Activity
- class unified_planning.model.scheduling.Activity(name: str, duration: int = 1, _env: Environment | None = None)[source]
Bases:
Chronicle
Activity is essentially an interval with start and end timepoint that facilitates defining constraints in the associated
SchedulingProblem
- property duration: DurationInterval
Returns the activity duration interval.
- set_fixed_duration(value: int | float | Fraction | str | FNode)[source]
Sets the duration interval for this activity as the interval [value, value].
- Parameters:
value – The value set as both edges of this action’s duration.
- set_duration_bounds(lower: int | float | Fraction | str | FNode, upper: int | float | Fraction | str | FNode)[source]
Sets the duration interval for this activity as the interval [lower, upper].
- Parameters:
lower – The value set as the lower edge of this action’s duration.
upper – The value set as the upper edge of this action’s duration.
- uses(resource: Fluent | FNode, amount: int | float | Fraction | str | FNode = 1)[source]
Asserts that the activity borrows a given amount (1 by default) of the resource. The borrowed resources will be reusable by another activity at the time epoch immediately succeeding the activity end.
- Parameters:
resource – Fluent expression that denotes the resource taht is used.
amount – Quantity of the resource that is borrowed over the course of the activity.
- add_release_date(date: int | float | Fraction | str | FNode)[source]
Sets the earliest date at which the activity can be started.
- add_deadline(date: int | float | Fraction | str | FNode)[source]
Sets the latest date at which the activity might end.
- add_condition(interval: Timing | Timepoint | int | float | Fraction | TimeInterval, condition: FNode | Fluent | Parameter | bool)
Adds the given expression to the action’s conditions. For this action to be applicable the given expression must evaluate to True during the whole given interval.
- Parameters:
interval – The interval in which the given expression must evaluate to True for this action to be applicable.
condition – The expression that must be True in the given interval for this action to be applicable.
- add_constraint(constraint: FNode | Fluent | Parameter | bool)
Adds the given expression to the chronicle’s constraints.
- add_decrease_effect(timing: Timing | Timepoint | int | float | Fraction, fluent: FNode | Fluent, value: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object, condition: FNode | Fluent | Parameter | Variable | bool = True, forall: Iterable[Variable] = ())
At the given time, adds the given decrement to the action’s effects.
- Parameters:
timing – The exact time in which the decrement is applied.
fluent – The fluent which value is decremented by the added effect.
value – The given fluent is decremented by the given value.
condition – The condition in which this effect is applied; the default value is True.
forall – The ‘Variables’ that are universally quantified in this effect; the default value is empty.
- add_effect(timing: Timing | Timepoint | int | float | Fraction, fluent: FNode | Fluent, value: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object, condition: FNode | Fluent | Parameter | Variable | bool = True, forall: Iterable[Variable] = ())
At the given time, adds the given assignment to the action’s effects.
- Parameters:
timing – The exact time in which the assignment is applied.
fluent – The fluent which value is modified by the assignment.
value – The value to assign to the given fluent.
condition – The condition in which this effect is applied; the default value is True.
forall – The ‘Variables’ that are universally quantified in this effect; the default value is empty.
- add_increase_effect(timing: Timing | Timepoint | int | float | Fraction, fluent: FNode | Fluent, value: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object, condition: FNode | Fluent | Parameter | Variable | bool = True, forall: Iterable[Variable] = ())
At the given time, adds the given increment to the action’s effects.
- Parameters:
timing – The exact time in which the increment is applied.
fluent – The fluent which value is incremented by the added effect.
value – The given fluent is incremented by the given value.
condition – The condition in which this effect is applied; the default value is True.
forall – The ‘Variables’ that are universally quantified in this effect; the default value is empty.
- add_parameter(name: str, tpe: Type) Parameter
Adds a new decision variable associated to this activity. The resulting parameter’s identifier will be prefixed with the activity’s name but may be used outside the activity itself. For instance, it could appear in global constraints or constraints involving more than one activity.
- clear_conditions()
Removes all conditions.
- clear_effects()
Removes all effects from the Action.
- property conditional_effects: Dict[Timing, List[Effect]]
Return the action conditional effects.
IMPORTANT NOTE: this property does some computation, so it should be called as seldom as possible.
- property conditions: Dict[TimeInterval, List[FNode]]
Returns the action conditions; a map from TimeInterval to a list of Expressions indicating that for this action to be applicable, during the whole TimeInterval set as key, all the expression in the mapped list must evaluate to True.
- property effects: Dict[Timing, List[Effect]]
Returns the all the action’s effects; a map from Timing to list of Effects indicating that, when the action is applied, all the Effects must be applied at the Timing set as key in the map.
- is_conditional() bool
Returns True if the action has conditional effects, False otherwise.
- property name: str
Returns the Chronicle name.