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.
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.
Iterate over all propositions that are used in this expression.
set_forward_diff
([value])Set the forward difference flag.
Attributes
A static variable that indicates whether we want to enable forward difference for expressions.
The constant value.
- __init__(constant)[source]#
Initialize the constant expression.
- Parameters:
constant (bool) – the constant value.
- __new__(**kwargs)#
- 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:
- Returns:
the Boolean expression after filtering.
- Return type:
- 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:
- 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.