Class NodeEdgeConnector

java.lang.Object
com.dna.jopt.member.unit.nodeedge.AbstractNodeEdgeConnector
com.dna.jopt.member.unit.nodeedge.NodeEdgeConnector
All Implemented Interfaces:
INodeEdgeConnector, Serializable

public class NodeEdgeConnector extends AbstractNodeEdgeConnector
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:
  • Constructor Details

  • Method Details

    • removeConnectionFromElements

      public void removeConnectionFromElements(IOptimizationElement removeElement)
    • 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 element
      protectedIdsOpt - the protected ids opt
      Returns:
      true, if successful
    • removeConnection

      public boolean removeConnection(IOptimizationElement removeElement)
      Description copied from interface: INodeEdgeConnector
      Removes a connection.
      Parameters:
      removeElement - the remove element
      Returns:
      true, if successful
    • cleanUp

      public Set<String> cleanUp(List<IOptimizationElement> presentItems, List<String> presentIdemIds)
      Description copied from interface: INodeEdgeConnector
      Cleans up the connections table by removing connections with no present items.
      Parameters:
      presentItems - the present items to be kept
      presentIdemIds - 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 starting IOptimizationElement of the connection
      toElement - the termination IOptimizationElement of the connection
      visitor - the IResource 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

      public static double distancePlacePlaceFlatEarth(IOptimizationElement e1, IOptimizationElement e2)