diff --git a/.gitignore b/.gitignore index 51d10e5..8f91fea 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__/ *.py[cod] *$py.class .pyenv +.vscode/settings.json # C extensions *.so diff --git a/setup.py b/setup.py index 23aff94..3dce034 100644 --- a/setup.py +++ b/setup.py @@ -24,5 +24,6 @@ "seaborn", "scipy", "statsmodels", + "itis-dakota", ], ) diff --git a/src/mmux_utils/utils/funs_create_dakota_conf.py b/src/mmux_utils/funs_create_dakota_conf.py similarity index 100% rename from src/mmux_utils/utils/funs_create_dakota_conf.py rename to src/mmux_utils/funs_create_dakota_conf.py diff --git a/src/mmux_utils/utils/funs_data_processing.py b/src/mmux_utils/funs_data_processing.py similarity index 100% rename from src/mmux_utils/utils/funs_data_processing.py rename to src/mmux_utils/funs_data_processing.py diff --git a/src/mmux_utils/funs_evaluate.py b/src/mmux_utils/funs_evaluate.py new file mode 100644 index 0000000..6843c46 --- /dev/null +++ b/src/mmux_utils/funs_evaluate.py @@ -0,0 +1,36 @@ +### Allows to evaluate in different modes - batch, single set, ... +### also in OSPARC or local deployment +from typing import Callable, List +from pathlib import Path +import dakota.environment as dakenv + + +### Otherwise could create a class that I can instantiate and give a "model" at initialization time, +# which is given to "run dakota" as input parameter +def batch_evaluator(model: Callable, batch_input: List[dict]): + return map(model, batch_input) # FIXME not sure this will work + + +def single_evaluator(model: Callable, input: dict): + return model(input) + + +def run_dakota(dakota_conf_path: Path, batch_mode: bool = True): + print("Starting dakota") + dakota_conf = dakota_conf_path.read_text() + callbacks = ( + {"batch_evaluator": batch_evaluator} + if batch_mode + else {"evaluator": single_evaluator} # not sure this will work + ) + study = dakenv.study( + callbacks=callbacks, + input_string=dakota_conf, + ) + study.execute() + ## TODO access documentation of dakenv.study -- cannot, also cannot find in https://github.com/snl-dakota/dakota/tree/devel/packages + # would need to ask Werner + + +if __name__ == "__main__": + print("DONE") diff --git a/src/mmux_utils/utils/funs_gp_evaluation.py b/src/mmux_utils/funs_gp_evaluation.py similarity index 100% rename from src/mmux_utils/utils/funs_gp_evaluation.py rename to src/mmux_utils/funs_gp_evaluation.py diff --git a/src/mmux_utils/plotting/plot_pareto_front.py b/src/mmux_utils/plot_pareto_front.py similarity index 100% rename from src/mmux_utils/plotting/plot_pareto_front.py rename to src/mmux_utils/plot_pareto_front.py diff --git a/src/mmux_utils/plotting/plot_surr.py b/src/mmux_utils/plot_surr.py similarity index 100% rename from src/mmux_utils/plotting/plot_surr.py rename to src/mmux_utils/plot_surr.py diff --git a/src/mmux_utils/plotting/__init__.py b/src/mmux_utils/plotting/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/mmux_utils/utils/__init__.py b/src/mmux_utils/utils/__init__.py deleted file mode 100644 index e69de29..0000000