MATSIM
Public Member Functions | Public Attributes | List of all members
org.matsim.core.scoring.ScoringFunction Interface Reference
Inheritance diagram for org.matsim.core.scoring.ScoringFunction:
Inheritance graph
[legend]

Public Member Functions

void handleActivity (Activity activity)
 
void handleLeg (Leg leg)
 
void agentStuck (final double time)
 
void addMoney (final double amount)
 
void addScore (final double amount)
 
void finish ()
 
double getScore ()
 
void handleEvent (Event event)
 
default void handleTrip (TripStructureUtils.Trip trip)
 
default void explainScore (StringBuilder out)
 

Public Attributes

String SCORE_DELIMITER = ";"
 
String SCORE_EXPLANATION_ATTR = "scoreExplanation"
 

Detailed Description

A scoring function calculates the score for one plan of an agent. The score usually depends on how much time an agent is traveling and how much time an agent spends at an activity. Thus the scoring function gets informed when activities start and end as well as when legs start and end.
Note that one ScoringFunction calculates the score for exactly one agent. Thus every agents must have its own instance of a scoring function!

See tutorial.programming.example16customscoring.RunCustomScoringExample for an example.

Author
mrieser

Definition at line 42 of file ScoringFunction.java.

Member Function Documentation

◆ handleActivity()

void org.matsim.core.scoring.ScoringFunction.handleActivity ( Activity  activity)

Tells the scoring function about an Activity. The Activity which the agent is in when the simulation starts will have a startTime of Time.getUndefinedTime(). The Activity which the agent is in when the simulation ends will have an endTime of Time.getUndefinedTime(). It is up to the implementation what to make of this, especially to "wrap" it "around".

Parameters
activity

Implemented in org.matsim.deprecated.scoring.ScoringFunctionAccumulator, org.matsim.core.scoring.SumScoringFunction, org.matsim.core.scoring.functions.OnlyTravelTimeDependentScoringFunction, and org.matsim.deprecated.scoring.ScoringFunctionAdapter.

◆ handleLeg()

void org.matsim.core.scoring.ScoringFunction.handleLeg ( Leg  leg)

Tells the scoring function about a Leg. Will contain complete route information for network routes (as you would expect in a Plan), but only a GenericRoute for everything else, especially transit.

Implemented in org.matsim.deprecated.scoring.ScoringFunctionAccumulator, org.matsim.core.scoring.SumScoringFunction, org.matsim.deprecated.scoring.ScoringFunctionAdapter, and org.matsim.core.scoring.functions.OnlyTravelTimeDependentScoringFunction.

◆ agentStuck()

void org.matsim.core.scoring.ScoringFunction.agentStuck ( final double  time)

Tells the scoring function that the agent got stuck in the simulation and is removed from the simulation. This should usually lead to a high penalty in the score, as the agent was not able to perform its plan as wanted. An agent can get stuck while performing an activity or while driving.

Parameters
timeThe time at which the agent got stuck and was removed from the simulation.

Implemented in org.matsim.core.scoring.SumScoringFunction, org.matsim.deprecated.scoring.ScoringFunctionAccumulator, and org.matsim.core.scoring.functions.OnlyTravelTimeDependentScoringFunction.

◆ addMoney()

void org.matsim.core.scoring.ScoringFunction.addMoney ( final double  amount)

Adds the specified amount of utility to the agent's score. This is mostly used for handling PersonMoneyEvents, allowing other parts of the code to influence an agent's score.

Parameters
amountamount to be added to the agent's score

Implemented in org.matsim.core.scoring.SumScoringFunction, org.matsim.deprecated.scoring.ScoringFunctionAccumulator, and org.matsim.core.scoring.functions.OnlyTravelTimeDependentScoringFunction.

◆ addScore()

void org.matsim.core.scoring.ScoringFunction.addScore ( final double  amount)

Adds the specified amount of utility to the agent's score. This is mostly used for handling PersonScoreEvents, allowing other parts of the code to influence an agent's score.

Parameters
amountamount to be added to the agent's score

Implemented in org.matsim.core.scoring.SumScoringFunction, org.matsim.deprecated.scoring.ScoringFunctionAccumulator, and org.matsim.core.scoring.functions.OnlyTravelTimeDependentScoringFunction.

◆ finish()

void org.matsim.core.scoring.ScoringFunction.finish ( )

Tells the scoring function that no more information will be given to it and that the final score should be calculated. But the score must not be written to the plan!

Implemented in org.matsim.deprecated.scoring.ScoringFunctionAccumulator, org.matsim.core.scoring.SumScoringFunction, and org.matsim.core.scoring.functions.OnlyTravelTimeDependentScoringFunction.

◆ getScore()

double org.matsim.core.scoring.ScoringFunction.getScore ( )

◆ handleEvent()

void org.matsim.core.scoring.ScoringFunction.handleEvent ( Event  event)

◆ handleTrip()

default void org.matsim.core.scoring.ScoringFunction.handleTrip ( TripStructureUtils.Trip  trip)

Definition at line 107 of file ScoringFunction.java.

107  {
108  // empty default implementation, since older implementations of the interface
109  // don't have this method, and work happily without. kai, sep'18
110  }

◆ explainScore()

default void org.matsim.core.scoring.ScoringFunction.explainScore ( StringBuilder  out)

Write detailed score explanation into the output

out

. Multiple value should be separated with SCORE_DELIMITER.

Implemented in org.matsim.core.scoring.SumScoringFunction.

Definition at line 115 of file ScoringFunction.java.

115  {
116  }

Member Data Documentation

◆ SCORE_DELIMITER

String org.matsim.core.scoring.ScoringFunction.SCORE_DELIMITER = ";"

◆ SCORE_EXPLANATION_ATTR

String org.matsim.core.scoring.ScoringFunction.SCORE_EXPLANATION_ATTR = "scoreExplanation"

The attribute that will be used for the score explanation.

Definition at line 125 of file ScoringFunction.java.


The documentation for this interface was generated from the following file: