1
1
"""Basic example of parallel multi-fidelity Bayesian optimization with Ax."""
2
2
3
- from optimas . core import VaryingParameter , Objective
3
+ from generator_standard . vocs import VOCS
4
4
from optimas .generators import AxMultiFidelityGenerator
5
5
from optimas .evaluators import TemplateEvaluator
6
6
from optimas .explorations import Exploration
@@ -10,16 +10,16 @@ def analyze_simulation(simulation_directory, output_params):
10
10
"""Analyze the simulation output.
11
11
12
12
This method analyzes the output generated by the simulation to
13
- obtain the value of the optimization objective and other analyzed
14
- parameters, if specified. The value of these parameters has to be
15
- given to the `output_params` dictionary.
13
+ obtain the value of the optimization objective and other observables.
14
+ The value of these parameters has to be given to the
15
+ `output_params` dictionary.
16
16
17
17
Parameters
18
18
----------
19
19
simulation_directory : str
20
20
Path to the simulation folder where the output was generated.
21
21
output_params : dict
22
- Dictionary where the value of the objectives and analyzed parameters
22
+ Dictionary where the value of the objectives and observables
23
23
will be stored. There is one entry per parameter, where the key
24
24
is the name of the parameter given by the user.
25
25
@@ -37,22 +37,24 @@ def analyze_simulation(simulation_directory, output_params):
37
37
return output_params
38
38
39
39
40
- # Create varying parameters (including fidelity) and objectives.
41
- var_1 = VaryingParameter ("x0" , 0.0 , 15.0 )
42
- var_2 = VaryingParameter ("x1" , 0.0 , 15.0 )
43
- res = VaryingParameter (
44
- "resolution" , 1.0 , 8.0 , is_fidelity = True , fidelity_target_value = 8.0
40
+ # Create VOCS object defining variables, objectives.
41
+ vocs = VOCS (
42
+ variables = {
43
+ "x0" : [0.0 , 15.0 ],
44
+ "x1" : [0.0 , 15.0 ],
45
+ "resolution" : [1.0 , 8.0 ],
46
+ },
47
+ objectives = {"f" : "MINIMIZE" },
45
48
)
46
- obj = Objective ("f" , minimize = True )
47
49
48
50
49
51
# Create generator.
50
52
gen = AxMultiFidelityGenerator (
51
- varying_parameters = [var_1 , var_2 , res ],
52
- objectives = [obj ],
53
+ vocs = vocs ,
53
54
n_init = 4 ,
54
55
fidel_cost_intercept = 2.0 ,
55
56
)
57
+ gen .set_fidelity_param ("resolution" , fidelity_target_value = 8.0 )
56
58
57
59
58
60
# Create evaluator.
0 commit comments