InstantaneousAction

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

Bases: Action

Represents an instantaneous action.

clone()[source]
property preconditions: List[FNode]

Returns the list of the Action preconditions.

clear_preconditions()[source]

Removes all the Action preconditions

property effects: List[Effect]

Returns the list of the Action effects.

clear_effects()[source]

Removes all the Action’s effects.

property conditional_effects: List[Effect]

Returns the list of the action conditional effects.

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

is_conditional() bool[source]

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

property unconditional_effects: List[Effect]

Returns the list of the action unconditional effects.

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

add_precondition(precondition: FNode | Fluent | Parameter | bool)[source]

Adds the given expression to action’s preconditions.

Parameters:

precondition – The expression that must be added to the action’s preconditions.

add_effect(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] = ())[source]

Adds the given assignment to the action’s effects.

Parameters:
  • fluent – The fluent of 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(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] = ())[source]

Adds the given increase effect to the action’s effects.

Parameters:
  • fluent – The fluent which value is increased.

  • 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_decrease_effect(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] = ())[source]

Adds the given decrease effect to the action’s effects.

Parameters:
  • fluent – The fluent which value is decreased.

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

property simulated_effect: SimulatedEffect | None

Returns the action simulated effect.

set_simulated_effect(simulated_effect: SimulatedEffect)[source]

Sets the given simulated effect as the only action’s simulated effect.

Parameters:

simulated_effect – The SimulatedEffect instance that must be set as this action’s only simulated effect.

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.