Skip to content

Commit 945de9a

Browse files
committed
able to render now
1 parent caeb10b commit 945de9a

2 files changed

Lines changed: 23 additions & 16 deletions

File tree

‎examples/p_153.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@
3333
"multi-peak",
3434
"convex-quadratic",
3535
},
36-
references={
36+
references=[
3737
Reference(
3838
title="Pareto Set Characterization in Constrained Multiobjective Optimization and the COBI Problem Generator",
3939
authors=["Anne Auger", "Dimo Brockhoff", "Luka Opravˇs", "Tea Tuˇsar"],
4040
link=Link(type="arxiv", url="https://arxiv.org/abs/2604.09131"),
4141
)
42-
},
42+
],
4343
objectives={2},
44-
variables=Variables(continuous=ValueRange(min=1, max=np.inf)), # inf?
44+
variables=Variables(continuous=ValueRange(min=1, max=100)), # inf?
4545
implementations=["cobi_impl"],
4646
can_evaluate_objectives_independently=YesNoSome.no,
4747
constraints=Constraints(
48-
box=1, linear=np.inf, function=np.inf
48+
box=1, linear=100, function=100
4949
), # convex-quadratic or multipeak, one box per variable?
5050
noise_type={"none"},
5151
soft_constraints=None,

‎src/opltools/schema.py‎

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class OPLType(Enum):
99
problem = "problem"
1010
suite = "suite"
1111
generator = "generator"
12-
implementation = 'implementation'
12+
implementation = "implementation"
1313

1414

1515
class YesNoSome(Enum):
@@ -26,7 +26,7 @@ class Link(BaseModel):
2626

2727
class Thing(BaseModel):
2828
type: OPLType
29-
model_config = ConfigDict(extra='allow')
29+
model_config = ConfigDict(extra="allow")
3030

3131

3232
class Objectives(RootModel):
@@ -75,7 +75,7 @@ class Usage(BaseModel):
7575

7676

7777
class Implementation(Thing):
78-
type: OPLType= OPLType.implementation
78+
type: OPLType = OPLType.implementation
7979
name: str
8080
description: str
8181
links: list[Link] | None = None
@@ -89,7 +89,7 @@ class ProblemLike(Thing):
8989
long_name: str | None = None
9090
description: str | None = None
9191
tags: set[str] | None = None
92-
references: set[Reference] | None = None
92+
references: list[Reference] | None = None
9393
implementations: set[str] | None = None
9494
objectives: set[int] | None = None
9595
variables: Variables | None = None
@@ -106,29 +106,31 @@ class ProblemLike(Thing):
106106

107107

108108
class Problem(ProblemLike):
109-
type:OPLType = OPLType.problem
109+
type: OPLType = OPLType.problem
110110
instances: ValueRange | list[str] | None = None
111111

112112

113113
class Suite(ProblemLike):
114-
type:OPLType = OPLType.suite
114+
type: OPLType = OPLType.suite
115115
problems: set[str] | None = None
116116

117117

118118
class Generator(ProblemLike):
119-
type:OPLType = OPLType.generator
119+
type: OPLType = OPLType.generator
120120

121121

122122
class Library(RootModel):
123123
root: dict[str, Problem | Generator | Suite | Implementation] | None
124124

125-
def _check_id_references(self, ids, type:OPLType) -> None:
125+
def _check_id_references(self, ids, type: OPLType) -> None:
126126
if not self.root:
127127
return
128128
for id in ids:
129129
if id in self.root:
130130
if self.root[id].type != type:
131-
raise ValueError(f"ID {id} is a {self.root[id].name}, expected a {type.name}")
131+
raise ValueError(
132+
f"ID {id} is a {self.root[id].name}, expected a {type.name}"
133+
)
132134
else:
133135
raise ValueError(f"Missing {type.name} with id '{id}'")
134136

@@ -145,11 +147,16 @@ def validate(self) -> Self:
145147
if isinstance(thing, Suite) and thing.problems:
146148
for problem_id in thing.problems:
147149
if problem_id not in self.root:
148-
raise ValueError(f"Suite {id} references problem with undefined id '{problem_id}'.")
150+
raise ValueError(
151+
f"Suite {id} references problem with undefined id '{problem_id}'."
152+
)
149153
if self.root[problem_id].type != OPLType.problem:
150-
raise ValueError(f"Suite {id} references problem with id '{problem_id}' but id is a {self.root[problem_id].type.name}.")
154+
raise ValueError(
155+
f"Suite {id} references problem with id '{problem_id}' but id is a {self.root[problem_id].type.name}."
156+
)
151157
return self
152158

159+
153160
__all__ = [
154161
"Problem",
155162
"Suite",
@@ -158,5 +165,5 @@ def validate(self) -> Self:
158165
"Library",
159166
"YesNoSome",
160167
"Link",
161-
"Reference"
168+
"Reference",
162169
]

0 commit comments

Comments
 (0)