Skip to content

Commit defd0dc

Browse files
committed
Merge branch 'update/validate' of github.com:OpenOptimizationOrg/OPL into update/validate
2 parents 4eda3f7 + 733864c commit defd0dc

3 files changed

Lines changed: 57 additions & 52 deletions

File tree

‎examples/emdo.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
name="Electric Motor Design Optimization",
3838
description="Not publicly available",
3939
language="python",
40-
evaluation_time="8 minutes"
40+
evaluation_time=["8 minutes"]
4141
),
4242
"fn_emdo": Problem(
4343
name="Electric Motor Design Optimization",

‎problems.yaml‎

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ fn_emdo:
119119
can_evaluate_objectives_independently: null
120120
code_examples: null
121121
constraints:
122+
- equality: null
123+
hard: some
124+
number: null
125+
type: unknown
122126
- equality: null
123127
hard: yes
124128
number: 12
@@ -127,10 +131,6 @@ fn_emdo:
127131
hard: yes
128132
number: null
129133
type: box
130-
- equality: null
131-
hard: some
132-
number: null
133-
type: unknown
134134
description: "# Goal\nFind a design of a synchronous electric motor for power steering
135135
systems that minimizes costs and satisfies all constraints.\n\n# Motivation\n\
136136
Challenging to find good solutions in a limited time.\n\n# Key Challenges\n* Time-consuming
@@ -166,10 +166,10 @@ fn_emdo:
166166
tags: null
167167
type: problem
168168
variables:
169-
- dim: 13
170-
type: continuous
171169
- dim: 13
172170
type: integer
171+
- dim: 13
172+
type: continuous
173173
fn_fleetopt:
174174
allows_partial_evaluation: yes
175175
can_evaluate_objectives_independently: null
@@ -282,11 +282,11 @@ fn_invdeceptive_deceptive_rotell:
282282
- dim:
283283
max: null
284284
min: 1
285-
type: binary
285+
type: continuous
286286
- dim:
287287
max: null
288288
min: 1
289-
type: continuous
289+
type: binary
290290
fn_inverted_dtlz1:
291291
allows_partial_evaluation: null
292292
can_evaluate_objectives_independently: null
@@ -398,11 +398,11 @@ fn_onemax_sphere_deceptive_rotell:
398398
- dim:
399399
max: null
400400
min: 1
401-
type: binary
401+
type: continuous
402402
- dim:
403403
max: null
404404
min: 1
405-
type: continuous
405+
type: binary
406406
fn_onemax_sphere_zeromax_sphere:
407407
allows_partial_evaluation: null
408408
can_evaluate_objectives_independently: null
@@ -434,11 +434,11 @@ fn_onemax_sphere_zeromax_sphere:
434434
- dim:
435435
max: null
436436
min: 1
437-
type: binary
437+
type: continuous
438438
- dim:
439439
max: null
440440
min: 1
441-
type: continuous
441+
type: binary
442442
fn_radar_waveform:
443443
allows_partial_evaluation: null
444444
can_evaluate_objectives_independently: null
@@ -598,11 +598,11 @@ gen_ealain:
598598
- dim:
599599
max: null
600600
min: 1
601-
type: integer
601+
type: binary
602602
- dim:
603603
max: null
604604
min: 1
605-
type: binary
605+
type: integer
606606
- dim:
607607
max: null
608608
min: 1
@@ -758,8 +758,8 @@ gen_ma_bbob:
758758
evaluation_time: null
759759
fidelity_levels: null
760760
implementations:
761-
- impl_ma_bbob
762761
- impl_iohexperimenter
762+
- impl_ma_bbob
763763
long_name: null
764764
modality:
765765
- multimodal
@@ -929,11 +929,11 @@ gen_randoptgen:
929929
- dim:
930930
max: null
931931
min: 1
932-
type: integer
932+
type: binary
933933
- dim:
934934
max: null
935935
min: 1
936-
type: binary
936+
type: integer
937937
- dim:
938938
max: null
939939
min: 1
@@ -1124,8 +1124,8 @@ impl_cec2022:
11241124
impl_cfd:
11251125
description: Expensive real-world CFD-based test problems
11261126
evaluation_time:
1127-
- 15m
11281127
- 30s
1128+
- 15m
11291129
language: null
11301130
links:
11311131
- type: repository
@@ -2052,8 +2052,8 @@ suite_cec2022:
20522052
evaluation_time: null
20532053
fidelity_levels: null
20542054
implementations:
2055-
- impl_cec2022
20562055
- impl_iohexperimenter
2056+
- impl_cec2022
20572057
long_name: null
20582058
modality: null
20592059
name: CEC2022
@@ -2156,11 +2156,11 @@ suite_cre:
21562156
- dim:
21572157
max: 7
21582158
min: 3
2159-
type: continuous
2159+
type: integer
21602160
- dim:
21612161
max: 7
21622162
min: 3
2163-
type: integer
2163+
type: continuous
21642164
suite_cuter:
21652165
allows_partial_evaluation: no
21662166
can_evaluate_objectives_independently: null
@@ -2196,11 +2196,11 @@ suite_cuter:
21962196
- dim:
21972197
max: null
21982198
min: 1
2199-
type: integer
2199+
type: binary
22002200
- dim:
22012201
max: null
22022202
min: 1
2203-
type: binary
2203+
type: integer
22042204
- dim:
22052205
max: null
22062206
min: 1
@@ -2210,16 +2210,16 @@ suite_cutest:
22102210
can_evaluate_objectives_independently: null
22112211
code_examples: null
22122212
constraints:
2213-
- equality: null
2214-
hard: yes
2215-
number: null
2216-
type: box
22172213
- equality: null
22182214
hard: some
22192215
number:
22202216
max: null
22212217
min: 1
22222218
type: unknown
2219+
- equality: null
2220+
hard: yes
2221+
number: null
2222+
type: box
22232223
description: CUTEst for optimization software
22242224
dynamic_type: null
22252225
evaluation_time: null
@@ -2248,11 +2248,11 @@ suite_cutest:
22482248
- dim:
22492249
max: null
22502250
min: 1
2251-
type: integer
2251+
type: binary
22522252
- dim:
22532253
max: null
22542254
min: 1
2255-
type: binary
2255+
type: integer
22562256
- dim:
22572257
max: null
22582258
min: 1
@@ -2454,14 +2454,14 @@ suite_expobench:
24542454
can_evaluate_objectives_independently: null
24552455
code_examples: null
24562456
constraints:
2457-
- equality: null
2458-
hard: yes
2459-
number: null
2460-
type: box
24612457
- equality: null
24622458
hard: some
24632459
number: null
24642460
type: unknown
2461+
- equality: null
2462+
hard: yes
2463+
number: null
2464+
type: box
24652465
description: Wind farm layout optimization, gas filter design, pipe shape
24662466
optimization, hyperparameter tuning, and hospital simulation
24672467
dynamic_type: null
@@ -2473,8 +2473,8 @@ suite_expobench:
24732473
modality: null
24742474
name: EXPObench
24752475
noise_type:
2476-
- real-life
24772476
- observational
2477+
- real-life
24782478
objectives:
24792479
- 1
24802480
problems: null
@@ -2492,15 +2492,15 @@ suite_expobench:
24922492
- dim:
24932493
max: 135
24942494
min: 10
2495-
type: categorical
2495+
type: integer
24962496
- dim:
24972497
max: 135
24982498
min: 10
2499-
type: integer
2499+
type: continuous
25002500
- dim:
25012501
max: 135
25022502
min: 10
2503-
type: continuous
2503+
type: categorical
25042504
suite_gbea:
25052505
allows_partial_evaluation: null
25062506
can_evaluate_objectives_independently: null
@@ -3131,10 +3131,10 @@ suite_modact:
31313131
tags: null
31323132
type: suite
31333133
variables:
3134-
- dim: 20
3135-
type: continuous
31363134
- dim: 20
31373135
type: integer
3136+
- dim: 20
3137+
type: continuous
31383138
suite_morepo:
31393139
allows_partial_evaluation: null
31403140
can_evaluate_objectives_independently: null
@@ -3272,11 +3272,11 @@ suite_re:
32723272
- dim:
32733273
max: 7
32743274
min: 2
3275-
type: continuous
3275+
type: integer
32763276
- dim:
32773277
max: 7
32783278
min: 2
3279-
type: integer
3279+
type: continuous
32803280
suite_rwmvop:
32813281
allows_partial_evaluation: null
32823282
can_evaluate_objectives_independently: null
@@ -3436,11 +3436,11 @@ suite_tulipa_energy:
34363436
code_examples: null
34373437
constraints:
34383438
- equality: null
3439-
hard: yes
3439+
hard: some
34403440
number: null
34413441
type: unknown
34423442
- equality: null
3443-
hard: some
3443+
hard: yes
34443444
number: null
34453445
type: unknown
34463446
description: Determine the optimal investment and operation decisions for

‎src/opltools/schema.py‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ class Variable(BaseModel):
5656
type: VariableType = VariableType.unknown
5757
dim: int | set[int] | ValueRange | None = 0
5858

59-
60-
def __hash__(self):
61-
if isinstance(self.dim, set):
62-
dim_hash = hash(frozenset(self.dim))
63-
else:
64-
dim_hash = hash(self.dim)
65-
return hash(self.type) + dim_hash
59+
def __hash__(self):
60+
if isinstance(self.dim, set):
61+
dim_hash = hash(frozenset(self.dim))
62+
else:
63+
dim_hash = hash(self.dim)
64+
return hash(self.type) + dim_hash
6665

6766

6867
class ConstraintType(Enum):
@@ -233,7 +232,12 @@ def _percolate_set(self, thing: Any, children: set | None, property: str):
233232
@model_validator(mode="after")
234233
def _validate(self, info: ValidationInfo) -> Self:
235234
# Check for duplicates and
236-
# Make sure all problems referenced in suites exists
235+
# First check and fixup all problems
236+
for id, thing in self.root.items():
237+
if isinstance(thing, Problem) and thing.implementations:
238+
self._percolate_set(thing, thing.implementations, "evaluation_time")
239+
240+
# Then check and fixup all suites because changes from the problems need to propagate to the suites
237241
unique_fields = (
238242
info.context.get("unique_error_fields", []) if info.context else []
239243
)
@@ -271,6 +275,7 @@ def _validate(self, info: ValidationInfo) -> Self:
271275
self._percolate_set(thing, thing.problems, "constraints")
272276
self._percolate_set(thing, thing.problems, "evaluation_time")
273277

278+
seen, duplicates = _update_seen(fields, seen, duplicates, thing)
274279
return self
275280

276281

0 commit comments

Comments
 (0)