Probabilistic Computation Tree Logic (PCTL) Constraint¶
masa.common.constraints.pctl.PCTL ¶
Bases: Constraint
Simplified PCTL-named monitor tracking whether any unsafe step occurred.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cost_fn
|
CostFn
|
Mapping from label sets to scalar cost. |
required |
alpha
|
float
|
Threshold parameter stored for downstream use (not currently used in the logic in this file). |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
cost_fn |
Cost function |
|
alpha |
User-specified parameter (reserved for probabilistic variants). |
|
safe |
True until an unsafe cost is observed. |
|
step_cost |
Most recent cost value. |
|
total_unsafe |
Count of unsafe steps (as floats). |
Source code in masa/common/constraints/pctl.py
reset ¶
update ¶
Update safety flags from the current label set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Iterable[str]
|
Iterable of atomic propositions. |
required |
Source code in masa/common/constraints/pctl.py
satisfied ¶
episode_metric ¶
End-of-episode metrics.
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
Dict containing: |
Dict[str, float]
|
|
Dict[str, float]
|
|
Source code in masa/common/constraints/pctl.py
step_metric ¶
Per-step metrics.
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
Dict containing: |
Dict[str, float]
|
|
Dict[str, float]
|
|
Source code in masa/common/constraints/pctl.py
masa.common.constraints.pctl.PCTLEnv ¶
Bases: BaseConstraintEnv
Gymnasium wrapper for the PCTL monitor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
Env
|
Base environment (must be a |
required |
cost_fn
|
CostFn
|
Cost function mapping labels to a scalar. |
cost_fn
|
alpha
|
float
|
Threshold parameter stored on the monitor (see |
0.01
|
**kw
|
Extra keyword arguments forwarded to |
{}
|