declearn.main.utils.Constraint
Base class to implement effort constraints.
This class defines a generic API and implements count-based constraints.
Usage
- When instantiated, a base Constraint records a
self.value
counter, initialized based on thestart
parameter. - On each
self.increment()
call, theself.value
attribute is incremented by 1. - The constraint is
saturated
whenself.value > self.limit
.
Source code in declearn/main/utils/_constraints.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
saturated: bool
property
Return whether the constraint is saturated.
__init__(limit, start=0.0, name='constraint')
Instantiate a count-based constraint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit |
Optional[float]
|
Value beyond which the constraint is saturated. If None, set to Inf, making this a counter. |
required |
start |
float
|
Start value of the counter.
This value goes up by 1 on each |
0.0
|
name |
str
|
Name of the constraint. |
'constraint'
|
Source code in declearn/main/utils/_constraints.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
increment()
Update self.value
, incrementing it by 1.
Source code in declearn/main/utils/_constraints.py
68 69 70 71 72 |
|