boa.wrapper_utils.load_json#
- boa.wrapper_utils.load_json(*args, **kwargs) dict[source]#
Read experiment configuration file for setting up the optimization. yml file contains the list of parameters, and whether each parameter is a fixed parameter or a range parameter. Fixed parameters have a value specified, and range parameters have a range specified.
- Parameters
config_file (os.PathLike) – File path for the experiment configuration file
normalize (bool) – Whether to run boa.wrapper_utils.normalize_config after loading config to run certain predictable configuration normalization. (default true)
parameter_keys (str | list[Union[str, list[str], list[Union[str, int]]]]) – Alternative keys or paths to keys to parse as parameters to optimize, for more information, see
wpr_params_to_boa()
Examples
If you have a parameters in your configration like this
>>> from boa import normalize_config >>> config = { ... "params": { ... "a": {"x1": {"bounds": [0, 1], "type": "range"}, "x2": {"type": "fixed", "value": 0.5}}, ... "b": {"x1": {"bounds": [0, 1], "type": "range"}, "x2": {"type": "fixed", "value": 0.5}}, ... }, ... "params2": [ ... {0: {"x1": {"bounds": [0, 1], "type": "range"}, "x2": {"type": "fixed", "value": 0.5}}}, ... {0: {"x1": {"bounds": [0, 1], "type": "range"}, "x2": {"type": "fixed", "value": 0.5}}}, ... ], ... "params_a": {"x1": {"bounds": [0, 1], "type": "range"}, "x2": {"type": "fixed", "value": 0.5}}, ... } >>> parameter_keys = [ ... ["params", "a"], ... ["params", "b"], ... ["params_a"], ... ["params2", 0, 0], ... ["params2", 1, 0], ... ] >>> config = normalize_config(config, parameter_keys) >>> pprint(config["parameters"]) [{'bounds': [0, 1], 'name': 'params_a_x1', 'type': 'range'}, {'name': 'params_a_x2', 'type': 'fixed', 'value': 0.5}, {'bounds': [0, 1], 'name': 'params_b_x1', 'type': 'range'}, {'name': 'params_b_x2', 'type': 'fixed', 'value': 0.5}, {'bounds': [0, 1], 'name': 'params_a_x1_0', 'type': 'range'}, {'name': 'params_a_x2_0', 'type': 'fixed', 'value': 0.5}, {'bounds': [0, 1], 'name': 'params2_0_0_x1', 'type': 'range'}, {'name': 'params2_0_0_x2', 'type': 'fixed', 'value': 0.5}, {'bounds': [0, 1], 'name': 'params2_1_0_x1', 'type': 'range'}, {'name': 'params2_1_0_x2', 'type': 'fixed', 'value': 0.5}]
- Returns
loaded_configs
- Return type
dict