Class NodeEdgeConnectorItem

java.lang.Object
com.dna.jopt.member.unit.nodeedge.NodeEdgeConnectorItem
All Implemented Interfaces:
INodeConnectorItem, Serializable, Cloneable

public class NodeEdgeConnectorItem extends Object implements INodeConnectorItem
A NodeEdgeConnnectorItem holds the two Strings of the start and the end location. Each NodeEdgeConnnectorItem is describing for example the time, distance etc. between two Nodes and is itself contained within a INodeEdgeConnector

The INodeConnectorItem can be populated with realistic data on distance and time needed between two locations. 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 which is more efficient 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:
16/09/2019
Author:
DNA
See Also:
  • Constructor Details

    • NodeEdgeConnectorItem

      public NodeEdgeConnectorItem()
  • Method Details

    • doAutoCalculateTime

      public void doAutoCalculateTime(boolean isDoAutoCalculateTime)
      Description copied from interface: INodeConnectorItem
      In case only a distance is provided by a user, the missing driving time information can be calculated on the fly.
      Specified by:
      doAutoCalculateTime in interface INodeConnectorItem
      Parameters:
      isDoAutoCalculateTime - the boolean to be set
    • isDoAutoCalculateTime

      public boolean isDoAutoCalculateTime()
      Description copied from interface: INodeConnectorItem
      Checks if the driving time has to be approximated by calculation because only distance but no exact driving time has been provided by the user.
      Specified by:
      isDoAutoCalculateTime in interface INodeConnectorItem
      Returns:
      the isDoAutoCalculateTime
      See Also:
    • getDistanceMeter

      public double getDistanceMeter()
      Description copied from interface: INodeConnectorItem
      Gets the distance in meters.
      Specified by:
      getDistanceMeter in interface INodeConnectorItem
      Returns:
      the double distanceMeter
    • getBaseTimeMillis

      public long getBaseTimeMillis()
      Description copied from interface: INodeConnectorItem
      Gets the base traveling time in milliseconds.
      Specified by:
      getBaseTimeMillis in interface INodeConnectorItem
      Returns:
      the base time millis
    • getTimeMillis

      public long getTimeMillis(IResource visitor)
      Description copied from interface: INodeConnectorItem
      Gets the traveling time in milliseconds correct for potential visitor modifications.
      Specified by:
      getTimeMillis in interface INodeConnectorItem
      Parameters:
      visitor - the visitor
      Returns:
      the long potentially modified timeMillis
    • getDistanceMeter

      public double getDistanceMeter(Instant time)
      Description copied from interface: INodeConnectorItem
      Gets the distance as function of time. If a IConnectionByTimeStore is present an input Instant will be used to extract the corresponding value. In case no store is present, the instant time is ignored.

      Internally, when the distance information of the connection is requested, the departure time of the from element is used as input.

      Specified by:
      getDistanceMeter in interface INodeConnectorItem
      Parameters:
      time - the instant time
      Returns:
      the set distanceMeter or the distanceMeter of the localDateTime
    • getTimeMillis

      public long getTimeMillis(IResource visitor, Instant time)
      Description copied from interface: INodeConnectorItem
      Gets the driving time as function of time. Further, the driving time has potential modifications by the visitor assigned. If a IConnectionByTimeStore is present an input Instant will be used to extract the corresponding value. In case no store is present, the instant time is ignored.

      Internally, when the driving time information of the connection is requested, the departure time of the from element is used as input.

      Specified by:
      getTimeMillis in interface INodeConnectorItem
      Parameters:
      visitor - the visitor
      time - the instant time
      Returns:
      the set timeMillis or the timeMillis (modified by the visitor) for the LocalDateTime
    • getBaseTimeMillis

      public long getBaseTimeMillis(Instant time)
      Description copied from interface: INodeConnectorItem
      Gets the driving time as function of time. Further, the driving time has potential modifications by the visitor assigned. If a IConnectionByTimeStore is present an input Instant will be used to extract the corresponding value. In case no store is present, the instant time is ignored.

      Internally, when the driving time information of the connection is requested, the departure time of the from element is used as input.

      Specified by:
      getBaseTimeMillis in interface INodeConnectorItem
      Parameters:
      time - the instant time
      Returns:
      the set timeMillis or the timeMillis of the LocalDateTime
    • setDrivingTime

      public void setDrivingTime(Duration duration)
      Description copied from interface: INodeConnectorItem
      Sets the driving time of that specific connection.

      Please note that the same connection in the other direction can have a different driving time.

      Specified by:
      setDrivingTime in interface INodeConnectorItem
      Parameters:
      duration - the duration of the driving time
    • setDistance

      public void setDistance(javax.measure.Quantity<javax.measure.quantity.Length> distance)
      Description copied from interface: INodeConnectorItem
      Sets distance of the specific connection.
      Specified by:
      setDistance in interface INodeConnectorItem
      Parameters:
      distance - Quantity of the distance to be set
    • setDistanceMeter

      @Deprecated public void setDistanceMeter(double distanceMeter)
      Deprecated.
      Description copied from interface: INodeConnectorItem
      Deprecated method

      Sets the distance of a connection in meters.

      Specified by:
      setDistanceMeter in interface INodeConnectorItem
      Parameters:
      distanceMeter - the double distance in meter to be set
    • setTimeMillis

      @Deprecated public void setTimeMillis(long timeMillis)
      Deprecated.
      Description copied from interface: INodeConnectorItem
      Deprecated method

      Sets the duration of a connection in milliseconds.

      Specified by:
      setTimeMillis in interface INodeConnectorItem
      Parameters:
      timeMillis - the long milliseconds to be set
    • getConnectionByTimeStore

      public IConnectionByTimeStore getConnectionByTimeStore()
      Description copied from interface: INodeConnectorItem
      Gets the IConnectionByTimeStore of a connection. In case the driving time is a function of the clock-time itself a connection store can be defined. For example, using a certain connection during a rushhour at a Monday morning takes longer compared to a Sunday afternoon.

      Further, the distance can be also modeled as a function of time, for example if another path is taken depending on the time.

      Specified by:
      getConnectionByTimeStore in interface INodeConnectorItem
      Returns:
      the connectionByTimeStore
    • setConnectionByTimeStore

      public void setConnectionByTimeStore(IConnectionByTimeStore connectionByTimeStore)
      Description copied from interface: INodeConnectorItem
      Sets the connectionByTimeStore. In case the driving time is a function of the clock-time itself a connection store can be defined. For example, using a certain connection during a rushhour at a Monday morning takes longer compared to a Sunday afternoon.
      Specified by:
      setConnectionByTimeStore in interface INodeConnectorItem
      Parameters:
      connectionByTimeStore - the iConnectionByTimeStore
    • getFromOptimizationElement

      public IOptimizationElement getFromOptimizationElement()
      Description copied from interface: INodeConnectorItem
      Gets the optimization element (usually a Node) from which the connection starts.
      Specified by:
      getFromOptimizationElement in interface INodeConnectorItem
      Returns:
      the fromOptimizationElement
    • setFromOptimizationElement

      public void setFromOptimizationElement(IOptimizationElement fromOptimizationElement)
      Description copied from interface: INodeConnectorItem
      Sets the optimization element (usually a Node) from which the connection starts.
      Specified by:
      setFromOptimizationElement in interface INodeConnectorItem
      Parameters:
      fromOptimizationElement - the iOptimizationElement to be set
    • getToOptimizationElement

      public IOptimizationElement getToOptimizationElement()
      Description copied from interface: INodeConnectorItem
      Gets the optimization element (usually a Node) at which the connection ends.
      Specified by:
      getToOptimizationElement in interface INodeConnectorItem
      Returns:
      the toOptimizationElement
    • setToOptimizationElement

      public void setToOptimizationElement(IOptimizationElement toOptimizationElement)
      Description copied from interface: INodeConnectorItem
      Sets the optimization element (usually a Node) at which the connection ends.
      Specified by:
      setToOptimizationElement in interface INodeConnectorItem
      Parameters:
      toOptimizationElement - the iOptimizationElement to be set
    • setIsCreatedOnTheFly

      public void setIsCreatedOnTheFly(boolean isCreatedOnTheFly)
      Description copied from interface: INodeConnectorItem
      Marks the connection as created on the fly in case the connection is not found in the INodeEdgeConnector which means it was created on the fly by its IBackupElementConnector.
      Specified by:
      setIsCreatedOnTheFly in interface INodeConnectorItem
      Parameters:
      isCreatedOnTheFly - the boolean to be set
    • isCreatedOnTheFly

      public boolean isCreatedOnTheFly()
      Description copied from interface: INodeConnectorItem
      Checks if the connection is created on the fly in case the connection is not found in the INodeEdgeConnector which means it was created on the fly by its IBackupElementConnector.
      Specified by:
      isCreatedOnTheFly in interface INodeConnectorItem
      Returns:
      the set status of isCreatedOnTheFly
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getShiftedCopy

      public Optional<INodeConnectorItem> getShiftedCopy(ReducedNodeEdgeConnectorItem deltaItem)
      Specified by:
      getShiftedCopy in interface INodeConnectorItem
    • getShiftedCopy

      public Optional<INodeConnectorItem> getShiftedCopy(INodeConnectorItem deltaItem)
      Specified by:
      getShiftedCopy in interface INodeConnectorItem