52 typedef std::vector<std::tuple<std::string, std::string, std::string> >
AssignmentMap;
55 Function(
const std::string& _id =
"",
int _nArgs = -1):
75 const std::string&
id,
const std::string& programID,
80 const std::string& basePath,
124 int step,
SUMOTime stepDuration)
override;
137 const std::string
getParameter(
const std::string& key,
const std::string defaultValue =
"")
const override;
140 void setParameter(
const std::string& key,
const std::string& value)
override;
149 std::map<std::string, double>
getConditions()
const override;
215 double evalTernaryExpression(
double a,
const std::string& o,
double b,
const std::string& condition)
const;
244 bool weakConflict(
int linkIndex,
const std::string& state)
const;
246 template<
typename T, SumoXMLTag Tag>
248 const T* det =
dynamic_cast<const T*
>(
251 if (det ==
nullptr) {
254 return retrieveDetExpression<T, Tag>(arg, expr,
false);
256 throw ProcessError(
"Unknown detector '" + arg +
"' in expression '" + expr +
"'");
327 mutable std::vector<std::map<std::string, double> >
myStack;
An actuated (adaptive) traffic light logic.
double myDetectorGap
The detector distance in seconds.
FunctionMap myFunctions
The loaded functions.
double myJamThreshold
The minimum continuous occupancy time to mark a detector as jammed.
bool myBuildAllDetectors
Whether all detectors shall be built.
double myMaxGap
The maximum gap to check in seconds.
const std::string getParameter(const std::string &key, const std::string defaultValue="") const override
try to get the value of the given parameter (including prefixed parameters)
std::vector< SwitchingRules > mySwitchingRules
~MSActuatedTrafficLightLogic()
Destructor.
std::vector< std::map< std::string, double > > myStack
The function call stack;.
double evalAtomicExpression(const std::string &expr) const
evaluate atomic expression
int getTarget(int step)
get the green phase following step
SUMOTime trySwitch() override
Switches to the next phase.
SUMOTime myLastTrySwitchTime
last time trySwitch was called
int getDetectorPriority(const InductLoopInfo &loopInfo) const
SUMOTime myFreq
The frequency for aggregating detector output.
SUMOTime getMinimumMinDuration(MSLane *lane) const
get the minimum min duration for all stretchable phases that affect the given lane
std::vector< const MSInductLoop * > myExtraLoops
extra loops for output/tracking
bool myShowDetectors
Whether the detectors shall be shown in the GUI.
std::vector< SUMOTime > myLinkMaxGreenTimes
maximum consecutive time that the given link may remain green
void loadState(MSTLLogicControl &tlcontrol, SUMOTime t, int step, SUMOTime spentDuration) override
restores the tls state
SUMOTime getMaxDur(int step=-1) const override
std::vector< std::vector< InductLoopInfo * > > InductLoopMap
Definition of a map from phases to induct loops controlling them.
AssignmentMap myAssignments
The condition assignments.
std::string myVehicleTypes
Whether detector output separates by vType.
double gapControl()
Return the minimum detection gap of all detectors if the current phase should be extended and double:...
std::vector< std::tuple< std::string, std::string, std::string > > AssignmentMap
std::set< std::string > myListedConditions
the conditions which shall be listed in GUITLLogicPhasesTrackerWindow
double evalExpression(const std::string &condition) const
evaluate custom switching condition
std::vector< SUMOTime > myLinkMinGreenTimes
minimum consecutive time that the given link must remain green
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration) override
Changes the current phase and her duration.
bool weakConflict(int linkIndex, const std::string &state) const
whether a given link has only weak mode foes that are green in the given state
static const std::vector< std::string > OPERATOR_PRECEDENCE
void deactivateProgram() override
bool myHasMultiTarget
Whether any of the phases has multiple targets.
double myPassingTime
The passing time used in seconds.
SUMOTime getLinkMinDuration(int target) const
the minimum duratin for keeping the current phase due to linkMinDur constraints
SUMOTime getMinDur(int step=-1) const override
bool canExtendLinkGreen(int target)
whether the target phase is acceptable in light of linkMaxDur constraints
InductLoopMap myInductLoopsForPhase
A map from phase to induction loops to be used for gap control.
int decideNextPhaseCustom(bool mustSwitch)
select among candidate phases based on detector states and custom switching rules
double evalTernaryExpression(double a, const std::string &o, double b, const std::string &condition) const
evaluate atomic expression
void executeAssignments(const AssignmentMap &assignments, ConditionMap &conditions, const ConditionMap &forbidden=ConditionMap()) const
execute assignemnts of the logic or a custom function
void setShowDetectors(bool show)
bool myTraCISwitch
whether the next switch time was requested via TraCI
int getPhasePriority(int step) const
count the number of active detectors for the given step
SUMOTime duration(const double detectionGap) const
Returns the minimum duration of the current phase.
void activateProgram() override
called when switching programs
std::vector< InductLoopInfo > myInductLoops
bool maxLinkDurationReached()
whether the current phase cannot be continued due to linkMaxDur constraints
double evalCustomFunction(const std::string &fun, const std::string &arg) const
evaluate function expression
void initAttributeOverride()
initialize custom switching rules
std::map< std::string, double > getConditions() const override
return all named conditions defined for this traffic light
bool hasMajor(const std::string &state, const LaneVector &lanes) const
return whether there is a major link from the given lane in the given phase
std::vector< const MSE2Collector * > myExtraE2
SUMOTime getEarliestEnd(int step=-1) const override
std::map< std::string, Function > FunctionMap
std::map< std::string, double > getDetectorStates() const override
retrieve all detectors used by this program
double getDetectorState(const std::string laneID) const override
retrieve a specific detector used by this program
void setParameter(const std::string &key, const std::string &value) override
Sets a parameter and updates internal constants.
std::vector< SUMOTime > myLinkGreenTimes
consecutive time that the given link index has been green
const T * retrieveDetExpression(const std::string &arg, const std::string &expr, bool tryPrefix) const
SUMOTime getLatestEnd(int step=-1) const override
bool showDetectors() const
std::vector< SUMOTime > myLinkRedTimes
Parameterised::Map ConditionMap
std::string myFile
The output file for generated detectors.
void initSwitchingRules()
ConditionMap myConditions
The custom switching conditions.
const std::string myDetectorPrefix
void init(NLDetectorBuilder &nb) override
Initialises the tls with information about incoming lanes.
int decideNextPhase()
select among candidate phases based on detector states
SUMOTime myInactiveThreshold
The time threshold to avoid starved phases.
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
An unextended detector measuring at a fixed position on a fixed lane.
double getOccupancyTime() const
Returns the time of continous occupation by the same vehicle in seconds or 0 if there is no vehicle o...
Representation of a lane in the micro simulation.
MSDetectorControl & getDetectorControl()
Returns the detector control.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
A fixed traffic light logic.
A class that stores and controls tls and switching of their programs.
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Builds detectors for microsim.
T get(const std::string &id) const
Retrieves an item.
std::map< std::string, std::string > Map
parameters map
AssignmentMap assignments
Function(const std::string &_id="", int _nArgs=-1)
InductLoopInfo(MSInductLoop *_loop, const MSLane *_lane, int numPhases, double _maxGap, double _jamThreshold)
std::vector< bool > servedPhase