Package org.goplanit.demands
Class Demands
- java.lang.Object
-
- org.goplanit.component.PlanitComponent<Demands>
-
- org.goplanit.demands.Demands
-
- All Implemented Interfaces:
Serializable,Comparable<IdAble>,EventListener,PlanitComponentListener,EventListener,ExternalIdAble,IdAble
public class Demands extends PlanitComponent<Demands> implements Serializable
Container class for all demands registered on the project. In PlanIt we assume that all traffic flows between an origin and destination. Hence all demand for a given time period and mode is provided between an origin and destination via ODDemand. Further, unlike other components, we let anyone register OdDemand compatible instances on this class to provide maximum flexibility in the underlying container since depending on the od data different containers might be preferred for optimizing memory usage. Also not all OdDemand instances on the same Demands instance might utilize the same data structure, hence the need to avoid a general approach across all entries within a Demands instance- Author:
- markr
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description DemandsModifierdemandModifiermodifier features for demandsprotected TreeMap<Long,TreeMap<Mode,OdDemands>>odDemandsByTimePeriodAndModeTrip demand matricesTimePeriodstimePeriodsinternal class instance containing all time periods on this demand instanceTravellerTypestravelerTypesinternal class instance containing all traveler types on this demand instanceUserClassesuserClassesinternal class instance containing all user classes on this demand instance
-
Constructor Summary
Constructors Constructor Description Demands(Demands other, boolean deepCopy)Copy constructorDemands(IdGroupingToken groupId)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,String>collectSettingsAsKeyValueMap()Provide all the settings of this particular component by name and value, where each value is a string representation of the underlying entityDemandsdeepClone()deep clone on planit component should attempt to also update internal dependencies between deep cloned containers where possibleOdDemandsget(Mode mode, TimePeriod timePeriod)Get an OdDemand by mode and time period in pcu/hourDemandsModifiergetDemandsModifier()access to modifier featuresSet<Mode>getRegisteredModesForTimePeriod(TimePeriod timePeriod)Get modes registered for the given time periodvoidlogInfo(String prefix)Log general information on this demands to the userOdDemandsregisterOdDemandPcuHour(TimePeriod timePeriod, Mode mode, OdDemands odDemandsPcuHour)Register provided odDemandvoidreset()reset all demands, traveler types, time periods and user classesDemandsshallowClone()Create a shallow copy of this entityvoidupdateUserClassTravellerTypes(Function<TravellerType,TravellerType> ttToTtMapping, boolean removeMissingMappings)Update the traveller type of all user classes based on the mapping provided (if any)-
Methods inherited from class org.goplanit.component.PlanitComponent
equals, getComponentType, getExternalId, getId, getIdGroupingToken, getKnownSupportedEventTypes, getXmlId, hashCode, onPlanitComponentEvent, setExternalId, setXmlId
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.event.EventListener
hasKnownSupportedEventTypes
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
appendExternalId, appendExternalId, getIdsAsString, getSplitExternalId, getSplitExternalId, hasExternalId, hasXmlId, setXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, idEquals, idHashCode
-
-
-
-
Field Detail
-
odDemandsByTimePeriodAndMode
protected final TreeMap<Long,TreeMap<Mode,OdDemands>> odDemandsByTimePeriodAndMode
Trip demand matrices
-
timePeriods
public final TimePeriods timePeriods
internal class instance containing all time periods on this demand instance
-
userClasses
public final UserClasses userClasses
internal class instance containing all user classes on this demand instance
-
travelerTypes
public final TravellerTypes travelerTypes
internal class instance containing all traveler types on this demand instance
-
demandModifier
public final DemandsModifier demandModifier
modifier features for demands
-
-
Constructor Detail
-
Demands
public Demands(IdGroupingToken groupId)
Constructor- Parameters:
groupId- contiguous id generation within this group for instances of this class
-
Demands
public Demands(Demands other, boolean deepCopy)
Copy constructor- Parameters:
other- to copydeepCopy- when true, create a deep copy, shallow copy otherwise
-
-
Method Detail
-
updateUserClassTravellerTypes
public void updateUserClassTravellerTypes(Function<TravellerType,TravellerType> ttToTtMapping, boolean removeMissingMappings)
Update the traveller type of all user classes based on the mapping provided (if any)- Parameters:
ttToTtMapping- to use should contain original travellerType as currently used on user class and then the value is the new traveller type to replace itremoveMissingMappings- when true if there is no mapping, the traveller type is nullified, otherwise they are left in-tact
-
registerOdDemandPcuHour
public OdDemands registerOdDemandPcuHour(TimePeriod timePeriod, Mode mode, OdDemands odDemandsPcuHour)
Register provided odDemand- Parameters:
timePeriod- the time period for this origin-demand objectmode- the mode for this origin-demand objectodDemandsPcuHour- the origin-demand object to be registered in pcu/hour- Returns:
- oldOdDemand if there already existed an odDemand for the given mode and time period, the overwritten entry is returned
-
get
public OdDemands get(Mode mode, TimePeriod timePeriod)
Get an OdDemand by mode and time period in pcu/hour- Parameters:
mode- the mode for which the ODDemand object is requiredtimePeriod- the time period for which the ODDemand object is required- Returns:
- ODDemand object if found, otherwise null
-
getRegisteredModesForTimePeriod
public Set<Mode> getRegisteredModesForTimePeriod(TimePeriod timePeriod)
Get modes registered for the given time period- Parameters:
timePeriod- the specified time period- Returns:
- Set of modes for this time period
-
shallowClone
public Demands shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClonein interfaceIdAble- Specified by:
shallowClonein classPlanitComponent<Demands>- Returns:
- shallow copy of entity
-
deepClone
public Demands deepClone()
deep clone on planit component should attempt to also update internal dependencies between deep cloned containers where possible- Specified by:
deepClonein interfaceIdAble- Specified by:
deepClonein classPlanitComponent<Demands>- Returns:
- deep copy of entity
-
logInfo
public void logInfo(String prefix)
Log general information on this demands to the user- Parameters:
prefix- to use
-
reset
public void reset()
reset all demands, traveler types, time periods and user classes- Specified by:
resetin classPlanitComponent<Demands>
-
getDemandsModifier
public DemandsModifier getDemandsModifier()
access to modifier features- Returns:
- demand modifier
-
collectSettingsAsKeyValueMap
public Map<String,String> collectSettingsAsKeyValueMap()
Provide all the settings of this particular component by name and value, where each value is a string representation of the underlying entity- Specified by:
collectSettingsAsKeyValueMapin classPlanitComponent<Demands>- Returns:
- name-value map of all (user configurable) settings
-
-