operators module

class operators.AddAnchor(proba: float, **kwargs)[source]

Bases: Operator

Anchor operator: changes the anchors of the schedule.

proba: probability of the operator

apply_change(schedule: Schedule) Schedule[source]

Changes anchor nodes of given schedule.

compute_change_proba(prev_sched: Schedule, new_sched: Schedule, **kwargs) float[source]

Computes change probability.

-prev_sched, new_sched: Schedule objects

class operators.Assign(proba, list_act: Optional[List] = None, p_act: Optional[List] = None, **kwargs)[source]

Bases: Operator

Assign operator: adds an activity in the schedule

proba: probability of the operator list_act: list of activities to choose from p_act: choice probabilities for the activities chosen_act_proba: probability of the chosen activity

apply_change(schedule: Schedule) Schedule[source]

Assigns an activity to an existing block or anchor. The boundary conditions (first and last block are at home) must be respected.

compute_change_proba(prev_sched: Schedule, new_sched: Schedule, **kwargs) float[source]

Computes change probability.

-prev_sched, new_sched: Schedule objects

class operators.Block(proba: float, **kwargs)[source]

Bases: Operator

Block operator: changes the discretization of the schedule.

proba: probability of the operator discret_list: list of possible discretizations in hours

apply_change(schedule: Schedule) Schedule[source]

Changes discretization of given schedule

compute_change_proba(prev_sched: Schedule, new_sched: Schedule, n_discret: int = 4, **kwargs) float[source]

Computes change probability.

-prev_sched, new_sched: Schedule objects -n_discret: number of possible discretizations

class operators.InflateDeflate(proba, **kwargs)[source]

Bases: Operator

Inflate/deflate operator: increases or decreases duration of an activity

proba: probability of the operator

apply_change(schedule: Schedule) Schedule[source]

Randomly increases duration of one activity, and decrease duration of another by same amount.

compute_change_proba(prev_sched: Schedule, new_sched: Schedule, **kwargs) float[source]

Computes change probability.

-prev_sched, new_sched: Schedule objects

class operators.Location(proba, list_loc=None, p_loc=None, **kwargs)[source]

Bases: Operator

Location operator: changes location associated with activity

proba: probability of the operator list_loc: list of possible locations to choose from p_loc: associated probabilities

apply_change(schedule: Schedule) Schedule[source]

This operator randomly changes the travel mode of the selected activty

compute_change_proba(prev_sched, new_sched, **kwargs)[source]

Computes forward probability of change.

class operators.MetaOperator(proba: float, n_op: int, proba_operators: float, operators: Optional[List] = None, **kwargs)[source]

Bases: Operator

Meta operator: implements a combination of operators

proba: probability of the operator n_op: number of operators to combine proba_operators: probabilities of each operato operators: list of possible operators

apply_change(schedule: Schedule) Schedule[source]

Applies combined changes of operators

compute_change_proba(prev_schedule: Schedule, new_schedule: Schedule, time: int = 24, n_activities: int = 8, n_discret: int = 4, **kwargs) float[source]

Computes forward probability of change.

property meta_type
set_operators() None[source]

Creates combination of operators

class operators.Mode(proba, list_modes=None, p_modes=None, **kwargs)[source]

Bases: Operator

Mode operator: changes mode of transportation associated with activity

proba: probability of the operator list_modes: list of possible modes to choose from p_modes: associated probabilities

apply_change(schedule: Schedule) Schedule[source]

This operator randomly changes the travel mode of the selected activty

compute_change_proba(prev_sched: Schedule, new_sched: Schedule, **kwargs)[source]

Computes change probability.

-prev_sched, new_sched: Schedule objects

class operators.Operator(optype: str, proba: float, **kwargs)[source]

Bases: object

This class creates an “operator” unit to be used in the estimation process. Operators can easily be created with the OperatorFactory class.

  • optype: label of the operator

  • proba: probability associated with the operator

  • list_operators: the list of currently available operators.

  • describe: prints information on the operator

  • apply_change: applies a change to the given schedule.

  • compute_change_proba: computes probability of change

apply_change(schedule: Schedule) Schedule[source]

Applies change on given schedule.

compute_change_proba()[source]

Computes forward probability of change.

describe()[source]
property list_operators
property optype
property proba
class operators.OperatorFactory[source]

Bases: object

This class creates an object from the Operator class.

create(optype: str, **kwargs) Operator[source]

Creates an object from the Operator class

Parameters:
  • -optype (label of operator) –

  • -kwargs (other keyword arguments that will be passed to the constructor of the Operator class.) –

Return type:

Operator

draw(list_operators: List, p_operators: Optional[List] = None, **kwargs) Operator[source]

Randomly creates an object from the Operator class, given a list of possible operators and probabilities.

Parameters:
  • -list_operators (list of possible operators to choose from) –

  • -p_operators (list of operator probabilities (must be the same length as list_operators and sum up to 1)) –

  • -kwargs (other keyword arguments that will be passed to the constructor of the Operator class.) –

Return type:

Operator

class operators.Swap(proba, **kwargs)[source]

Bases: Operator

Swap operator: swaps 2 adjacent blocks (start time and duration)

proba: probability of the operator

apply_change(schedule: Schedule) Schedule[source]

Swaps 2 adjacent blocks (start time and duration)

compute_change_proba(prev_sched: Schedule, new_sched: Schedule, **kwargs)[source]

Computes change probability.

-prev_sched, new_sched: Schedule objects