DurativeAction

class unified_planning.model.DurativeAction(_name: str, _parameters: OrderedDict[str, Type] | None = None, _env: Environment | None = None, **kwargs: Type)[source]

Bases: Action, TimedCondsEffs

Represents a durative action.

clone()[source]
property duration: DurationInterval

Returns the action duration interval.

set_duration_constraint(duration: DurationInterval)[source]

Sets the duration interval for this action.

Parameters:

duration – The new duration interval of this action.

set_fixed_duration(value: int | float | Fraction | str | FNode)[source]

Sets the duration interval for this action as the interval [value, value].

Parameters:

value – The value set as both edges of this action’s duration.

set_closed_duration_interval(lower: int | float | Fraction | str | FNode, upper: int | float | Fraction | str | FNode)[source]

Sets the duration interval for this action 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.

set_open_duration_interval(lower: int | float | Fraction | str | FNode, upper: int | float | Fraction | str | FNode)[source]

Sets the duration interval for this action 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.

Note that lower and upper are not part of the interval.

set_left_open_duration_interval(lower: int | float | Fraction | str | FNode, upper: int | float | Fraction | str | FNode)[source]

Sets the duration interval for this action 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.

Note that lower is not part of the interval.

set_right_open_duration_interval(lower: int | float | Fraction | str | FNode, upper: int | float | Fraction | str | FNode)[source]

Sets the duration interval for this action 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.

Note that upper is not part of the interval.

is_conditional() bool[source]

Returns True if the action has conditional effects, False otherwise.

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_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.

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.

property environment: Environment

Returns this Action Environment.

property name: str

Returns the Action name.

parameter(name: str) Parameter

Returns the parameter of the Action with the given name.

Example

>>> from unified_planning.shortcuts import *
>>> location_type = UserType("Location")
>>> move = InstantaneousAction("move", source=location_type, target=location_type)
>>> move.parameter("source")  # return the "source" parameter of the action, with type "Location"
Location source
>>> move.parameter("target")
Location target

If a parameter’s name (1) does not conflict with an existing attribute of Action and (2) does not start with ‘_’ it can also be accessed as if it was an attribute of the action. For instance:

>>> move.source
Location source
Parameters:

name – The name of the target parameter.

Returns:

The parameter of the Action with the given name.

property parameters: List[Parameter]

Returns the list of the Action parameters.

set_simulated_effect(timing: Timing, simulated_effect: SimulatedEffect)

Sets the given simulated effect at the specified timing.

Parameters:
  • timing – The time in which the simulated effect must be applied.

  • simulated_effect – The simulated effect that must be applied at the given timing.

property simulated_effects: Dict[Timing, SimulatedEffect]

Returns the action simulated effects.

property unconditional_effects: Dict[Timing, List[Effect]]

Return the action unconditional effects.

IMPORTANT NOTE: this property does some computation, so it should be called as seldom as possible.