Commit 8ff8cf2
Refactor Objective and OutcomeConstraint to expression-based
Summary:
Refactors the Objective class to hold an expression string instead of Metric objects. This is Step 1 of decoupling Objective from Metric, enabling objectives to be defined purely by string expressions like "accuracy", "-loss", "2*acc + recall", or "acc, -loss" (multi-objective).
Key changes:
- Objective.__init__ now takes an `expression: str` as its primary argument, eagerly parsed via SymPy into cached metric names, weights, and objective type flags.
- The deprecated `metric`/`minimize` kwargs are preserved for backward compatibility and emit DeprecationWarning.
- New properties: `expression`, `metric_weights`, `metric_weights_by_objective`, `is_single_objective`, `is_scalarized_objective`, `is_multi_objective`.
- Old properties that returned Metric objects (`metric`, `metrics`, `metric_signatures`, `get_unconstrainable_metrics`) now emit DeprecationWarning and raise NotImplementedError.
- New `get_unconstrainable_metric_names()` replaces `get_unconstrainable_metrics()`.
- MultiObjective and ScalarizedObjective are preserved as deprecated subclasses that build expression strings internally, keeping isinstance checks working during transition.
- Added three expression-parsing helpers to ax/utils/common/sympy.py: `parse_objective_expression`, `extract_metric_names_from_objective_expr`, `extract_metric_weights_from_objective_expr`.
- All private cached attributes removed from Objective.__init__ except _expression_str. All derived values become computed properties.
- Refactored OutcomeConstraint, ObjectiveThreshold, and ScalarizedOutcomeConstraint to hold expression strings instead of Metric objects.
- OutcomeConstraint now takes an expression string (e.g. "qps >= 700", "loss <= 0.5%") as its primary constructor argument.
Differential Revision: D935208191 parent 1054802 commit 8ff8cf2
128 files changed
Lines changed: 4650 additions & 2827 deletions
File tree
- ax
- adapter
- tests
- transforms
- tests
- analysis
- healthcheck
- tests
- plotly
- tests
- tests
- api
- tests
- utils/instantiation
- tests
- benchmark
- problems
- surrogate/lcbench
- synthetic
- discretized
- hss
- testing
- tests
- problems
- surrogate
- hss
- lcbench
- synthetic
- hss
- core
- tests
- early_stopping
- strategies
- tests
- generation_strategy/tests
- global_stopping
- strategies
- tests
- metrics/tests
- orchestration
- tests
- plot
- tests
- runners/tests
- service
- tests
- utils
- storage
- json_store
- tests
- sqa_store
- tests
- utils
- common
- tests
- testing
- tutorials/external_generation_node
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| |||
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
| 223 | + | |
222 | 224 | | |
223 | 225 | | |
224 | 226 | | |
| |||
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
| 233 | + | |
231 | 234 | | |
232 | 235 | | |
233 | | - | |
| 236 | + | |
234 | 237 | | |
235 | 238 | | |
236 | | - | |
| 239 | + | |
237 | 240 | | |
238 | 241 | | |
239 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
240 | 246 | | |
241 | 247 | | |
242 | 248 | | |
| |||
250 | 256 | | |
251 | 257 | | |
252 | 258 | | |
253 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
254 | 262 | | |
255 | 263 | | |
256 | 264 | | |
| |||
266 | 274 | | |
267 | 275 | | |
268 | 276 | | |
269 | | - | |
| 277 | + | |
| 278 | + | |
270 | 279 | | |
271 | 280 | | |
272 | 281 | | |
273 | 282 | | |
274 | 283 | | |
275 | 284 | | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
287 | 290 | | |
288 | 291 | | |
289 | 292 | | |
290 | 293 | | |
291 | | - | |
| 294 | + | |
292 | 295 | | |
293 | 296 | | |
294 | 297 | | |
| |||
302 | 305 | | |
303 | 306 | | |
304 | 307 | | |
305 | | - | |
| 308 | + | |
306 | 309 | | |
307 | 310 | | |
308 | 311 | | |
309 | 312 | | |
310 | | - | |
| 313 | + | |
311 | 314 | | |
312 | | - | |
313 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
314 | 323 | | |
315 | 324 | | |
316 | 325 | | |
317 | | - | |
| 326 | + | |
318 | 327 | | |
319 | 328 | | |
320 | 329 | | |
321 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
322 | 333 | | |
323 | 334 | | |
324 | 335 | | |
| |||
328 | 339 | | |
329 | 340 | | |
330 | 341 | | |
331 | | - | |
332 | | - | |
| 342 | + | |
| 343 | + | |
333 | 344 | | |
334 | 345 | | |
335 | | - | |
| 346 | + | |
336 | 347 | | |
337 | 348 | | |
338 | 349 | | |
| |||
643 | 654 | | |
644 | 655 | | |
645 | 656 | | |
646 | | - | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
647 | 660 | | |
648 | 661 | | |
649 | 662 | | |
650 | 663 | | |
| 664 | + | |
651 | 665 | | |
652 | 666 | | |
653 | 667 | | |
654 | 668 | | |
655 | 669 | | |
| 670 | + | |
656 | 671 | | |
657 | 672 | | |
658 | 673 | | |
| |||
1111 | 1126 | | |
1112 | 1127 | | |
1113 | 1128 | | |
| 1129 | + | |
1114 | 1130 | | |
1115 | 1131 | | |
1116 | 1132 | | |
| |||
1119 | 1135 | | |
1120 | 1136 | | |
1121 | 1137 | | |
| 1138 | + | |
1122 | 1139 | | |
1123 | 1140 | | |
1124 | 1141 | | |
1125 | 1142 | | |
1126 | 1143 | | |
1127 | | - | |
| 1144 | + | |
| 1145 | + | |
1128 | 1146 | | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
1133 | | - | |
1134 | | - | |
1135 | | - | |
1136 | | - | |
1137 | | - | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
1138 | 1151 | | |
1139 | 1152 | | |
1140 | 1153 | | |
1141 | 1154 | | |
1142 | 1155 | | |
1143 | 1156 | | |
1144 | | - | |
| 1157 | + | |
| 1158 | + | |
1145 | 1159 | | |
1146 | 1160 | | |
1147 | 1161 | | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
1148 | 1165 | | |
1149 | | - | |
| 1166 | + | |
1150 | 1167 | | |
1151 | 1168 | | |
1152 | 1169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
470 | 474 | | |
471 | 475 | | |
472 | | - | |
| 476 | + | |
473 | 477 | | |
474 | 478 | | |
475 | 479 | | |
| |||
689 | 693 | | |
690 | 694 | | |
691 | 695 | | |
692 | | - | |
| 696 | + | |
693 | 697 | | |
694 | 698 | | |
695 | 699 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
573 | 574 | | |
574 | 575 | | |
575 | 576 | | |
| 577 | + | |
576 | 578 | | |
577 | 579 | | |
578 | 580 | | |
| |||
584 | 586 | | |
585 | 587 | | |
586 | 588 | | |
587 | | - | |
| 589 | + | |
| 590 | + | |
588 | 591 | | |
589 | 592 | | |
590 | 593 | | |
| |||
594 | 597 | | |
595 | 598 | | |
596 | 599 | | |
597 | | - | |
598 | | - | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
599 | 603 | | |
600 | 604 | | |
601 | 605 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
167 | 169 | | |
168 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
169 | 173 | | |
170 | 174 | | |
171 | 175 | | |
172 | 176 | | |
| 177 | + | |
173 | 178 | | |
174 | 179 | | |
175 | 180 | | |
| |||
0 commit comments