Stopping Conditions¶
Stopping conditions for Xopt optimization.
This module contains classes that implement various stopping criteria for optimization processes. Each stopping condition class takes an Xopt dataframe and VOCS object to determine whether optimization should stop.
CompositeCondition
¶
Bases: StoppingCondition
Combine multiple stopping conditions with AND/OR logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conditions
|
List[StoppingCondition]
|
List of stopping conditions to combine. |
required |
logic
|
str
|
Logic to combine conditions: "and" or "or" (default: "or"). |
required |
Source code in xopt/stopping_conditions.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
should_stop(data, vocs)
¶
Combine conditions using specified logic.
Source code in xopt/stopping_conditions.py
336 337 338 339 340 341 342 343 344 345 346 347 348 | |
yaml(**kwargs)
¶
serialize first then dump to yaml string
Source code in xopt/pydantic.py
231 232 233 234 235 236 237 238 | |
ConvergenceCondition
¶
Bases: StoppingCondition
Stop when optimization converges (improvement is below threshold).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objective_name
|
str
|
Name of the objective to monitor for convergence. |
required |
improvement_threshold
|
float
|
Minimum improvement required to continue optimization. |
required |
patience
|
int
|
Number of evaluations to wait without improvement before stopping. |
required |
relative
|
bool
|
Whether to use relative improvement (default: False). |
required |
Source code in xopt/stopping_conditions.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
should_stop(data, vocs)
¶
Stop if no improvement for specified patience.
Source code in xopt/stopping_conditions.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
yaml(**kwargs)
¶
serialize first then dump to yaml string
Source code in xopt/pydantic.py
231 232 233 234 235 236 237 238 | |
FeasibilityCondition
¶
Bases: StoppingCondition
Stop when a feasible solution is found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
require_all_constraints
|
bool
|
Whether all constraints must be satisfied (default: True). |
required |
Source code in xopt/stopping_conditions.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
should_stop(data, vocs)
¶
Stop when a feasible solution is found.
Source code in xopt/stopping_conditions.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
yaml(**kwargs)
¶
serialize first then dump to yaml string
Source code in xopt/pydantic.py
231 232 233 234 235 236 237 238 | |
MaxEvaluationsCondition
¶
Bases: StoppingCondition
Stop after a maximum number of evaluations. Evaluations can be counted in different ways based on parameters. If count_valid_only is True, only evaluations without errors are counted. If use_dataframe_index is True, the dataframe index is used to count evaluations instead of the number of rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_evaluations
|
int
|
Maximum number of function evaluations before stopping. |
required |
count_valid_only
|
bool
|
Whether to count only valid evaluations (default: False). |
required |
use_dataframe_index
|
bool
|
Whether to use the dataframe index to count evaluations (default: False). |
required |
Source code in xopt/stopping_conditions.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
should_stop(data, vocs)
¶
Stop if we've reached the maximum number of evaluations.
Source code in xopt/stopping_conditions.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
yaml(**kwargs)
¶
serialize first then dump to yaml string
Source code in xopt/pydantic.py
231 232 233 234 235 236 237 238 | |
StagnationCondition
¶
Bases: StoppingCondition
Stop when the best objective value hasn't improved for a number of evaluations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objective_name
|
str
|
Name of the objective to monitor. |
required |
patience
|
int
|
Number of evaluations without improvement before stopping. |
required |
tolerance
|
float
|
Minimum improvement considered significant (default: 1e-8). |
required |
Source code in xopt/stopping_conditions.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
should_stop(data, vocs)
¶
Stop if no improvement in best value for specified patience.
Source code in xopt/stopping_conditions.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
yaml(**kwargs)
¶
serialize first then dump to yaml string
Source code in xopt/pydantic.py
231 232 233 234 235 236 237 238 | |
StoppingCondition
¶
Bases: XoptBaseModel, ABC
Abstract base class for stopping conditions.
All stopping conditions must implement the should_stop method which takes an Xopt dataframe and VOCS object and returns True if optimization should stop.
Source code in xopt/stopping_conditions.py
29 30 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 | |
should_stop(data, vocs)
abstractmethod
¶
Determine if optimization should stop based on data and VOCS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
The Xopt optimization data containing variables, objectives, constraints, etc. |
required |
vocs
|
VOCS
|
The VOCS object defining variables, objectives, and constraints. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if optimization should stop, False otherwise. |
Source code in xopt/stopping_conditions.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
yaml(**kwargs)
¶
serialize first then dump to yaml string
Source code in xopt/pydantic.py
231 232 233 234 235 236 237 238 | |
TargetValueCondition
¶
Bases: StoppingCondition
Stop when an objective reaches a target value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objective_name
|
str
|
Name of the objective to monitor. |
required |
target_value
|
float
|
Target value for the objective. |
required |
tolerance
|
float
|
Tolerance for reaching the target (default: 1e-6). |
required |
Source code in xopt/stopping_conditions.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
should_stop(data, vocs)
¶
Stop if objective reaches target value within tolerance.
Source code in xopt/stopping_conditions.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
yaml(**kwargs)
¶
serialize first then dump to yaml string
Source code in xopt/pydantic.py
231 232 233 234 235 236 237 238 | |