Class NodeEdgeConnector
java.lang.Object
com.dna.jopt.member.unit.nodeedge.AbstractNodeEdgeConnector
com.dna.jopt.member.unit.nodeedge.NodeEdgeConnector
- All Implemented Interfaces:
INodeEdgeConnector
,Serializable
A node connector is holding a
table
of INodeConnectorItem
which hold the two
Strings
of the start and the end location. Each INodeConnectorItem
is describing
for example the time, distance etc. between two nodes.
The INodeConnectorItem
can be populated with realistic data on distance and time
needed between two locations. The time and distance between two locations can be different
depending in which direction you are heading since traffic or route taken might change. If not
populated, air distance and average speed is being used.
The Nodes
are filtered before the INodeconnector
is being populated. If one
Node
is only accessible in December and another one only in January the Optimizer
never puts them in the same Route
and the specific data on the distance between these
Nodes
does not need to be acquired.
Implementation example:
List<INodeConnectorItem> connectionItems = new ArrayList<INodeConnectorItem>();
// Add connections from resources
INodeConnectorItem connectionJackHeilbronn = new NodeEdgeConnectorItem();
connectionJackHeilbronn.setFromOptimizationElement(resourceJackHeilbronn);
connectionJackHeilbronn.setToOptimizationElement(cityHeilbronn);
connectionJackHeilbronn.setDistance(Quantities.getQuantity(2, KILO(METRE)));
connectionJackHeilbronn.setDrivingTime(Duration.ofMinutes(10));
connectionItems.add(connectionJackHeilbronn);
// Add some connection items => The rest will be generated as fall back solution to bird
// distances.
INodeConnectorItem connectionKoelnOberhausen = new NodeEdgeConnectorItem();
connectionKoelnOberhausen.setFromOptimizationElement(cityKoeln);
connectionKoelnOberhausen.setToOptimizationElement(cityOberhausen);
connectionJackHeilbronn.setDistance(Quantities.getQuantity(20, KILO(METRE)));
connectionKoelnOberhausen.doAutoCalculateTime(true); // The time will be calculated based on the provided distance
connectionItems.add(connectionKoelnOberhausen);
INodeConnectorItem connectionOberhausenKoeln = new NodeEdgeConnectorItem();
connectionOberhausenKoeln.setFromOptimizationElement(cityOberhausen);
connectionOberhausenKoeln.setToOptimizationElement(cityKoeln);
connectionJackHeilbronn.setDistance(Quantities.getQuantity(20, KILO(METRE)));
connectionOberhausenKoeln.doAutoCalculateTime( true); // The time will be calculated based on the provided distance
connectionItems.add(connectionOberhausenKoeln);
INodeEdgeConnector myNodeConnector = new NodeEdgeConnector();
// Add items to connector
myNodeConnector.putNodeConnections(connectionItems);
// Set NodeEdgeConnector
setNodeConnector(this.myNodeConnector);
- Since:
- 03/08/2019
- Version:
- 06/09/2019
- Author:
- DNA
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionThe constructor for aNodeEdgeConnector
, which is used to clean up and remove connections.NodeEdgeConnector
(IBackupElementConnector backUpConnector) The constructor for aNodeEdgeConnector
, which is used to clean up and remove connections. -
Method Summary
Modifier and TypeMethodDescriptionstatic double
angleFromCoordinate
(double long1, double lat1, double long2, double lat2) cleanUp
(List<IOptimizationElement> presentItems, List<String> presentIdemIds) Cleans up the connections table by removing connections with no present items.static double
distancePlacePlaceFlatEarth
(double lon1, double lat1, double lon2, double lat2) static double
distancePlacePlaceFlatEarthPolar
(double lon1, double lat1, double lon2, double lat2) static double
distancePlacePlaceHaversine
(double lon1, double lat1, double lon2, double lat2) getNodeConnection
(IOptimizationElement fromElement, IOptimizationElement toElement, ILogicEntityRoute contextRoute) getNodeConnection
(IOptimizationElement fromElement, IOptimizationElement toElement, IResource visitor) Gets a specific node connection.void
refactorNodeConnectorConnection
(IOptimizationElement oldElement, IOptimizationElement newElement, boolean reAddConnections) boolean
removeConnection
(IOptimizationElement removeElement) Removes a connection.boolean
removeConnection
(IOptimizationElement removeElement, Optional<Set<String>> protectedIdsOpt) Removes the connection.void
removeConnectionFromElements
(IOptimizationElement removeElement) void
removeConnectionFromElements
(IOptimizationElement removeElement, Set<String> protectedIds) Methods inherited from class com.dna.jopt.member.unit.nodeedge.AbstractNodeEdgeConnector
attachSeparatedTestConnectionProvider, dropSeparatedTestConnectionProvider, getBackupElementConnector, getExternalConnectionProvider, getNodeConnection, getNodeConnections, getNodeConnectorTable, getSeparatedTestConnectionProvider, hasConnectionToOrFrom, putNodeConnection, putNodeConnection, putNodeConnectionIfNotExisting, putNodeConnectionIfNotExisting, putNodeConnections, putNodeConnectionsIfNotExisting, setBackupElementConnector, setExternalConnectionProvider, setNodeConnections
-
Constructor Details
-
NodeEdgeConnector
The constructor for aNodeEdgeConnector
, which is used to clean up and remove connections.- Parameters:
backUpConnector
- the iBackupElementConnector
-
NodeEdgeConnector
public NodeEdgeConnector()The constructor for aNodeEdgeConnector
, which is used to clean up and remove connections. The alternative with aIBackupElementConnector
isNodeEdgeConnector(IBackupElementConnector)
.
-
-
Method Details
-
removeConnectionFromElements
-
removeConnectionFromElements
public void removeConnectionFromElements(IOptimizationElement removeElement, Set<String> protectedIds) -
refactorNodeConnectorConnection
public void refactorNodeConnectorConnection(IOptimizationElement oldElement, IOptimizationElement newElement, boolean reAddConnections) -
removeConnection
public boolean removeConnection(IOptimizationElement removeElement, Optional<Set<String>> protectedIdsOpt) Description copied from interface:INodeEdgeConnector
Removes the connection. A connections is only protected, if both (from and too element) are on the list of protected ids.- Parameters:
removeElement
- the remove elementprotectedIdsOpt
- the protected ids opt- Returns:
- true, if successful
-
removeConnection
Description copied from interface:INodeEdgeConnector
Removes a connection.- Parameters:
removeElement
- the remove element- Returns:
- true, if successful
-
cleanUp
Description copied from interface:INodeEdgeConnector
Cleans up the connections table by removing connections with no present items.- Parameters:
presentItems
- the present items to be keptpresentIdemIds
- the present items ids to be kept.- Returns:
- the set strings of the removed nodeConnectorIds
-
getNodeConnection
public INodeConnectorItem getNodeConnection(IOptimizationElement fromElement, IOptimizationElement toElement, ILogicEntityRoute contextRoute) -
getNodeConnection
public INodeConnectorItem getNodeConnection(IOptimizationElement fromElement, IOptimizationElement toElement, IResource visitor) Description copied from interface:INodeEdgeConnector
Gets a specific node connection. This call will ignore connections hooks.- Parameters:
fromElement
- the startingIOptimizationElement
of the connectiontoElement
- the terminationIOptimizationElement
of the connectionvisitor
- theIResource
visitor- Returns:
- the node connection
-
distancePlacePlaceHaversine
public static double distancePlacePlaceHaversine(double lon1, double lat1, double lon2, double lat2) -
distancePlacePlaceFlatEarth
public static double distancePlacePlaceFlatEarth(double lon1, double lat1, double lon2, double lat2) -
distancePlacePlaceFlatEarthPolar
public static NodeEdgeConnector.FlatePlaceOnEarthItem distancePlacePlaceFlatEarthPolar(double lon1, double lat1, double lon2, double lat2) -
angleFromCoordinate
public static double angleFromCoordinate(double long1, double lat1, double long2, double lat2) -
distancePlacePlaceFlatEarth
-