Network elements - MayerTh/RVRPSimulator GitHub Wiki

There are currently two simulation network elements which are implementing the interface for network elements: IVRPSimulationModelNewtorkElements. With the help of these elements (IWay and INode) an underlying routing network can be build. The INode holds a location and a list of IWay, a node models the home of several structure elements. An IWay defines a source and a target from type INode, a maximum driving speed, a IDistanceFunction, and a ITimeFunction.

IDistanceFunction is a functional interfaces requiring the implementation of the following method.

    /**
     * Returns the distance between the two instances of {@link Location}.
     * 
     * @param location1
     * @param location2
     * @return
     */
     public Double getDistance(Location location1, Location location2);

RVRPSimulator provides Euclidean2DDistanceFunction which calculates the euclidean distance between the two given location as implementation of IDistanceFunction. ITimeFunction is also a functional interface requiring the implementation of following method.

     /**
     * Returns a travel time depending on following parameters:
     * 
     * @param source
     * @param destination
     * @param distanceFunction
     * @param maxWaySpeed
     * @param movable
     * @return
     */
     public Double getTravelTime(Location source, Location destination, 
          IDistanceFunction distanceFunction, Double maxWaySpeed, 
               IVRPSimulationModelStructureElementWithStorageMovable movable, 
                    IClock clock);

As you can see the time a vehicle is traveling on a way is calculated with the help of the IDistanceFunction, the maximum speed of the way and the vehicle (IVRPSimulationModelStructureElementWithStorageMovable) itself. Note that also a time dependent travel time can be claculated, so you can model that traveling times during rush hour are usually longer than during other times of the day. RVRPSimulator provides LinearMotionTravelTimeFunction which calculates the travel time as linar motion between the two location depending on Math.min(maxWaySpeed, movable.getAverageSpeed()) and distanceFunction.getDistance(source, target), and a ZeroTravelTimeFunction.

Note, that if you would like to calculate your traveling times with the help of the [GoogleMapsAPI] (https://developers.google.com/maps/?hl=en) or any other API, you only have to introduce a new ITimeFunction which calls the API and returns the travel time as Double. Attach this GoogleMaps-ITimeFunction to your ways and the simulation will run with traveling times calculated by Google. It is also possible to plugin a traffic simulation tool like [SUMO] (http://www.dlr.de/ts/en/desktopdefault.aspx/tabid-9883/16931_read-41000/).

Default implementation and network elements acting as resources

RVRPSimulator provides the default implementations DefaultWay and DefaultNode. Since all network elements are implementing the interface IVRPSimulationModelElement, network elements are acting as resources within the simulation. They can get allocated by IVRPSimulationBehaviourElementCanAllocate. For example the [bevaiour element] (https://github.com/MayerTh/RVRPSimulator/wiki/Behaviour-elements) TransportActivity allocates a way during activity execution. This concept allows traffic dependent travel time modelling for ways. So a non default implementation of the network element IWay can count the number of transports executed and return an depending travel time.