ExpressionManager
- class unified_planning.model.ExpressionManager(environment: Environment)[source]
Bases:
object
ExpressionManager is responsible for the creation of all expressions.
- auto_promote(*args: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object | Iterable[Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object]) List[FNode] [source]
Method that takes an iterable of expressions and returns the list of these expressions casted to FNode.
- Parameters:
args – The iterable of expression that must be promoted to FNode.
- Returns:
The resulting list of FNode.
- create_node(node_type: OperatorKind, args: Tuple[FNode, ...], payload: Fluent | Object | Parameter | Variable | Timing | str | bool | int | Fraction | Tuple[Variable, ...] | None = None) FNode [source]
Creates the unified_planning expressions if it hasn’t been created yet in the environment. Otherwise returns the existing one.
- Parameters:
node_type – The OperationKind referring to this expression (like a PLUS, MINUS, FLUENT_EXP, etc.).
args – The direct sons in this expression tree; a tuple of expressions.
payload – In some OperationKind contains the information about the expression; for an INT_EXP contains the integer, for a FLUENT_EXP the fluent etc.
- Returns:
The created expression.
- And(*args: FNode | Fluent | Parameter | Variable | bool | Iterable[FNode | Fluent | Parameter | Variable | bool]) FNode [source]
- Returns a conjunction of terms.This function has polymorphic n-arguments:
And(a,b,c)
And([a,b,c])
Restriction: Arguments must beboolean
.- Parameters:
*args – Either an
Iterable
ofboolean
expressions, like[a, b, c]
, or an unpacked version of it, likea, b, c
.- Returns:
The
AND
expression created.
- Or(*args: FNode | Fluent | Parameter | Variable | bool | Iterable[FNode | Fluent | Parameter | Variable | bool]) FNode [source]
- Returns an disjunction of terms.This function has polymorphic n-arguments:
Or(a,b,c)
Or([a,b,c])
Restriction: Arguments must beboolean
- Parameters:
*args – Either an
Iterable
ofboolean expressions
, like[a, b, c]
, or an unpacked version of it, likea, b, c
.- Returns:
The
OR
expression created.
- XOr(*args: FNode | Fluent | Parameter | Variable | bool | Iterable[FNode | Fluent | Parameter | Variable | bool]) FNode [source]
- Returns an exclusive disjunction of terms in CNF form.This function has polimorphic n-arguments:
XOr(a,b,c)
XOr([a,b,c])
Restriction: Arguments must be boolean- Parameters:
*args – Either an
Iterable
ofboolean expressions
, like[a, b, c]
, or an unpacked version of it, likea, b, c
.- Returns:
The exclusive disjunction in CNF form.
- Not(expression: FNode | Fluent | Parameter | Variable | bool) FNode [source]
- Creates an expression of the form:
not expression
Restriction:
expression
must be ofboolean type
- Parameters:
expression – The
boolean
expression of which the negation must be created.- Returns:
The created
Not
expression.
- Implies(left: FNode | Fluent | Parameter | Variable | bool, right: FNode | Fluent | Parameter | Variable | bool) FNode [source]
- Creates an expression of the form:
left -> right
Restriction:
Left
andRight
must be ofboolean type
- Parameters:
left – The
boolean
expression acting as the premise of theImplies
.right – The
boolean
expression acting as the implied part of theImplies
.
- Returns:
The created
Implication
.
- Iff(left: FNode | Fluent | Parameter | Variable | bool, right: FNode | Fluent | Parameter | Variable | bool) FNode [source]
- Creates an expression of the form:
left <-> right
Semantically, The expression is
True
only ifleft
andright
have the same value. Restriction:Left
andRight
must be ofboolean type
- Parameters:
left – The
left
member of theIff expression
.right – The
right
member of theIff expression
.
- Returns:
The created
Iff
expression.
- Exists(expression: FNode | Fluent | Parameter | Variable | bool, *vars: Variable) FNode [source]
- Creates an expression of the form:
Exists (var[0]... var[n]) | expression
Restriction: expression must be of
boolean type
and vars must be ofVariable
type- Parameters:
expression – The main expression of the
existential
. The expression should contain the givenvariables
.*vars – All the
Variables
appearing in theexistential
expression.
- Returns:
The created
Existential
expression.
- Forall(expression: FNode | Fluent | Parameter | Variable | bool, *vars: Variable) FNode [source]
- Creates an expression of the form:
Forall (var[0]... var[n]) | expression
Restriction: expression must be of
boolean type
and vars must be ofVariable
type- Parameters:
expression – The main expression of the
universal
quantifier. The expression should contain the givenvariables
.*vars – All the
Variables
appearing in theuniversal
expression.
- Returns:
The created
Forall
expression.
- Always(expression: FNode | Fluent | Parameter | Variable | bool) FNode [source]
- Creates an expression of the form:
Always(a)
Restriction: expression must be of
boolean type
and with only one arg.- Parameters:
expression – The
boolean
expression of the trajectory constraints.- Returns:
The created
Always
expression.
- Sometime(expression: FNode | Fluent | Parameter | Variable | bool) FNode [source]
- Creates an expression of the form:
Sometime(a)
Restriction: expression must be of
boolean type
and with only one arg.- Parameters:
expression – The
boolean
expression of the trajectory constraints.- Returns:
The created
Sometime
expression.
- AtMostOnce(expression: FNode | Fluent | Parameter | Variable | bool) FNode [source]
- Creates an expression of the form:
At-Most-Once(a, b)
Restriction: expression must be of
boolean type
and with only two arg.- Parameters:
expression – The
boolean
expression of the trajectory constraints.- Returns:
The created
At-Most-Once(a, b)
expression.
- SometimeBefore(phi: FNode | Fluent | Parameter | Variable | bool, psi: FNode | Fluent | Parameter | Variable | bool) FNode [source]
- Creates an expression of the form:
Sometime-Before(a, b)
Restriction: expression must be of
boolean type
and with only one args- Parameters:
expression – The
boolean
expression of the trajectory constraints.- Returns:
The created
Sometime
expression.
- SometimeAfter(phi: FNode | Fluent | Parameter | Variable | bool, psi: FNode | Fluent | Parameter | Variable | bool) FNode [source]
- Creates an expression of the form:
Sometime-After(a, b)
Restriction: expression must be of
boolean type
and with only two arg.- Parameters:
expression – The
boolean
expression of the trajectory constraints.- Returns:
The created
Sometime-After(a, b)
expression.
- FluentExp(fluent: Fluent, params: Sequence[Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object] = ()) FNode [source]
- Creates an expression for the given
fluent
andparameters
.Restriction:parameters type
must be compatible with theFluent
:func:signature <unified_planning.model.Fluent.signature>
- Parameters:
fluent – The
Fluent
that will be set as thepayload
of this expression.params – The Sequence of expressions acting as
parameters
for thisFluent
; mainly the parameters will be :class:Objects <unified_planning.model.Object>
(when theFluentExp
is grounded) or :func:Action parameters <unified_planning.model.Action.parameters>
(when theFluentExp
is lifted).
- Returns:
The created
Fluent
Expression.
- Dot(agent: Agent | str, fluent_exp: FNode | Fluent) FNode [source]
Creates an expression for the given
agent
andfluent_exp
. Restriction: agent must be ofagent type
or the name of an agent and fluent_exp must be offluentExp type
- Parameters:
agent – The
Agent
that will be set as thepayload
of this expression.fluent_exp – The
Fluent_exp
that will be set as theargs
of this expression.
- Returns:
The created
Dot
Expression.
- ParameterExp(param: Parameter) FNode [source]
Returns an expression for the given
Action parameter
.- Parameters:
param – The
Parameter
that must be promoted toFNode
.- Returns:
The
FNode
containing the givenparam
as his payload.
- VariableExp(var: Variable) FNode [source]
Returns an expression for the given
Variable
.- Parameters:
var – The
Variable
that must be promoted toFNode
.- Returns:
The
FNode
containing the givenvariable
as his payload.
- ObjectExp(obj: Object) FNode [source]
Returns an expression for the given object.
- Parameters:
obj – The
Object
that must be promoted toFNode
.- Returns:
The
FNode
containing the given object as his payload.
- TimingExp(timing: Timing) FNode [source]
Returns an expression for the given
Timing
.- Parameters:
timing – The
Timing
that must be promoted toFNode
.- Returns:
The
FNode
containing the giventiming
as his payload.
- Bool(value: bool) FNode [source]
Return a boolean constant.
- Parameters:
value – The boolean value that must be promoted to
FNode
.- Returns:
The
FNode
containing the givenvalue
as his payload.
- Int(value: int) FNode [source]
Return an
int
constant.- Parameters:
value – The integer that must be promoted to
FNode
.- Returns:
The
FNode
containing the giveninteger
as his payload.
- Real(value: Fraction) FNode [source]
Return a
real
constant.- Parameters:
value – The
Fraction
that must be promoted toFNode
.- Returns:
The
FNode
containing the givenvalue
as his payload.
- Plus(*args: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object | Iterable[Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object]) FNode [source]
- Creates an expression of the form:
args[0] + ... + args[n]
- Parameters:
*args – Either an
Iterable
of expressions, like[a, b, 3]
, or an unpacked version of it, likea, b, 3
.- Returns:
The
PLUS
expression created. (likea + b + 3
)
- Minus(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object) FNode [source]
Creates an expression of the form:
left - right
.- Parameters:
left – The
Minus minuend
.right – The
Minus subtrahend
.
- Returns:
The created
Minus
expression.
- Times(*args: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object | Iterable[Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object]) FNode [source]
- Creates an expression of the form:
args[0] * ... * args[n]
- Parameters:
*args – Either an
Iterable
of expressions, like[a, b, 3]
, or an unpacked version of it, likea, b, 3
.- Returns:
The
TIMES
expression created. (likea * b * 3
)
- Div(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object) FNode [source]
- Creates an expression of the form:
left / right
- Parameters:
left – The
Div dividend
.right – The
Div divisor
.
- Returns:
The created
DIV
expression.
- LE(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object) FNode [source]
- Creates an expression of the form:
left <= right
.
- Parameters:
left – The left side of the
<=
.right – The right side of the
<=
.
- Returns:
The created
LE
expression.
- GE(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object) FNode [source]
- Creates an expression of the form:
left >= right
.
- Parameters:
left – The left side of the
>=
.right – The right side of the
>=
.
- Returns:
The created
GE
expression.
- LT(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object) FNode [source]
- Creates an expression of the form:
left < right
.
- Parameters:
left – The left side of the
<
.right – The right side of the
<
.
- Returns:
The created
LT
expression.
- GT(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object) FNode [source]
- Creates an expression of the form:
left > right
.
- Parameters:
left – The left side of the
>
.right – The right side of the
>
.
- Returns:
The created
GT
expression.
- Equals(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | bool | str | Object) FNode [source]
- Creates an expression of the form:
left == right
.
NOTE: Is not valid for boolean expression, for those use
Iff
.- Parameters:
left – The left side of the
==
.right – The right side of the
==
.
- Returns:
The created
Equals
expression.