concepts.dm.pdsketch.strips.strips_grounded_expression.GSBoolConstantExpression#

class GSBoolConstantExpression[source]#

Bases: GSBoolOutputExpression

A constant Boolean expression.

Methods

compile()

Compile the expression into a function that takes a state as input.

enable_forward_diff_ctx()

A context manager that enables the forward difference flag.

filter_propositions(propositions[, state])

Filter the propositions in this expression.

forward(state)

Compute the expression on the given state.

iter_propositions()

Iterate over all propositions that are used in this expression.

set_forward_diff([value])

Set the forward difference flag.

Attributes

FORWARD_DIFF

A static variable that indicates whether we want to enable forward difference for expressions.

constant

The constant value.

__init__(constant)[source]#

Initialize the constant expression.

Parameters:

constant (bool) – the constant value.

__new__(**kwargs)#
compile()[source]#

Compile the expression into a function that takes a state as input.

Return type:

Callable[[SState], bool | GSBoolForwardDiffReturn]

static enable_forward_diff_ctx()#

A context manager that enables the forward difference flag. Example:

state = SState({'a', 'b'})
expr = GSSimpleBoolExpression({'a', 'b'})
compiled_function = expr.compile()
with GSBoolExpression.enable_forward_diff_ctx():
    rv = compiled_function(state)
    assert isinstance(rv, GSBoolForwardDiffReturn)
    assert rv.rv is True
    assert rv.propositions == {'a', 'b'}
filter_propositions(propositions, state=None)[source]#

Filter the propositions in this expression. Since this is a constant expression, the result will always be the same expression.

Parameters:
  • propositions (Set[str]) – the propositions that should be kept.

  • state (SState | None) – the initial state, default to None.

Returns:

the Boolean expression after filtering.

Return type:

GSBoolConstantExpression

forward(state)#

Compute the expression on the given state.

Parameters:

state (SState) – the state to compute the expression on.

Returns:

the return value of the expression.

Return type:

bool | GSBoolForwardDiffReturn

iter_propositions()[source]#

Iterate over all propositions that are used in this expression.

Return type:

Iterable[str]

static set_forward_diff(value=True)#

Set the forward difference flag. If the forward difference flag is set to True, the compiled function will return a tuple of (bool, Set[SProposition]) instead of a bool.

Parameters:

value (bool) – the value to set, default to True.

FORWARD_DIFF = False#

A static variable that indicates whether we want to enable forward difference for expressions.

constant: bool#

The constant value.