Reach-avoid Constraint¶
masa.common.constraints.reach_avoid.ReachAvoid ¶
Bases: Constraint
Reach target label set while avoiding unsafe label set.
At each step, given a label set labels:
- reaching condition:
reach = (reach_label in labels) - avoiding condition:
avoid_ok = (avoid_label not in labels)
State updates:
reachedbecomes true once reach is observed,violatedbecomes true once avoid is violated,satisfiedbecomes true once reached is true and violated is false.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
avoid_label
|
str
|
Atomic proposition name indicating unsafe/avoid condition. |
required |
reach_label
|
str
|
Atomic proposition name indicating the target condition. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
avoid_label |
Name of unsafe label. |
|
reach_label |
Name of target label. |
|
reached |
Whether target has been reached at least once. |
|
violated |
Whether unsafe has been observed at least once. |
|
satisfied |
Whether reach-avoid has been satisfied so far. |
Source code in masa/common/constraints/reach_avoid.py
reset ¶
update ¶
Update reach/avoid flags from the current label set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Iterable[str]
|
Iterable of atomic propositions for the current step. |
required |
Source code in masa/common/constraints/reach_avoid.py
episode_metric ¶
End-of-episode metrics.
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
Dict containing: |
Dict[str, float]
|
|
Dict[str, float]
|
|
Dict[str, float]
|
|
Source code in masa/common/constraints/reach_avoid.py
step_metric ¶
Per-step metrics.
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
Dict containing: |
Dict[str, float]
|
|
Dict[str, float]
|
|
Dict[str, float]
|
|
Source code in masa/common/constraints/reach_avoid.py
masa.common.constraints.reach_avoid.ReachAvoidEnv ¶
Bases: BaseConstraintEnv
Gymnasium wrapper for the ReachAvoid monitor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
Env
|
Base environment (must be a |
required |
avoid_label
|
str
|
Atomic proposition name for unsafe/avoid condition. |
'unsafe'
|
reach_label
|
str
|
Atomic proposition name for target condition. |
'target'
|
**kw
|
Extra keyword arguments forwarded to |
{}
|