Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
fa96b4c
Implement VOCS for simple generators
shuds13 Jul 22, 2025
31ba116
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 22, 2025
7cd13c9
Convert further tests to vocs
shuds13 Jul 23, 2025
b03f0f1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 23, 2025
f973cfa
Make exploration_diagnostics work with vocs
shuds13 Jul 23, 2025
e44319c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 23, 2025
0f8049d
Base generator inherits from standard
shuds13 Jul 23, 2025
a73735c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 23, 2025
942a692
For line_sampling set default value on setup
shuds13 Jul 23, 2025
56757a8
Merge branch 'vocs' of github.com:optimas-org/optimas into vocs
shuds13 Jul 23, 2025
6a51d00
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 23, 2025
3293fde
Add validate_vocs to line sampler
shuds13 Jul 23, 2025
684bf31
Actually add validate_vocs to line sampler
shuds13 Jul 23, 2025
0b690ff
Use observable types and update env test
shuds13 Jul 24, 2025
89323d0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 24, 2025
f313089
Allow observable to be any type
shuds13 Jul 24, 2025
cca80cc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 24, 2025
4b8d698
Update exception test to vocs
shuds13 Jul 24, 2025
c7660e6
Update Ax base and service generators to vocs
shuds13 Jul 25, 2025
fa43bc0
Update gpu resources test
shuds13 Jul 25, 2025
8e21bb5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2025
deaeb6b
Handle constraints in service generators
shuds13 Jul 25, 2025
68e2e13
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2025
d4bb5dc
First pass at converting test_ax_generators to VOCS
shuds13 Jul 25, 2025
cebffd1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2025
36f6277
Make fix_value work
shuds13 Jul 28, 2025
df8066b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 28, 2025
9d9eaf7
Add update_range to work with vocs
shuds13 Jul 28, 2025
bf31174
Merge commit
shuds13 Jul 28, 2025
4948cb5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 28, 2025
cf1211d
Set fidelity parameter via generator
shuds13 Jul 28, 2025
9b60771
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 28, 2025
ce09d6b
Update multitask for vocs and apply id mapping
shuds13 Jul 28, 2025
07eee24
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 28, 2025
9df7f76
Specify multitask trial_type as discrete variable
shuds13 Jul 28, 2025
bbc23bc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 28, 2025
6f0933f
Create vocs in ax_client
shuds13 Jul 29, 2025
3a6ef44
Update model manager test
shuds13 Jul 29, 2025
f883c7b
Revert multitask to preserve ax id/arm info.
shuds13 Jul 30, 2025
346dbee
Convert Discrete integer range to VaryingParameter
shuds13 Jul 30, 2025
844ff1a
No need to pass `is_fidelity`
RemiLehe Aug 18, 2025
d019af5
Update dummy examples to use vocs
shuds13 Aug 19, 2025
21210b9
Update line
shuds13 Aug 19, 2025
b760144
Remove duplicate line
shuds13 Aug 19, 2025
ee2cb13
Update ionization examples to use vocs
shuds13 Aug 19, 2025
b91a7db
Update remaining examples to use vocs
shuds13 Aug 20, 2025
ff92723
Handle discrete variables in gen base class
shuds13 Aug 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/unix-noax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
conda install numpy pandas pytorch cpuonly -c pytorch
conda install -c conda-forge mpi4py mpich
pip install .[test]
pip install git+https://github.com/campa-consortium/generator_standard.git@obs_type
pip uninstall --yes ax-platform # Run without Ax
- shell: bash -l {0}
name: Run unit tests without Ax
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unix-openmpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
conda install numpy pandas pytorch cpuonly -c pytorch
conda install -c conda-forge mpi4py openmpi=5.*
pip install .[test]
pip install git+https://github.com/campa-consortium/generator_standard.git@obs_type
- shell: bash -l {0}
name: Run unit tests with openMPI
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
conda install numpy pandas pytorch cpuonly -c pytorch
conda install -c conda-forge mpi4py mpich
pip install .[test]
pip install git+https://github.com/campa-consortium/generator_standard.git@obs_type
- shell: bash -l {0}
name: Run unit tests with MPICH
run: |
Expand Down
30 changes: 14 additions & 16 deletions examples/astra/run_optimization_serial_ASTRA.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,32 @@
https://optimas.readthedocs.io/en/latest/index.html
"""

from optimas.core import VaryingParameter, Objective, Parameter
from optimas.generators import AxSingleFidelityGenerator
from optimas.evaluators import TemplateEvaluator
from optimas.explorations import Exploration
from generator_standard.vocs import VOCS
from analysis_script import analyze_simulation

# Create varying parameters and objectives.
# Create VOCS object.
# name of parameter, lower bound of values to be explored,
# upper bound of values to be explored
var_1 = VaryingParameter("RF_phase", -2.5, 2.5)
var_2 = VaryingParameter("B_sol", 0.12, 0.38)
# Objectives that will be minimized:
obj_1 = Objective("bunch_length", minimize=True)
obj_2 = Objective("emittance", minimize=True)
# Additional example parameters that will be analyzed but are not used for the
# optimization:
em_x = Parameter("emittance_x")
em_y = Parameter("emittance_y")
vocs = VOCS(
variables={
"RF_phase": [-2.5, 2.5],
"B_sol": [0.12, 0.38],
},
objectives={
"bunch_length": "MINIMIZE",
"emittance": "MINIMIZE",
},
observables=["emittance_x", "emittance_y"],
)

# Create generator.
# Pick the generator to be used, here Single-fidelity Bayesian optimization.
# The analyzed_parameters are parameters that are calculated for each
# simulation but not used for the optimization.
gen = AxSingleFidelityGenerator(
varying_parameters=[var_1, var_2],
objectives=[obj_1, obj_2],
vocs=vocs,
n_init=8,
analyzed_parameters=[em_x, em_y],
)


Expand Down
26 changes: 14 additions & 12 deletions examples/dummy/run_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Basic example of parallel Bayesian optimization with Ax."""

from optimas.core import VaryingParameter, Objective
from generator_standard.vocs import VOCS
from optimas.generators import AxSingleFidelityGenerator
from optimas.evaluators import TemplateEvaluator
from optimas.explorations import Exploration
Expand All @@ -10,16 +10,16 @@ def analyze_simulation(simulation_directory, output_params):
"""Analyze the simulation output.

This method analyzes the output generated by the simulation to
obtain the value of the optimization objective and other analyzed
parameters, if specified. The value of these parameters has to be
given to the `output_params` dictionary.
obtain the value of the optimization objective and other observables.
The value of these parameters has to be given to the
`output_params` dictionary.

Parameters
----------
simulation_directory : str
Path to the simulation folder where the output was generated.
output_params : dict
Dictionary where the value of the objectives and analyzed parameters
Dictionary where the value of the objectives and observables
will be stored. There is one entry per parameter, where the key
is the name of the parameter given by the user.

Expand All @@ -37,16 +37,18 @@ def analyze_simulation(simulation_directory, output_params):
return output_params


# Create varying parameters and objectives.
var_1 = VaryingParameter("x0", 0.0, 15.0)
var_2 = VaryingParameter("x1", 0.0, 15.0)
obj = Objective("f", minimize=True)
# Create VOCS object defining variables, objectives.
vocs = VOCS(
variables={
"x0": [0.0, 15.0],
"x1": [0.0, 15.0],
},
objectives={"f": "MINIMIZE"},
)


# Create generator.
gen = AxSingleFidelityGenerator(
varying_parameters=[var_1, var_2], objectives=[obj], n_init=2
)
gen = AxSingleFidelityGenerator(vocs=vocs, n_init=2)


# Create evaluator.
Expand Down
26 changes: 14 additions & 12 deletions examples/dummy_grid_sampling/run_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Basic example of parallel grid sampling with simulations."""

from optimas.core import VaryingParameter, Objective
from generator_standard.vocs import VOCS
from optimas.generators import GridSamplingGenerator
from optimas.evaluators import TemplateEvaluator
from optimas.explorations import Exploration
Expand All @@ -10,16 +10,16 @@ def analyze_simulation(simulation_directory, output_params):
"""Analyze the simulation output.

This method analyzes the output generated by the simulation to
obtain the value of the optimization objective and other analyzed
parameters, if specified. The value of these parameters has to be
given to the `output_params` dictionary.
obtain the value of the optimization objective and other observables.
The value of these parameters has to be given to the
`output_params` dictionary.

Parameters
----------
simulation_directory : str
Path to the simulation folder where the output was generated.
output_params : dict
Dictionary where the value of the objectives and analyzed parameters
Dictionary where the value of the objectives and observables
will be stored. There is one entry per parameter, where the key
is the name of the parameter given by the user.

Expand All @@ -37,16 +37,18 @@ def analyze_simulation(simulation_directory, output_params):
return output_params


# Create varying parameters and objectives.
var_1 = VaryingParameter("x0", 0.0, 15.0)
var_2 = VaryingParameter("x1", 0.0, 15.0)
obj = Objective("f")
# Create VOCS object defining variables, objectives.
vocs = VOCS(
variables={
"x0": [0.0, 15.0],
"x1": [0.0, 15.0],
},
objectives={"f": "MAXIMIZE"},
)


# Create generator.
gen = GridSamplingGenerator(
varying_parameters=[var_1, var_2], objectives=[obj], n_steps=[5, 7]
)
gen = GridSamplingGenerator(vocs=vocs, n_steps=[5, 7])


# Create evaluator.
Expand Down
26 changes: 14 additions & 12 deletions examples/dummy_line_sampling/run_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Basic example of parallel line sampling with simulations."""

from optimas.core import VaryingParameter, Objective
from generator_standard.vocs import VOCS, ContinuousVariable
from optimas.generators import LineSamplingGenerator
from optimas.evaluators import TemplateEvaluator
from optimas.explorations import Exploration
Expand All @@ -10,16 +10,16 @@ def analyze_simulation(simulation_directory, output_params):
"""Analyze the simulation output.

This method analyzes the output generated by the simulation to
obtain the value of the optimization objective and other analyzed
parameters, if specified. The value of these parameters has to be
given to the `output_params` dictionary.
obtain the value of the optimization objective and other observables.
The value of these parameters has to be given to the
`output_params` dictionary.

Parameters
----------
simulation_directory : str
Path to the simulation folder where the output was generated.
output_params : dict
Dictionary where the value of the objectives and analyzed parameters
Dictionary where the value of the objectives and observables
will be stored. There is one entry per parameter, where the key
is the name of the parameter given by the user.

Expand All @@ -37,16 +37,18 @@ def analyze_simulation(simulation_directory, output_params):
return output_params


# Create varying parameters and objectives.
var_1 = VaryingParameter("x0", 0.0, 15.0, default_value=5.0)
var_2 = VaryingParameter("x1", 0.0, 15.0, default_value=6.0)
obj = Objective("f")
# Create VOCS object defining variables, objectives.
vocs = VOCS(
variables={
"x0": ContinuousVariable(domain=[0.0, 15.0], default_value=5.0),
"x1": ContinuousVariable(domain=[0.0, 15.0], default_value=6.0),
},
objectives={"f": "MAXIMIZE"},
)


# Create generator.
gen = LineSamplingGenerator(
varying_parameters=[var_1, var_2], objectives=[obj], n_steps=[5, 7]
)
gen = LineSamplingGenerator(vocs=vocs, n_steps=[5, 7])


# Create evaluator.
Expand Down
28 changes: 15 additions & 13 deletions examples/dummy_mf/run_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Basic example of parallel multi-fidelity Bayesian optimization with Ax."""

from optimas.core import VaryingParameter, Objective
from generator_standard.vocs import VOCS
from optimas.generators import AxMultiFidelityGenerator
from optimas.evaluators import TemplateEvaluator
from optimas.explorations import Exploration
Expand All @@ -10,16 +10,16 @@ def analyze_simulation(simulation_directory, output_params):
"""Analyze the simulation output.

This method analyzes the output generated by the simulation to
obtain the value of the optimization objective and other analyzed
parameters, if specified. The value of these parameters has to be
given to the `output_params` dictionary.
obtain the value of the optimization objective and other observables.
The value of these parameters has to be given to the
`output_params` dictionary.

Parameters
----------
simulation_directory : str
Path to the simulation folder where the output was generated.
output_params : dict
Dictionary where the value of the objectives and analyzed parameters
Dictionary where the value of the objectives and observables
will be stored. There is one entry per parameter, where the key
is the name of the parameter given by the user.

Expand All @@ -37,22 +37,24 @@ def analyze_simulation(simulation_directory, output_params):
return output_params


# Create varying parameters (including fidelity) and objectives.
var_1 = VaryingParameter("x0", 0.0, 15.0)
var_2 = VaryingParameter("x1", 0.0, 15.0)
res = VaryingParameter(
"resolution", 1.0, 8.0, is_fidelity=True, fidelity_target_value=8.0
# Create VOCS object defining variables, objectives.
vocs = VOCS(
variables={
"x0": [0.0, 15.0],
"x1": [0.0, 15.0],
"resolution": [1.0, 8.0],
},
objectives={"f": "MINIMIZE"},
)
obj = Objective("f", minimize=True)


# Create generator.
gen = AxMultiFidelityGenerator(
varying_parameters=[var_1, var_2, res],
objectives=[obj],
vocs=vocs,
n_init=4,
fidel_cost_intercept=2.0,
)
gen.set_fidelity_param("resolution", fidelity_target_value=8.0)


# Create evaluator.
Expand Down
27 changes: 16 additions & 11 deletions examples/dummy_mt/run_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Basic example of parallel multitask Bayesian optimization with Ax."""

from optimas.core import VaryingParameter, Objective, Task
from generator_standard.vocs import VOCS
from optimas.core import Task
from optimas.generators import AxMultitaskGenerator
from optimas.evaluators import TemplateEvaluator, MultitaskEvaluator
from optimas.explorations import Exploration
Expand All @@ -10,16 +11,16 @@ def analyze_simulation(simulation_directory, output_params):
"""Analyze the simulation output.

This method analyzes the output generated by the simulation to
obtain the value of the optimization objective and other analyzed
parameters, if specified. The value of these parameters has to be
given to the `output_params` dictionary.
obtain the value of the optimization objective and other observables.
The value of these parameters has to be given to the
`output_params` dictionary.

Parameters
----------
simulation_directory : str
Path to the simulation folder where the output was generated.
output_params : dict
Dictionary where the value of the objectives and analyzed parameters
Dictionary where the value of the objectives and observables
will be stored. There is one entry per parameter, where the key
is the name of the parameter given by the user.

Expand All @@ -37,10 +38,15 @@ def analyze_simulation(simulation_directory, output_params):
return output_params


# Create varying parameters and objectives.
var_1 = VaryingParameter("x0", 0.0, 15.0)
var_2 = VaryingParameter("x1", 0.0, 15.0)
obj = Objective("f", minimize=True)
# Create VOCS object defining variables, objectives.
vocs = VOCS(
variables={
"x0": [0.0, 15.0],
"x1": [0.0, 15.0],
"trial_type": {"cheap_model", "expensive_model"},
},
objectives={"f": "MINIMIZE"},
)


# Create tasks.
Expand All @@ -50,8 +56,7 @@ def analyze_simulation(simulation_directory, output_params):

# Create generator.
gen = AxMultitaskGenerator(
varying_parameters=[var_1, var_2],
objectives=[obj],
vocs=vocs,
lofi_task=lofi_task,
hifi_task=hifi_task,
)
Expand Down
Loading
Loading