Skip to content

Commit 8784c8f

Browse files
authored
Merge pull request #173 from OpenOptimizationOrg/pr-convert-problems.yaml
Pr convert problems.yaml
2 parents 32c8b86 + 4da6948 commit 8784c8f

32 files changed

Lines changed: 8250 additions & 1261 deletions
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Check
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches: ["main"]
7+
8+
jobs:
9+
test:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
runs-on: [ubuntu-latest, macos-latest, windows-latest]
14+
python-version: ["3.10", "3.11", "3.12", "3.13"]
15+
runs-on: ${{matrix.runs-on}}
16+
steps:
17+
- uses: actions/checkout@v6
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v7
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install the project
27+
run: uv sync --all-extras --dev
28+
29+
- name: Lint with ruff
30+
run: uv run ruff check --output-format=github .
31+
32+
- name: Run tests
33+
run: uv run pytest --cov=opltools --cov-report=term-missing

examples/cobi.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from opltools import Implementation, Generator, Reference, Library, Variable, Constraint
2+
from pydantic_yaml import to_yaml_str
3+
4+
things = {}
5+
6+
things["cobi_impl"] = Implementation(
7+
name="COBI Implementation",
8+
description="Python library for COBI (COnstrained BI-objective optimization) problem generator",
9+
language="python",
10+
links=[
11+
{
12+
"type": "repository",
13+
"url": "https://github.com/numbbo/cobi-problem-generator/",
14+
},
15+
{
16+
"type": "v0.5.0",
17+
"url": "https://github.com/numbbo/cobi-problem-generator/releases/tag/v0.5.0",
18+
},
19+
],
20+
requirements="https://github.com/numbbo/cobi-problem-generator/blob/main/requirements.txt",
21+
)
22+
23+
things["cobi_problem"] = Generator(
24+
name="COBI Problem",
25+
description="Generator of COnstrained BI-objective optimization problems",
26+
tags={
27+
"constrained",
28+
"bi-objective",
29+
"continuous",
30+
"black-box",
31+
"location",
32+
"multi-peak",
33+
"convex-quadratic",
34+
},
35+
references=[
36+
Reference(
37+
title="Pareto Set Characterization in Constrained Multiobjective Optimization and the COBI Problem Generator",
38+
authors=["Anne Auger", "Dimo Brockhoff", "Luka Opravš", "Tea Tušar"],
39+
link={"type": "arxiv", "url": "https://arxiv.org/abs/2604.09131"},
40+
)
41+
],
42+
objectives={2},
43+
variables=[Variable(type="continuous", dim={"min": 1})],
44+
implementations={"cobi_impl"},
45+
can_evaluate_objectives_independently="no",
46+
constraints=[
47+
# FIXME: Check
48+
Constraint(type="box", hard="yes", number={"min": 1}),
49+
Constraint(type="linear", hard="yes", number={"min": 1}),
50+
Constraint(type="function", hard="yes", number={"min": 1}),
51+
],
52+
noise_type={"none"},
53+
dynamic_type=None,
54+
allows_partial_evaluation="no",
55+
modality={"multi-modal per objective"},
56+
fidelity_levels={1},
57+
source={"artificial"},
58+
code_examples={"./code_153.py"},
59+
)
60+
library = Library(things)
61+
62+
print(to_yaml_str(library))

examples/demo.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from opltools import Suite, Problem, Library, Link, Variable, ValueRange
2+
from pydantic_yaml import to_yaml_str
3+
from opltools.schema import Implementation
4+
5+
things = {}
6+
7+
things["impl_py_cocoex"] = Implementation(
8+
name="coco-experiment Python module",
9+
description="Python bindings for the experiment part of the COCO framework",
10+
language="python",
11+
links=[
12+
Link(type="repository", url="https://github.com/numbbo/coco-experiment"),
13+
Link(type="package", url="https://pypi.org/project/coco-experiment/"),
14+
],
15+
evaluation_time="sub second",
16+
)
17+
18+
for fnr in range(1, 25):
19+
id = f"fn_bbob_f{fnr}"
20+
things[f"fn_bbob_f{fnr}"] = Problem(
21+
name=f"BBOB F_{fnr}",
22+
objectives={1},
23+
variables={Variable(type="continuous", dim=ValueRange(min=1, max=80))},
24+
implementations=["impl_py_cocoex"],
25+
)
26+
27+
things["suite_bbob"] = Suite(
28+
name="BBOB",
29+
problems={f"fn_bbob_f{fnr}" for fnr in range(1, 25)},
30+
implementations=["impl_py_cocoex"],
31+
)
32+
33+
library = Library(things)
34+
35+
print(to_yaml_str(library))

examples/emdo.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
from opltools import Library, Problem, Implementation
2+
from pydantic_yaml import to_yaml_str
3+
4+
#! - name: Electric Motor Design Optimization
5+
#! suite/generator/single: Single Problem
6+
#! variable type: Continuous, Integer
7+
#! dimensionality: '13'
8+
#! objectives: '1'
9+
#! constraints: 'yes'
10+
#! dynamic: 'no'
11+
#! noise: 'yes'
12+
#! multimodal: 'yes'
13+
#! multi-fidelity: 'no'
14+
#! source (real-world/artificial): Real-World Application
15+
#! implementation: Implementation not freely available
16+
#! textual description: The goal is to find a design of a synchronous electric motor
17+
#! for power steering systems that minimizes costs and satisfies all constraints.
18+
#! reference: https://dis.ijs.si/tea/Publications/Tusar23Multistep.pdf (paper in Slovene)
19+
#! other info:
20+
#! partial evaluations: 'no'
21+
#! full name: Electric Motor Design Optimization
22+
#! constraint properties: Hard Constraints, Soft Constraints, Box Constraints
23+
#! number of constraints: '12'
24+
#! description of multimodality: Constraints are multimodal
25+
#! key challenges / characteristics: Time-consuming solution evaluation, highly-constrained
26+
#! problem
27+
#! scientific motivation: Challenging to find good solutions in a limited time
28+
#! limitations: 'Unavailability, even if available, it wouldn''t be helpful to use
29+
#! for benchmarking due taking a long time to evaluate a single solution '
30+
#! implementation languages: Python
31+
#! approximate evaluation time: 8 minutes
32+
#! general: This is not an available problem, but could be interesting to show to
33+
#! researchers which difficulties appear in real-world problems
34+
35+
library = Library({
36+
"impl_emdo": Implementation(
37+
name="Electric Motor Design Optimization",
38+
description="Not publicly available",
39+
language="python",
40+
evaluation_time="8 minutes"
41+
),
42+
"fn_emdo": Problem(
43+
name="Electric Motor Design Optimization",
44+
description="""# Goal
45+
Find a design of a synchronous electric motor for power steering systems that minimizes costs and satisfies all constraints.
46+
47+
# Motivation
48+
Challenging to find good solutions in a limited time
49+
50+
# Key Challenges
51+
* Time-consuming solution evaluation,
52+
* highly-constrained problem
53+
* Constraints are multimodal
54+
55+
This is not an available problem, but could be interesting to show to researchers which difficulties appear in real-world problems""",
56+
objectives=[1],
57+
variables=[
58+
{"type": "continuous", "dim": {"min": None, "max": 13}},
59+
{"type": "integer", "dim": {"min": None, "max": 13}},
60+
],
61+
modality=["multimodal"],
62+
allows_partial_evaluation="no",
63+
constraints=[
64+
{"type": "box", "hard": "some", "number": 12}
65+
],
66+
dynamic_type=["no"],
67+
noise_type=["yes"],
68+
fidelity_levels=[1],
69+
source=["real-world"],
70+
references=[
71+
{
72+
"title": "A Multi-Step Evaluation Process in Electric Motor Design",
73+
"lang": "sj",
74+
"authors": ["Tea Tušar", "Peter Korošec", "Bogdan Filipič"],
75+
"link": {"url": "https://dis.ijs.si/tea/Publications/Tusar23Multistep.pdf"}
76+
}
77+
],
78+
implementations=["impl_emdo"]
79+
)
80+
})
81+
82+
print(to_yaml_str(library))

0 commit comments

Comments
 (0)