ExpressionManager
- class unified_planning.model.ExpressionManager(environment: Environment)[source]
Bases:
objectExpressionManager is responsible for the creation of all expressions.
- auto_promote(*args: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object | Iterable[Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | 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 | Presence | 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 | Presence | bool | Iterable[FNode | Fluent | Parameter | Variable | Presence | 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
Iterableofbooleanexpressions, like[a, b, c], or an unpacked version of it, likea, b, c.- Returns:
The
ANDexpression created.
- Or(*args: FNode | Fluent | Parameter | Variable | Presence | bool | Iterable[FNode | Fluent | Parameter | Variable | Presence | 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
Iterableofboolean expressions, like[a, b, c], or an unpacked version of it, likea, b, c.- Returns:
The
ORexpression created.
- XOr(*args: FNode | Fluent | Parameter | Variable | Presence | bool | Iterable[FNode | Fluent | Parameter | Variable | Presence | 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
Iterableofboolean 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 | Presence | bool) FNode[source]
- Creates an expression of the form:
not expression
Restriction:
expressionmust be ofboolean type- Parameters:
expression – The
booleanexpression of which the negation must be created.- Returns:
The created
Notexpression.
- Implies(left: FNode | Fluent | Parameter | Variable | Presence | bool, right: FNode | Fluent | Parameter | Variable | Presence | bool) FNode[source]
- Creates an expression of the form:
left -> right
Restriction:
LeftandRightmust be ofboolean type- Parameters:
left – The
booleanexpression acting as the premise of theImplies.right – The
booleanexpression acting as the implied part of theImplies.
- Returns:
The created
Implication.
- Iff(left: FNode | Fluent | Parameter | Variable | Presence | bool, right: FNode | Fluent | Parameter | Variable | Presence | bool) FNode[source]
- Creates an expression of the form:
left <-> right
Semantically, The expression is
Trueonly ifleftandrighthave the same value. Restriction:LeftandRightmust be ofboolean type- Parameters:
left – The
leftmember of theIff expression.right – The
rightmember of theIff expression.
- Returns:
The created
Iffexpression.
- Exists(expression: FNode | Fluent | Parameter | Variable | Presence | bool, *vars: Variable) FNode[source]
- Creates an expression of the form:
Exists (var[0]... var[n]) | expression
Restriction: expression must be of
boolean typeand vars must be ofVariabletype- Parameters:
expression – The main expression of the
existential. The expression should contain the givenvariables.*vars – All the
Variablesappearing in theexistentialexpression.
- Returns:
The created
Existentialexpression.
- Forall(expression: FNode | Fluent | Parameter | Variable | Presence | bool, *vars: Variable) FNode[source]
- Creates an expression of the form:
Forall (var[0]... var[n]) | expression
Restriction: expression must be of
boolean typeand vars must be ofVariabletype- Parameters:
expression – The main expression of the
universalquantifier. The expression should contain the givenvariables.*vars – All the
Variablesappearing in theuniversalexpression.
- Returns:
The created
Forallexpression.
- Always(expression: FNode | Fluent | Parameter | Variable | Presence | bool) FNode[source]
- Creates an expression of the form:
Always(a)
Restriction: expression must be of
boolean typeand with only one arg.- Parameters:
expression – The
booleanexpression of the trajectory constraints.- Returns:
The created
Alwaysexpression.
- Sometime(expression: FNode | Fluent | Parameter | Variable | Presence | bool) FNode[source]
- Creates an expression of the form:
Sometime(a)
Restriction: expression must be of
boolean typeand with only one arg.- Parameters:
expression – The
booleanexpression of the trajectory constraints.- Returns:
The created
Sometimeexpression.
- AtMostOnce(expression: FNode | Fluent | Parameter | Variable | Presence | bool) FNode[source]
- Creates an expression of the form:
At-Most-Once(a, b)
Restriction: expression must be of
boolean typeand with only two arg.- Parameters:
expression – The
booleanexpression of the trajectory constraints.- Returns:
The created
At-Most-Once(a, b)expression.
- SometimeBefore(phi: FNode | Fluent | Parameter | Variable | Presence | bool, psi: FNode | Fluent | Parameter | Variable | Presence | bool) FNode[source]
- Creates an expression of the form:
Sometime-Before(a, b)
Restriction: expression must be of
boolean typeand with only one args- Parameters:
expression – The
booleanexpression of the trajectory constraints.- Returns:
The created
Sometimeexpression.
- SometimeAfter(phi: FNode | Fluent | Parameter | Variable | Presence | bool, psi: FNode | Fluent | Parameter | Variable | Presence | bool) FNode[source]
- Creates an expression of the form:
Sometime-After(a, b)
Restriction: expression must be of
boolean typeand with only two arg.- Parameters:
expression – The
booleanexpression 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 | Presence | bool | str | Object] = ()) FNode[source]
- Creates an expression for the given
fluentandparameters.Restriction:parameters typemust be compatible with theFluent:func:signature <unified_planning.model.Fluent.signature>- Parameters:
fluent – The
Fluentthat will be set as thepayloadof this expression.params – The Sequence of expressions acting as
parametersfor thisFluent; mainly the parameters will be :class:Objects <unified_planning.model.Object>(when theFluentExpis grounded) or :func:Action parameters <unified_planning.model.Action.parameters>(when theFluentExpis lifted).
- Returns:
The created
FluentExpression.
- Dot(agent: Agent | str, fluent_exp: FNode | Fluent) FNode[source]
Creates an expression for the given
agentandfluent_exp. Restriction: agent must be ofagent typeor the name of an agent and fluent_exp must be offluentExp type- Parameters:
agent – The
Agentthat will be set as thepayloadof this expression.fluent_exp – The
Fluent_expthat will be set as theargsof this expression.
- Returns:
The created
DotExpression.
- ParameterExp(param: Parameter) FNode[source]
Returns an expression for the given
Action parameter.- Parameters:
param – The
Parameterthat must be promoted toFNode.- Returns:
The
FNodecontaining the givenparamas his payload.
- VariableExp(var: Variable) FNode[source]
Returns an expression for the given
Variable.- Parameters:
var – The
Variablethat must be promoted toFNode.- Returns:
The
FNodecontaining the givenvariableas his payload.
- ObjectExp(obj: Object) FNode[source]
Returns an expression for the given object.
- Parameters:
obj – The
Objectthat must be promoted toFNode.- Returns:
The
FNodecontaining the given object as his payload.
- TimingExp(timing: Timing) FNode[source]
Returns an expression for the given
Timing.- Parameters:
timing – The
Timingthat must be promoted toFNode.- Returns:
The
FNodecontaining the giventimingas his payload.
- Bool(value: bool) FNode[source]
Return a boolean constant.
- Parameters:
value – The boolean value that must be promoted to
FNode.- Returns:
The
FNodecontaining the givenvalueas his payload.
- Int(value: int) FNode[source]
Return an
intconstant.- Parameters:
value – The integer that must be promoted to
FNode.- Returns:
The
FNodecontaining the givenintegeras his payload.
- Real(value: Fraction) FNode[source]
Return a
realconstant.- Parameters:
value – The
Fractionthat must be promoted toFNode.- Returns:
The
FNodecontaining the givenvalueas his payload.
- Plus(*args: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object | Iterable[Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object]) FNode[source]
- Creates an expression of the form:
args[0] + ... + args[n]
- Parameters:
*args – Either an
Iterableof expressions, like[a, b, 3], or an unpacked version of it, likea, b, 3.- Returns:
The
PLUSexpression created. (likea + b + 3)
- Minus(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | 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
Minusexpression.
- Times(*args: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object | Iterable[Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object]) FNode[source]
- Creates an expression of the form:
args[0] * ... * args[n]
- Parameters:
*args – Either an
Iterableof expressions, like[a, b, 3], or an unpacked version of it, likea, b, 3.- Returns:
The
TIMESexpression created. (likea * b * 3)
- Div(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | 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
DIVexpression.
- LE(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | 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
LEexpression.
- GE(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | 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
GEexpression.
- LT(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | 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
LTexpression.
- GT(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | 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
GTexpression.
- Equals(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | 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
Equalsexpression.
- EqualsOrIff(left: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object, right: Timing | Timepoint | int | float | Fraction | FNode | Fluent | Parameter | Variable | Presence | bool | str | Object) FNode[source]
Creates an expression of either one of the following forms:
left <-> rightleft == right:param left: Theleftmember of theEqualsOrIff expression. :param right: Therightmember of theEqualsOrIff expression. :return: The createdEqualsorIffexpression.