MAEnvironment

class unified_planning.model.multi_agent.MAEnvironment(ma_problem: MultiAgentProblem)[source]

Bases: FluentsSetMixin

This is an MAEnvironment class that represents a generic MAEnvironment.

property environment: Environment

Returns this MAEnvironment Environment.

has_name(name: str) bool[source]

Returns True if the given name is already in the MultiAgentProblem, False otherwise.

Parameters:

name – The target name to find in the MultiAgentProblem.

Returns:

True if the given name is already in the MultiAgentProblem, False otherwise.

add_fluent(fluent_or_name: Fluent | str, typename: Type | None = None, *, default_initial_value: int | float | Fraction | str | FNode | Object | bool | None = None, **kwargs: Type) Fluent

Adds the given fluent to the problem.

If the first parameter is not a Fluent, the parameters will be passed to the Fluent constructor to create it.

Parameters:
  • fluent_or_nameFluent instance or name of the fluent to be constructed.

  • typename – If only the name of the fluent is given, this is the fluent’s type (passed to the Fluent constructor).

  • default_initial_value – If provided, defines the default value taken in initial state by a state variable of this fluent that has no explicit value.

  • kwargs – If only the name of the fluent is given, these are the fluent’s parameters (passed to the Fluent constructor).

Returns:

The fluent passed or constructed.

Example

>>> from unified_planning.shortcuts import *
>>> problem = Problem()
>>> location = UserType("Location")
>>> at_loc = Fluent("at_loc", BoolType(), l=location)  # creates a new fluent
>>> problem.add_fluent(at_loc)  # adds it to the problem
bool at_loc[l=Location]
>>> problem.add_fluent("connected", BoolType(), l1=location, l2=location)  # creates a new fluent and add it to the problem.
bool connected[l1=Location, l2=Location]
>>>
add_fluents(fluents: Iterable[Fluent])

Adds the given fluents to the problem.

Parameters:

fluents – The fluents that must be added to the problem.

clear_fluents()

Removes all the Fluent from the current Problem, together with their default.

fluent(name: str) Fluent

Returns the fluent with the given name.

Parameters:

name – The name of the target fluent:

Returns:

The fluent with the given name.

property fluents: List[Fluent]

Returns the fluents currently in the problem.

property fluents_defaults: Dict[Fluent, FNode]

Returns the problem’s fluents defaults.

get_static_fluents() Set[Fluent]

Returns the set of the static fluents.

Static fluents are those who can’t change their values because they never appear in the fluent field of an Effect, therefore there are no Actions in the Problem that can change their value.

get_unused_fluents() Set[Fluent]

Returns the set of fluents that are never used in the problem.

has_fluent(name: str) bool

Returns True if the fluent with the given name is in the problem, False otherwise.

Parameters:

name – The name of the target fluent.

Returns:

True if the fluent with the given name is in the problem, False otherwise.

property initial_defaults: Dict[Type, FNode]

Returns the problem’s fluents defaults for each type.