gemseo-multi-fidelity 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gemseo_multi_fidelity/__init__.py +17 -0
- gemseo_multi_fidelity/core/MFMapperAdapter_input.json +22 -0
- gemseo_multi_fidelity/core/MFMapperAdapter_output.json +22 -0
- gemseo_multi_fidelity/core/MFMapperLinker_input.json +22 -0
- gemseo_multi_fidelity/core/MFMapperLinker_output.json +22 -0
- gemseo_multi_fidelity/core/MFScenarioAdapter_input.json +39 -0
- gemseo_multi_fidelity/core/MFScenarioAdapter_output.json +23 -0
- gemseo_multi_fidelity/core/__init__.py +16 -0
- gemseo_multi_fidelity/core/boxed_domain.py +242 -0
- gemseo_multi_fidelity/core/corr_function.py +411 -0
- gemseo_multi_fidelity/core/criticality.py +124 -0
- gemseo_multi_fidelity/core/ds_mapper.py +307 -0
- gemseo_multi_fidelity/core/errors.py +42 -0
- gemseo_multi_fidelity/core/eval_mapper.py +188 -0
- gemseo_multi_fidelity/core/id_mapper_adapter.py +61 -0
- gemseo_multi_fidelity/core/mapper_adapter.py +126 -0
- gemseo_multi_fidelity/core/mapper_linker.py +72 -0
- gemseo_multi_fidelity/core/mf_formulation.py +635 -0
- gemseo_multi_fidelity/core/mf_logger.py +216 -0
- gemseo_multi_fidelity/core/mf_opt_problem.py +480 -0
- gemseo_multi_fidelity/core/mf_scenario.py +205 -0
- gemseo_multi_fidelity/core/noise_criterion.py +94 -0
- gemseo_multi_fidelity/core/projpolytope.out +0 -0
- gemseo_multi_fidelity/core/scenario_adapter.py +568 -0
- gemseo_multi_fidelity/core/stop_criteria.py +201 -0
- gemseo_multi_fidelity/core/strict_chain.py +75 -0
- gemseo_multi_fidelity/core/utils_model_quality.py +74 -0
- gemseo_multi_fidelity/corrections/__init__.py +16 -0
- gemseo_multi_fidelity/corrections/add_corr_function.py +80 -0
- gemseo_multi_fidelity/corrections/correction_factory.py +65 -0
- gemseo_multi_fidelity/corrections/mul_corr_function.py +86 -0
- gemseo_multi_fidelity/drivers/__init__.py +16 -0
- gemseo_multi_fidelity/drivers/mf_algo_factory.py +38 -0
- gemseo_multi_fidelity/drivers/mf_driver_lib.py +462 -0
- gemseo_multi_fidelity/drivers/refinement.py +234 -0
- gemseo_multi_fidelity/drivers/settings/__init__.py +16 -0
- gemseo_multi_fidelity/drivers/settings/base_mf_driver_settings.py +59 -0
- gemseo_multi_fidelity/drivers/settings/mf_refine_settings.py +50 -0
- gemseo_multi_fidelity/formulations/__init__.py +16 -0
- gemseo_multi_fidelity/formulations/refinement.py +144 -0
- gemseo_multi_fidelity/mapping/__init__.py +16 -0
- gemseo_multi_fidelity/mapping/identity_mapper.py +74 -0
- gemseo_multi_fidelity/mapping/interp_mapper.py +422 -0
- gemseo_multi_fidelity/mapping/mapper_factory.py +70 -0
- gemseo_multi_fidelity/mapping/mapping_errors.py +46 -0
- gemseo_multi_fidelity/mapping/subset_mapper.py +122 -0
- gemseo_multi_fidelity/mf_rosenbrock/__init__.py +16 -0
- gemseo_multi_fidelity/mf_rosenbrock/delayed_disc.py +136 -0
- gemseo_multi_fidelity/mf_rosenbrock/refact_rosen_testcase.py +46 -0
- gemseo_multi_fidelity/mf_rosenbrock/rosen_mf_case.py +284 -0
- gemseo_multi_fidelity/mf_rosenbrock/rosen_mf_funcs.py +350 -0
- gemseo_multi_fidelity/models/__init__.py +16 -0
- gemseo_multi_fidelity/models/fake_updater.py +112 -0
- gemseo_multi_fidelity/models/model_updater.py +91 -0
- gemseo_multi_fidelity/models/rbf/__init__.py +16 -0
- gemseo_multi_fidelity/models/rbf/kernel_factory.py +66 -0
- gemseo_multi_fidelity/models/rbf/kernels/__init__.py +16 -0
- gemseo_multi_fidelity/models/rbf/kernels/gaussian.py +93 -0
- gemseo_multi_fidelity/models/rbf/kernels/matern_3_2.py +101 -0
- gemseo_multi_fidelity/models/rbf/kernels/matern_5_2.py +101 -0
- gemseo_multi_fidelity/models/rbf/kernels/rbf_kernel.py +172 -0
- gemseo_multi_fidelity/models/rbf/rbf_model.py +422 -0
- gemseo_multi_fidelity/models/sparse_rbf_updater.py +96 -0
- gemseo_multi_fidelity/models/taylor/__init__.py +16 -0
- gemseo_multi_fidelity/models/taylor/taylor.py +212 -0
- gemseo_multi_fidelity/models/taylor_updater.py +66 -0
- gemseo_multi_fidelity/models/updater_factory.py +62 -0
- gemseo_multi_fidelity/settings/__init__.py +16 -0
- gemseo_multi_fidelity/settings/drivers.py +22 -0
- gemseo_multi_fidelity/settings/formulations.py +16 -0
- gemseo_multi_fidelity-0.0.1.dist-info/METADATA +99 -0
- gemseo_multi_fidelity-0.0.1.dist-info/RECORD +76 -0
- gemseo_multi_fidelity-0.0.1.dist-info/WHEEL +5 -0
- gemseo_multi_fidelity-0.0.1.dist-info/entry_points.txt +2 -0
- gemseo_multi_fidelity-0.0.1.dist-info/licenses/LICENSE.txt +165 -0
- gemseo_multi_fidelity-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Copyright 2021 IRT Saint Exupéry, https://www.irt-saintexupery.com
|
|
2
|
+
#
|
|
3
|
+
# This program is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 3 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
13
|
+
# along with this program; if not, write to the Free Software Foundation,
|
|
14
|
+
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
15
|
+
|
|
16
|
+
# Copyright (c) 2019 AIRBUS OPERATIONS
|
|
17
|
+
|
|
18
|
+
#
|
|
19
|
+
# Contributors:
|
|
20
|
+
# INITIAL AUTHORS - API and implementation and/or documentation
|
|
21
|
+
# :author: Romain Olivanti
|
|
22
|
+
# OTHER AUTHORS - MACROSCOPIC CHANGES
|
|
23
|
+
"""Adapter to wrap an EvaluationMapper in a Discipline."""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
from typing import TYPE_CHECKING
|
|
28
|
+
|
|
29
|
+
from gemseo.core.discipline.discipline import Discipline
|
|
30
|
+
|
|
31
|
+
from gemseo_multi_fidelity.core.eval_mapper import EvaluationMapper
|
|
32
|
+
from gemseo_multi_fidelity.core.scenario_adapter import MFScenarioAdapter
|
|
33
|
+
|
|
34
|
+
if TYPE_CHECKING:
|
|
35
|
+
from gemseo.typing import StrKeyMapping
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class MFMapperAdapter(Discipline):
|
|
39
|
+
"""Multi-fidelity evaluation mapper adapter."""
|
|
40
|
+
|
|
41
|
+
auto_detect_grammar_files = True
|
|
42
|
+
|
|
43
|
+
def __init__(
|
|
44
|
+
self, name: str, eval_mapper: EvaluationMapper, direct: bool = True
|
|
45
|
+
) -> None:
|
|
46
|
+
"""Constructor.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
name: The name of the adapter.
|
|
50
|
+
eval_mapper: The mapper between two levels.
|
|
51
|
+
direct: ``True`` to use the direct order.
|
|
52
|
+
"""
|
|
53
|
+
super().__init__(name=name)
|
|
54
|
+
|
|
55
|
+
if not isinstance(eval_mapper, EvaluationMapper):
|
|
56
|
+
msg = "eval_mapper must be an EvaluationMapper"
|
|
57
|
+
raise TypeError(msg)
|
|
58
|
+
|
|
59
|
+
if not isinstance(direct, bool):
|
|
60
|
+
msg = "direct must be a boolean"
|
|
61
|
+
raise TypeError(msg)
|
|
62
|
+
|
|
63
|
+
self.eval_mapper = eval_mapper
|
|
64
|
+
self._is_direct = direct
|
|
65
|
+
self._init_grammars(self.__class__.__name__)
|
|
66
|
+
|
|
67
|
+
def _init_grammars(self, name: str) -> None:
|
|
68
|
+
"""Initialize the grammars."""
|
|
69
|
+
# comp_dir = Path(inspect.getfile(MFScenarioAdapter)).absolute().parent
|
|
70
|
+
# input_grammar_file = self.auto_get_grammar_file(True, name, comp_dir)
|
|
71
|
+
# output_grammar_file = self.auto_get_grammar_file(False, name, comp_dir)
|
|
72
|
+
# self._instantiate_grammars(input_grammar_file, output_grammar_file)
|
|
73
|
+
|
|
74
|
+
if self._is_direct:
|
|
75
|
+
# Remove the reference data from the output grammar as it should not be
|
|
76
|
+
# forwarded
|
|
77
|
+
for item in [MFScenarioAdapter.X_REF, MFScenarioAdapter.OUTPUT_REF]:
|
|
78
|
+
del self.output_grammar[item]
|
|
79
|
+
|
|
80
|
+
def _map_x_best(self) -> None:
|
|
81
|
+
"""Map the output best point as the next starting point."""
|
|
82
|
+
x_in = self.io.data[MFScenarioAdapter.X_BEST]
|
|
83
|
+
|
|
84
|
+
if self._is_direct:
|
|
85
|
+
map_method = self.eval_mapper.design_space_mapper.map_vars_direct
|
|
86
|
+
else:
|
|
87
|
+
map_method = self.eval_mapper.design_space_mapper.map_vars_reverse
|
|
88
|
+
|
|
89
|
+
self.io.data[MFScenarioAdapter.X_START] = map_method(x_in, to_array=False)
|
|
90
|
+
|
|
91
|
+
def _map_reference_data(self) -> None:
|
|
92
|
+
"""Map the reference data, filters out reference data in direct mode."""
|
|
93
|
+
tag_x_ref = MFScenarioAdapter.X_REF
|
|
94
|
+
tag_output_ref = MFScenarioAdapter.OUTPUT_REF
|
|
95
|
+
|
|
96
|
+
x_ref = self.io.data.get(tag_x_ref)
|
|
97
|
+
if x_ref is not None:
|
|
98
|
+
output_ref = self.io.data[tag_output_ref]
|
|
99
|
+
if self._is_direct:
|
|
100
|
+
# Should not forward reference data in forward mode, delete it
|
|
101
|
+
del self.io.data[tag_x_ref]
|
|
102
|
+
del self.io.data[tag_output_ref]
|
|
103
|
+
else:
|
|
104
|
+
# Map it
|
|
105
|
+
output_ref, x_ref = self.eval_mapper.map_eval_reverse(
|
|
106
|
+
output_ref, x_eval=x_ref, to_arrays=False
|
|
107
|
+
)
|
|
108
|
+
self.io.data[tag_x_ref] = x_ref
|
|
109
|
+
self.io.data[tag_output_ref] = output_ref
|
|
110
|
+
|
|
111
|
+
def _forward_options(self) -> None:
|
|
112
|
+
"""Copy the options stored in output options in input options."""
|
|
113
|
+
output_options = self.io.data.get(MFScenarioAdapter.OUTPUT_OPTIONS)
|
|
114
|
+
if output_options is not None:
|
|
115
|
+
self.io.data[MFScenarioAdapter.INPUT_OPTIONS] = output_options
|
|
116
|
+
|
|
117
|
+
def _run(self, input_data: StrKeyMapping) -> None:
|
|
118
|
+
"""Run the mapping, filters out reference data in direct mode if present."""
|
|
119
|
+
# Map the current point
|
|
120
|
+
self._map_x_best()
|
|
121
|
+
|
|
122
|
+
# Map the reference data if needed
|
|
123
|
+
self._map_reference_data()
|
|
124
|
+
|
|
125
|
+
# Forward the options
|
|
126
|
+
self._forward_options()
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Copyright 2021 IRT Saint Exupéry, https://www.irt-saintexupery.com
|
|
2
|
+
#
|
|
3
|
+
# This program is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 3 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
13
|
+
# along with this program; if not, write to the Free Software Foundation,
|
|
14
|
+
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
15
|
+
|
|
16
|
+
# Copyright (c) 2020 AIRBUS OPERATIONS
|
|
17
|
+
|
|
18
|
+
#
|
|
19
|
+
# Contributors:
|
|
20
|
+
# INITIAL AUTHORS - API and implementation and/or documentation
|
|
21
|
+
# :author: Romain Olivanti
|
|
22
|
+
# OTHER AUTHORS - MACROSCOPIC CHANGES
|
|
23
|
+
"""Adapter to link two mappers."""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
from typing import TYPE_CHECKING
|
|
28
|
+
|
|
29
|
+
from gemseo.core.discipline.discipline import Discipline
|
|
30
|
+
|
|
31
|
+
from gemseo_multi_fidelity.core.scenario_adapter import MFScenarioAdapter
|
|
32
|
+
|
|
33
|
+
if TYPE_CHECKING:
|
|
34
|
+
from gemseo.typing import StrKeyMapping
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class MFMapperLinker(Discipline):
|
|
38
|
+
"""Multi-fidelity evaluation mapper adapter."""
|
|
39
|
+
|
|
40
|
+
auto_detect_grammar_files = True
|
|
41
|
+
|
|
42
|
+
def __init__(self, name: str) -> None:
|
|
43
|
+
"""Constructor.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
name: The name of the adapter.
|
|
47
|
+
"""
|
|
48
|
+
super().__init__(name=name)
|
|
49
|
+
self._init_grammars(self.__class__.__name__)
|
|
50
|
+
|
|
51
|
+
def _init_grammars(self, name: str) -> None:
|
|
52
|
+
"""Initialize the grammars."""
|
|
53
|
+
# comp_dir = Path(inspect.getfile(MFScenarioAdapter)).absolute().parent
|
|
54
|
+
# input_grammar_file = self.auto_get_grammar_file(True, name, comp_dir)
|
|
55
|
+
# output_grammar_file = self.auto_get_grammar_file(False, name, comp_dir)
|
|
56
|
+
# self._instantiate_grammars(input_grammar_file, output_grammar_file)
|
|
57
|
+
|
|
58
|
+
def _forward_x_best(self) -> None:
|
|
59
|
+
"""Map the output best point as the next starting point."""
|
|
60
|
+
x_best = self.io.data[MFScenarioAdapter.X_START]
|
|
61
|
+
self.io.data[MFScenarioAdapter.X_BEST] = x_best
|
|
62
|
+
|
|
63
|
+
def _forward_options(self) -> None:
|
|
64
|
+
"""Forward options so they can be used by a mapper."""
|
|
65
|
+
input_options = self.io.data.get(MFScenarioAdapter.INPUT_OPTIONS)
|
|
66
|
+
if input_options is not None:
|
|
67
|
+
self.io.data[MFScenarioAdapter.OUTPUT_OPTIONS] = input_options
|
|
68
|
+
|
|
69
|
+
def _run(self, input_data: StrKeyMapping) -> None:
|
|
70
|
+
"""Run."""
|
|
71
|
+
self._forward_x_best()
|
|
72
|
+
self._forward_options()
|