Interface INodeConnectorItem

All Superinterfaces:
Cloneable, Serializable
All Known Implementing Classes:
NodeEdgeConnectorItem

public interface INodeConnectorItem extends Cloneable, Serializable
A INodeConnectorItem holds the two Strings of the start and the target location. Each INodeConnectorItem is describing for example the time, distance etc. between two IOptimizationElement and is itself contained within a INodeEdgeConnector

The INodeConnectorItem can be populated with realistic data of distance and traveling time needed between two locations. If not populated, missing connection items are created by a IBackupElementConnector. The generation is triggered by the INodeEdgeConnector. By default the DefaultFlatEarthAverageSpeedBackupElementConnector is used.

Basic 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 based on a IBackupElementConnector

     INodeConnectorItem connectionKoelnOberhausen = new NodeEdgeConnectorItem();
     connectionKoelnOberhausen.setFromOptimizationElement(city!oeln);
     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 to an optimization instance
     opti.setNodeConnector(this.myNodeConnector);
 
Since:
19/11/2018
Version:
19/09/2019
Author:
DNA
  • Method Details

    • getDistanceMeter

      double getDistanceMeter()
      Gets the distance in meters.
      Returns:
      the double distanceMeter
    • getTimeMillis

      long getTimeMillis(IResource visitor)
      Gets the traveling time in milliseconds correct for potential visitor modifications.
      Parameters:
      visitor - the visitor
      Returns:
      the long potentially modified timeMillis
    • getBaseTimeMillis

      long getBaseTimeMillis()
      Gets the base traveling time in milliseconds.
      Returns:
      the base time millis
    • getDistanceMeter

      double getDistanceMeter(Instant time)
      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.

      Parameters:
      time - the instant time
      Returns:
      the set distanceMeter or the distanceMeter of the localDateTime
    • getTimeMillis

      long getTimeMillis(IResource visitor, Instant time)
      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.

      Parameters:
      visitor - the visitor
      time - the instant time
      Returns:
      the set timeMillis or the timeMillis (modified by the visitor) for the LocalDateTime
    • getBaseTimeMillis

      long getBaseTimeMillis(Instant time)
      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.

      Parameters:
      time - the instant time
      Returns:
      the set timeMillis or the timeMillis of the LocalDateTime
    • setDistance

      void setDistance(javax.measure.Quantity<javax.measure.quantity.Length> distance)
      Sets distance of the specific connection.
      Parameters:
      distance - Quantity of the distance to be set
    • setDrivingTime

      void setDrivingTime(Duration time)
      Sets the driving time of that specific connection.

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

      Parameters:
      time - the duration of the driving time
    • setDistanceMeter

      @Deprecated void setDistanceMeter(double distanceMeter)
      Deprecated.
      please use setDistance(Quantity) instead
      Deprecated method

      Sets the distance of a connection in meters.

      Parameters:
      distanceMeter - the double distance in meter to be set
    • setTimeMillis

      @Deprecated void setTimeMillis(long timeMillis)
      Deprecated.
      please use setDrivingTime(Duration) instead
      Deprecated method

      Sets the duration of a connection in milliseconds.

      Parameters:
      timeMillis - the long milliseconds to be set
    • getConnectionByTimeStore

      IConnectionByTimeStore getConnectionByTimeStore()
      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.

      Returns:
      the connectionByTimeStore
    • setConnectionByTimeStore

      void setConnectionByTimeStore(IConnectionByTimeStore connectionByTimeStore)
      Sets the NodeEdgeConnectorItem.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.
      Parameters:
      connectionByTimeStore - the iConnectionByTimeStore
    • getFromOptimizationElement

      IOptimizationElement getFromOptimizationElement()
      Gets the optimization element (usually a Node) from which the connection starts.
      Returns:
      the fromOptimizationElement
    • setFromOptimizationElement

      void setFromOptimizationElement(IOptimizationElement fromOptimizationElement)
      Sets the optimization element (usually a Node) from which the connection starts.
      Parameters:
      fromOptimizationElement - the iOptimizationElement to be set
    • getToOptimizationElement

      IOptimizationElement getToOptimizationElement()
      Gets the optimization element (usually a Node) at which the connection ends.
      Returns:
      the toOptimizationElement
    • setToOptimizationElement

      void setToOptimizationElement(IOptimizationElement toOptimizationElement)
      Sets the optimization element (usually a Node) at which the connection ends.
      Parameters:
      toOptimizationElement - the iOptimizationElement to be set
    • setIsCreatedOnTheFly

      void setIsCreatedOnTheFly(boolean isCreatedOnTheFly)
      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.
      Parameters:
      isCreatedOnTheFly - the boolean to be set
    • isCreatedOnTheFly

      boolean isCreatedOnTheFly()
      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.
      Returns:
      the set status of isCreatedOnTheFly
    • doAutoCalculateTime

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

      boolean isDoAutoCalculateTime()
      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.
      Returns:
      the isDoAutoCalculateTime
      See Also:
    • getShiftedCopy

      Optional<INodeConnectorItem> getShiftedCopy(INodeConnectorItem deltaItem)
    • getShiftedCopy