declearn.main.utils.TimeoutConstraint
Bases: Constraint
Class implementing a simple time-based constraint.
Usage
- When instantiated, a TimeoutConstraint records a reference
time (that at instantiation, optionally adjusted based on
the
start
parameter) under theself.start
attribute. - On each
self.increment()
call, theself.value
attribute is updated to the difference between the current time and theself.start
attribute. - The constraint is
saturated
whenself.value > self.limit
.
Source code in declearn/main/utils/_constraints.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
__init__(limit, start=0.0, name='timeout')
Instantiate a time-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 duration to substract from the current time to set up the reference starting time. |
0.0
|
name |
str
|
Name of the constraint. |
'timeout'
|
Source code in declearn/main/utils/_constraints.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
increment()
Update self.value
, storing time passed since self.start
.
Source code in declearn/main/utils/_constraints.py
118 119 120 121 122 |
|