desdeo 1.2__py3-none-any.whl → 2.1.0__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.
- desdeo/__init__.py +8 -8
- desdeo/adm/ADMAfsar.py +551 -0
- desdeo/adm/ADMChen.py +414 -0
- desdeo/adm/BaseADM.py +119 -0
- desdeo/adm/__init__.py +11 -0
- desdeo/api/README.md +73 -0
- desdeo/api/__init__.py +15 -0
- desdeo/api/app.py +50 -0
- desdeo/api/config.py +90 -0
- desdeo/api/config.toml +64 -0
- desdeo/api/db.py +27 -0
- desdeo/api/db_init.py +85 -0
- desdeo/api/db_models.py +164 -0
- desdeo/api/malaga_db_init.py +27 -0
- desdeo/api/models/__init__.py +266 -0
- desdeo/api/models/archive.py +23 -0
- desdeo/api/models/emo.py +128 -0
- desdeo/api/models/enautilus.py +69 -0
- desdeo/api/models/gdm/gdm_aggregate.py +139 -0
- desdeo/api/models/gdm/gdm_base.py +69 -0
- desdeo/api/models/gdm/gdm_score_bands.py +114 -0
- desdeo/api/models/gdm/gnimbus.py +138 -0
- desdeo/api/models/generic.py +104 -0
- desdeo/api/models/generic_states.py +401 -0
- desdeo/api/models/nimbus.py +158 -0
- desdeo/api/models/preference.py +128 -0
- desdeo/api/models/problem.py +717 -0
- desdeo/api/models/reference_point_method.py +18 -0
- desdeo/api/models/session.py +49 -0
- desdeo/api/models/state.py +463 -0
- desdeo/api/models/user.py +52 -0
- desdeo/api/models/utopia.py +25 -0
- desdeo/api/routers/_EMO.backup +309 -0
- desdeo/api/routers/_NAUTILUS.py +245 -0
- desdeo/api/routers/_NAUTILUS_navigator.py +233 -0
- desdeo/api/routers/_NIMBUS.py +765 -0
- desdeo/api/routers/__init__.py +5 -0
- desdeo/api/routers/emo.py +497 -0
- desdeo/api/routers/enautilus.py +237 -0
- desdeo/api/routers/gdm/gdm_aggregate.py +234 -0
- desdeo/api/routers/gdm/gdm_base.py +420 -0
- desdeo/api/routers/gdm/gdm_score_bands/gdm_score_bands_manager.py +398 -0
- desdeo/api/routers/gdm/gdm_score_bands/gdm_score_bands_routers.py +377 -0
- desdeo/api/routers/gdm/gnimbus/gnimbus_manager.py +698 -0
- desdeo/api/routers/gdm/gnimbus/gnimbus_routers.py +591 -0
- desdeo/api/routers/generic.py +233 -0
- desdeo/api/routers/nimbus.py +705 -0
- desdeo/api/routers/problem.py +307 -0
- desdeo/api/routers/reference_point_method.py +93 -0
- desdeo/api/routers/session.py +100 -0
- desdeo/api/routers/test.py +16 -0
- desdeo/api/routers/user_authentication.py +520 -0
- desdeo/api/routers/utils.py +187 -0
- desdeo/api/routers/utopia.py +230 -0
- desdeo/api/schema.py +100 -0
- desdeo/api/tests/__init__.py +0 -0
- desdeo/api/tests/conftest.py +151 -0
- desdeo/api/tests/test_enautilus.py +330 -0
- desdeo/api/tests/test_models.py +1179 -0
- desdeo/api/tests/test_routes.py +1075 -0
- desdeo/api/utils/_database.py +263 -0
- desdeo/api/utils/_logger.py +29 -0
- desdeo/api/utils/database.py +36 -0
- desdeo/api/utils/emo_database.py +40 -0
- desdeo/core.py +34 -0
- desdeo/emo/__init__.py +159 -0
- desdeo/emo/hooks/archivers.py +188 -0
- desdeo/emo/methods/EAs.py +541 -0
- desdeo/emo/methods/__init__.py +0 -0
- desdeo/emo/methods/bases.py +12 -0
- desdeo/emo/methods/templates.py +111 -0
- desdeo/emo/operators/__init__.py +1 -0
- desdeo/emo/operators/crossover.py +1282 -0
- desdeo/emo/operators/evaluator.py +114 -0
- desdeo/emo/operators/generator.py +459 -0
- desdeo/emo/operators/mutation.py +1224 -0
- desdeo/emo/operators/scalar_selection.py +202 -0
- desdeo/emo/operators/selection.py +1778 -0
- desdeo/emo/operators/termination.py +286 -0
- desdeo/emo/options/__init__.py +108 -0
- desdeo/emo/options/algorithms.py +435 -0
- desdeo/emo/options/crossover.py +164 -0
- desdeo/emo/options/generator.py +131 -0
- desdeo/emo/options/mutation.py +260 -0
- desdeo/emo/options/repair.py +61 -0
- desdeo/emo/options/scalar_selection.py +66 -0
- desdeo/emo/options/selection.py +127 -0
- desdeo/emo/options/templates.py +383 -0
- desdeo/emo/options/termination.py +143 -0
- desdeo/explanations/__init__.py +6 -0
- desdeo/explanations/explainer.py +100 -0
- desdeo/explanations/utils.py +90 -0
- desdeo/gdm/__init__.py +22 -0
- desdeo/gdm/gdmtools.py +45 -0
- desdeo/gdm/score_bands.py +114 -0
- desdeo/gdm/voting_rules.py +50 -0
- desdeo/mcdm/__init__.py +41 -0
- desdeo/mcdm/enautilus.py +338 -0
- desdeo/mcdm/gnimbus.py +484 -0
- desdeo/mcdm/nautili.py +345 -0
- desdeo/mcdm/nautilus.py +477 -0
- desdeo/mcdm/nautilus_navigator.py +656 -0
- desdeo/mcdm/nimbus.py +417 -0
- desdeo/mcdm/pareto_navigator.py +269 -0
- desdeo/mcdm/reference_point_method.py +186 -0
- desdeo/problem/__init__.py +83 -0
- desdeo/problem/evaluator.py +561 -0
- desdeo/problem/external/__init__.py +18 -0
- desdeo/problem/external/core.py +356 -0
- desdeo/problem/external/pymoo_provider.py +266 -0
- desdeo/problem/external/runtime.py +44 -0
- desdeo/problem/gurobipy_evaluator.py +562 -0
- desdeo/problem/infix_parser.py +341 -0
- desdeo/problem/json_parser.py +944 -0
- desdeo/problem/pyomo_evaluator.py +487 -0
- desdeo/problem/schema.py +1829 -0
- desdeo/problem/simulator_evaluator.py +348 -0
- desdeo/problem/sympy_evaluator.py +244 -0
- desdeo/problem/testproblems/__init__.py +88 -0
- desdeo/problem/testproblems/benchmarks_server.py +120 -0
- desdeo/problem/testproblems/binh_and_korn_problem.py +88 -0
- desdeo/problem/testproblems/cake_problem.py +185 -0
- desdeo/problem/testproblems/dmitry_forest_problem_discrete.py +71 -0
- desdeo/problem/testproblems/dtlz2_problem.py +102 -0
- desdeo/problem/testproblems/forest_problem.py +283 -0
- desdeo/problem/testproblems/knapsack_problem.py +163 -0
- desdeo/problem/testproblems/mcwb_problem.py +831 -0
- desdeo/problem/testproblems/mixed_variable_dimenrions_problem.py +83 -0
- desdeo/problem/testproblems/momip_problem.py +172 -0
- desdeo/problem/testproblems/multi_valued_constraints.py +119 -0
- desdeo/problem/testproblems/nimbus_problem.py +143 -0
- desdeo/problem/testproblems/pareto_navigator_problem.py +89 -0
- desdeo/problem/testproblems/re_problem.py +492 -0
- desdeo/problem/testproblems/river_pollution_problems.py +440 -0
- desdeo/problem/testproblems/rocket_injector_design_problem.py +140 -0
- desdeo/problem/testproblems/simple_problem.py +351 -0
- desdeo/problem/testproblems/simulator_problem.py +92 -0
- desdeo/problem/testproblems/single_objective.py +289 -0
- desdeo/problem/testproblems/spanish_sustainability_problem.py +945 -0
- desdeo/problem/testproblems/zdt_problem.py +274 -0
- desdeo/problem/utils.py +245 -0
- desdeo/tools/GenerateReferencePoints.py +181 -0
- desdeo/tools/__init__.py +120 -0
- desdeo/tools/desc_gen.py +22 -0
- desdeo/tools/generics.py +165 -0
- desdeo/tools/group_scalarization.py +3090 -0
- desdeo/tools/gurobipy_solver_interfaces.py +258 -0
- desdeo/tools/indicators_binary.py +117 -0
- desdeo/tools/indicators_unary.py +362 -0
- desdeo/tools/interaction_schema.py +38 -0
- desdeo/tools/intersection.py +54 -0
- desdeo/tools/iterative_pareto_representer.py +99 -0
- desdeo/tools/message.py +265 -0
- desdeo/tools/ng_solver_interfaces.py +199 -0
- desdeo/tools/non_dominated_sorting.py +134 -0
- desdeo/tools/patterns.py +283 -0
- desdeo/tools/proximal_solver.py +99 -0
- desdeo/tools/pyomo_solver_interfaces.py +477 -0
- desdeo/tools/reference_vectors.py +229 -0
- desdeo/tools/scalarization.py +2065 -0
- desdeo/tools/scipy_solver_interfaces.py +454 -0
- desdeo/tools/score_bands.py +627 -0
- desdeo/tools/utils.py +388 -0
- desdeo/tools/visualizations.py +67 -0
- desdeo/utopia_stuff/__init__.py +0 -0
- desdeo/utopia_stuff/data/1.json +15 -0
- desdeo/utopia_stuff/data/2.json +13 -0
- desdeo/utopia_stuff/data/3.json +15 -0
- desdeo/utopia_stuff/data/4.json +17 -0
- desdeo/utopia_stuff/data/5.json +15 -0
- desdeo/utopia_stuff/from_json.py +40 -0
- desdeo/utopia_stuff/reinit_user.py +38 -0
- desdeo/utopia_stuff/utopia_db_init.py +212 -0
- desdeo/utopia_stuff/utopia_problem.py +403 -0
- desdeo/utopia_stuff/utopia_problem_old.py +415 -0
- desdeo/utopia_stuff/utopia_reference_solutions.py +79 -0
- desdeo-2.1.0.dist-info/METADATA +186 -0
- desdeo-2.1.0.dist-info/RECORD +180 -0
- {desdeo-1.2.dist-info → desdeo-2.1.0.dist-info}/WHEEL +1 -1
- desdeo-2.1.0.dist-info/licenses/LICENSE +21 -0
- desdeo-1.2.dist-info/METADATA +0 -16
- desdeo-1.2.dist-info/RECORD +0 -4
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"""Model exports."""
|
|
2
|
+
|
|
3
|
+
__all__ = [ # noqa: RUF022
|
|
4
|
+
"Bounds",
|
|
5
|
+
"ConstantDB",
|
|
6
|
+
"ConstraintDB",
|
|
7
|
+
"CreateSessionRequest",
|
|
8
|
+
"DiscreteRepresentationDB",
|
|
9
|
+
"EMOSaveState",
|
|
10
|
+
"EMOSolveRequest",
|
|
11
|
+
"EMOIterateState",
|
|
12
|
+
"ENautilusRepresentativeSolutionsResponse",
|
|
13
|
+
"ENautilusState",
|
|
14
|
+
"ENautilusStateResponse",
|
|
15
|
+
"ENautilusStepRequest",
|
|
16
|
+
"ENautilusStepResponse",
|
|
17
|
+
"ExtraFunctionDB",
|
|
18
|
+
"ForestProblemMetaData",
|
|
19
|
+
"GenericIntermediateSolutionResponse",
|
|
20
|
+
"GetSessionRequest",
|
|
21
|
+
"GNIMBUSOptimizationState",
|
|
22
|
+
"GNIMBUSVotingState",
|
|
23
|
+
"GNIMBUSEndState",
|
|
24
|
+
"InteractiveSessionBase",
|
|
25
|
+
"InteractiveSessionDB",
|
|
26
|
+
"InteractiveSessionInfo",
|
|
27
|
+
"IntermediateSolutionRequest",
|
|
28
|
+
"IntermediateSolutionResponse",
|
|
29
|
+
"IntermediateSolutionState",
|
|
30
|
+
"NIMBUSClassificationRequest",
|
|
31
|
+
"NIMBUSClassificationState",
|
|
32
|
+
"NIMBUSDeleteSaveRequest",
|
|
33
|
+
"NIMBUSDeleteSaveResponse",
|
|
34
|
+
"NIMBUSInitializationRequest",
|
|
35
|
+
"NIMBUSInitializationState",
|
|
36
|
+
"NIMBUSIntermediateSolutionResponse",
|
|
37
|
+
"NIMBUSSaveRequest",
|
|
38
|
+
"NIMBUSClassificationResponse",
|
|
39
|
+
"NIMBUSInitializationResponse",
|
|
40
|
+
"NIMBUSSaveResponse",
|
|
41
|
+
"NIMBUSFinalizeRequest",
|
|
42
|
+
"NIMBUSFinalizeResponse",
|
|
43
|
+
"NIMBUSFinalState",
|
|
44
|
+
"NIMBUSSaveState",
|
|
45
|
+
"NonPreferredSolutions",
|
|
46
|
+
"ObjectiveDB",
|
|
47
|
+
"PreferenceBase",
|
|
48
|
+
"PreferenceDB",
|
|
49
|
+
"PreferredSolutions",
|
|
50
|
+
"PreferredRanges",
|
|
51
|
+
"ProblemDB",
|
|
52
|
+
"ProblemAddFromJSONRequest",
|
|
53
|
+
"ProblemGetRequest",
|
|
54
|
+
"ProblemInfo",
|
|
55
|
+
"ProblemInfoSmall",
|
|
56
|
+
"ProblemMetaDataDB",
|
|
57
|
+
"ProblemMetaDataGetRequest",
|
|
58
|
+
"ProblemSelectSolverRequest",
|
|
59
|
+
"ReferencePoint",
|
|
60
|
+
"RepresentativeNonDominatedSolutions",
|
|
61
|
+
"RPMSolveRequest",
|
|
62
|
+
"RPMState",
|
|
63
|
+
"SavedSolutionReference",
|
|
64
|
+
"ScalarizationFunctionDB",
|
|
65
|
+
"SimulatorDB",
|
|
66
|
+
"State",
|
|
67
|
+
"StateDB",
|
|
68
|
+
"SolutionInfo",
|
|
69
|
+
"TensorConstantDB",
|
|
70
|
+
"TensorVariableDB",
|
|
71
|
+
"User",
|
|
72
|
+
"UserBase",
|
|
73
|
+
"UserPublic",
|
|
74
|
+
"UserRole",
|
|
75
|
+
"VariableDB",
|
|
76
|
+
"ProblemMetaDataDB",
|
|
77
|
+
"BaseProblemMetaData",
|
|
78
|
+
"ForestProblemMetaData",
|
|
79
|
+
"Group",
|
|
80
|
+
"GroupModifyRequest",
|
|
81
|
+
"GroupCreateRequest",
|
|
82
|
+
"GroupRevertRequest",
|
|
83
|
+
"GroupIteration",
|
|
84
|
+
"GroupPublic",
|
|
85
|
+
"GroupInfoRequest",
|
|
86
|
+
"BaseGroupInfoContainer",
|
|
87
|
+
"ReferencePointDictType",
|
|
88
|
+
"BooleanDictTypeDecorator",
|
|
89
|
+
"EMOSolveRequest",
|
|
90
|
+
"PreferredRanges",
|
|
91
|
+
"PreferedSolutions",
|
|
92
|
+
"NonPreferredSolutions",
|
|
93
|
+
"EMOFetchRequest",
|
|
94
|
+
"EMOFetchResponse",
|
|
95
|
+
"EMOIterateRequest",
|
|
96
|
+
"EMOIterateResponse",
|
|
97
|
+
"EMOSaveRequest",
|
|
98
|
+
"EMOScoreRequest",
|
|
99
|
+
"EMOScoreResponse",
|
|
100
|
+
"Solution",
|
|
101
|
+
"SolutionReference",
|
|
102
|
+
"SolutionReferenceLite",
|
|
103
|
+
"SolutionReferenceResponse",
|
|
104
|
+
"SolverSelectionMetadata",
|
|
105
|
+
"UserSavedEMOResults",
|
|
106
|
+
"UserSavedSolutionDB",
|
|
107
|
+
"UtopiaRequest",
|
|
108
|
+
"UtopiaResponse",
|
|
109
|
+
"VariableDB",
|
|
110
|
+
"ScoreBandsRequest",
|
|
111
|
+
"ScoreBandsResponse",
|
|
112
|
+
"OptimizationPreference",
|
|
113
|
+
"VotingPreference",
|
|
114
|
+
"EndProcessPreference",
|
|
115
|
+
"GNIMBUSResultResponse",
|
|
116
|
+
"FullIteration",
|
|
117
|
+
"GNIMBUSAllIterationsResponse",
|
|
118
|
+
"GNIMBUSSwitchPhaseRequest",
|
|
119
|
+
"GNIMBUSSwitchPhaseResponse",
|
|
120
|
+
"GDMScoreBandsInitializationRequest",
|
|
121
|
+
"GDMSCOREBandInformation",
|
|
122
|
+
"GDMSCOREBandsResponse",
|
|
123
|
+
"GDMScoreBandsVoteRequest",
|
|
124
|
+
"GDMSCOREBandFinalSelection",
|
|
125
|
+
"GDMSCOREBandsDecisionResponse",
|
|
126
|
+
"GDMSCOREBandsRevertRequest",
|
|
127
|
+
"GDMSCOREBandsHistoryResponse",
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
from .archive import UserSavedEMOResults
|
|
132
|
+
from .emo import (
|
|
133
|
+
EMOFetchRequest,
|
|
134
|
+
EMOFetchResponse,
|
|
135
|
+
EMOIterateRequest,
|
|
136
|
+
EMOIterateResponse,
|
|
137
|
+
EMOSaveRequest,
|
|
138
|
+
EMOScoreRequest,
|
|
139
|
+
EMOScoreResponse,
|
|
140
|
+
Solution,
|
|
141
|
+
)
|
|
142
|
+
from .enautilus import (
|
|
143
|
+
ENautilusRepresentativeSolutionsResponse,
|
|
144
|
+
ENautilusStateResponse,
|
|
145
|
+
ENautilusStepRequest,
|
|
146
|
+
ENautilusStepResponse,
|
|
147
|
+
)
|
|
148
|
+
from .gdm.gdm_aggregate import (
|
|
149
|
+
Group,
|
|
150
|
+
GroupCreateRequest,
|
|
151
|
+
GroupInfoRequest,
|
|
152
|
+
GroupIteration,
|
|
153
|
+
GroupModifyRequest,
|
|
154
|
+
GroupPublic,
|
|
155
|
+
GroupRevertRequest,
|
|
156
|
+
)
|
|
157
|
+
from .gdm.gdm_base import (
|
|
158
|
+
BaseGroupInfoContainer,
|
|
159
|
+
BooleanDictTypeDecorator,
|
|
160
|
+
ReferencePointDictType,
|
|
161
|
+
)
|
|
162
|
+
from .gdm.gdm_score_bands import (
|
|
163
|
+
GDMSCOREBandFinalSelection,
|
|
164
|
+
GDMSCOREBandInformation,
|
|
165
|
+
GDMSCOREBandsDecisionResponse,
|
|
166
|
+
GDMSCOREBandsHistoryResponse,
|
|
167
|
+
GDMScoreBandsInitializationRequest,
|
|
168
|
+
GDMSCOREBandsResponse,
|
|
169
|
+
GDMSCOREBandsRevertRequest,
|
|
170
|
+
GDMScoreBandsVoteRequest,
|
|
171
|
+
)
|
|
172
|
+
from .gdm.gnimbus import (
|
|
173
|
+
EndProcessPreference,
|
|
174
|
+
FullIteration,
|
|
175
|
+
GNIMBUSAllIterationsResponse,
|
|
176
|
+
GNIMBUSResultResponse,
|
|
177
|
+
GNIMBUSSwitchPhaseRequest,
|
|
178
|
+
GNIMBUSSwitchPhaseResponse,
|
|
179
|
+
OptimizationPreference,
|
|
180
|
+
VotingPreference,
|
|
181
|
+
)
|
|
182
|
+
from .generic import (
|
|
183
|
+
GenericIntermediateSolutionResponse,
|
|
184
|
+
IntermediateSolutionRequest,
|
|
185
|
+
ScoreBandsRequest,
|
|
186
|
+
ScoreBandsResponse,
|
|
187
|
+
SolutionInfo,
|
|
188
|
+
)
|
|
189
|
+
from .generic_states import (
|
|
190
|
+
SavedSolutionReference,
|
|
191
|
+
SolutionReference,
|
|
192
|
+
SolutionReferenceLite,
|
|
193
|
+
SolutionReferenceResponse,
|
|
194
|
+
State,
|
|
195
|
+
StateDB,
|
|
196
|
+
UserSavedSolutionDB,
|
|
197
|
+
)
|
|
198
|
+
from .nimbus import (
|
|
199
|
+
NIMBUSClassificationRequest,
|
|
200
|
+
NIMBUSClassificationResponse,
|
|
201
|
+
NIMBUSDeleteSaveRequest,
|
|
202
|
+
NIMBUSDeleteSaveResponse,
|
|
203
|
+
NIMBUSFinalizeRequest,
|
|
204
|
+
NIMBUSFinalizeResponse,
|
|
205
|
+
NIMBUSInitializationRequest,
|
|
206
|
+
NIMBUSInitializationResponse,
|
|
207
|
+
NIMBUSIntermediateSolutionResponse,
|
|
208
|
+
NIMBUSSaveRequest,
|
|
209
|
+
NIMBUSSaveResponse,
|
|
210
|
+
)
|
|
211
|
+
from .preference import (
|
|
212
|
+
Bounds,
|
|
213
|
+
NonPreferredSolutions,
|
|
214
|
+
PreferenceBase,
|
|
215
|
+
PreferenceDB,
|
|
216
|
+
PreferredRanges,
|
|
217
|
+
PreferredSolutions,
|
|
218
|
+
ReferencePoint,
|
|
219
|
+
)
|
|
220
|
+
from .problem import (
|
|
221
|
+
ConstantDB,
|
|
222
|
+
ConstraintDB,
|
|
223
|
+
DiscreteRepresentationDB,
|
|
224
|
+
ExtraFunctionDB,
|
|
225
|
+
ForestProblemMetaData,
|
|
226
|
+
ObjectiveDB,
|
|
227
|
+
ProblemAddFromJSONRequest,
|
|
228
|
+
ProblemDB,
|
|
229
|
+
ProblemGetRequest,
|
|
230
|
+
ProblemInfo,
|
|
231
|
+
ProblemInfoSmall,
|
|
232
|
+
ProblemMetaDataDB,
|
|
233
|
+
ProblemMetaDataGetRequest,
|
|
234
|
+
ProblemSelectSolverRequest,
|
|
235
|
+
RepresentativeNonDominatedSolutions,
|
|
236
|
+
ScalarizationFunctionDB,
|
|
237
|
+
SimulatorDB,
|
|
238
|
+
SolverSelectionMetadata,
|
|
239
|
+
TensorConstantDB,
|
|
240
|
+
TensorVariableDB,
|
|
241
|
+
VariableDB,
|
|
242
|
+
)
|
|
243
|
+
from .reference_point_method import RPMSolveRequest
|
|
244
|
+
from .session import (
|
|
245
|
+
CreateSessionRequest,
|
|
246
|
+
GetSessionRequest,
|
|
247
|
+
InteractiveSessionBase,
|
|
248
|
+
InteractiveSessionDB,
|
|
249
|
+
InteractiveSessionInfo,
|
|
250
|
+
)
|
|
251
|
+
from .state import (
|
|
252
|
+
EMOIterateState,
|
|
253
|
+
EMOSaveState,
|
|
254
|
+
ENautilusState,
|
|
255
|
+
GNIMBUSEndState,
|
|
256
|
+
GNIMBUSOptimizationState,
|
|
257
|
+
GNIMBUSVotingState,
|
|
258
|
+
IntermediateSolutionState,
|
|
259
|
+
NIMBUSClassificationState,
|
|
260
|
+
NIMBUSFinalState,
|
|
261
|
+
NIMBUSInitializationState,
|
|
262
|
+
NIMBUSSaveState,
|
|
263
|
+
RPMState,
|
|
264
|
+
)
|
|
265
|
+
from .user import User, UserBase, UserPublic, UserRole
|
|
266
|
+
from .utopia import UtopiaRequest, UtopiaResponse
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Defines models for archiving solutions."""
|
|
2
|
+
|
|
3
|
+
from sqlmodel import Field
|
|
4
|
+
|
|
5
|
+
from desdeo.tools.generics import EMOResult
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class UserSavedEMOResults(EMOResult):
|
|
9
|
+
"""Defines a schema for storing emo solutions."""
|
|
10
|
+
|
|
11
|
+
name: str | None = Field(
|
|
12
|
+
description="An optional name for the solution, useful for archiving purposes.",
|
|
13
|
+
default=None,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
def to_emo_results(self) -> EMOResult:
|
|
17
|
+
"""Convert to SolverResults without the name field."""
|
|
18
|
+
return EMOResult(
|
|
19
|
+
optimal_variables=self.optimal_variables,
|
|
20
|
+
optimal_objectives=self.optimal_objectives,
|
|
21
|
+
constraint_values=self.constraint_values,
|
|
22
|
+
extra_func_values=self.extra_func_values,
|
|
23
|
+
)
|
desdeo/api/models/emo.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""Models specific to the nimbus method."""
|
|
2
|
+
|
|
3
|
+
from pydantic import ConfigDict
|
|
4
|
+
from sqlmodel import JSON, Column, Field, SQLModel
|
|
5
|
+
|
|
6
|
+
from desdeo.emo.options.templates import PreferenceOptions, TemplateOptions
|
|
7
|
+
from desdeo.tools.score_bands import SCOREBandsConfig, SCOREBandsResult
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class EMOIterateRequest(SQLModel):
|
|
11
|
+
"""Model of the request to iterate an EMO method."""
|
|
12
|
+
|
|
13
|
+
model_config = ConfigDict(use_attribute_docstrings=True)
|
|
14
|
+
|
|
15
|
+
problem_id: int
|
|
16
|
+
"""Database ID of the problem to solve."""
|
|
17
|
+
session_id: int | None = Field(default=None)
|
|
18
|
+
parent_state_id: int | None = Field(default=None)
|
|
19
|
+
"""State ID of the parent state, if any. Should be None if this is the first state in a session."""
|
|
20
|
+
|
|
21
|
+
template_options: list[TemplateOptions] | None = Field(default=None)
|
|
22
|
+
"""Options for the template to use. A list of options can be given if multiple templates are used in parallel."""
|
|
23
|
+
preference_options: PreferenceOptions | None = Field(default=None)
|
|
24
|
+
"""Options for the preference handling."""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class EMOFetchRequest(SQLModel):
|
|
28
|
+
"""Model of the request to fetch solutions from an EMO method."""
|
|
29
|
+
|
|
30
|
+
model_config = ConfigDict(use_attribute_docstrings=True)
|
|
31
|
+
|
|
32
|
+
problem_id: int
|
|
33
|
+
"""Database ID of the problem to solve."""
|
|
34
|
+
session_id: int | None = Field(default=None)
|
|
35
|
+
parent_state_id: int | None = Field(default=None)
|
|
36
|
+
"""State ID of the parent state, if any. Should be None if this is the first state in a session."""
|
|
37
|
+
|
|
38
|
+
num_solutions: int = Field(default=0)
|
|
39
|
+
"""Number of solutions to fetch. If 0, fetch all solutions."""
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class EMOSaveRequest(SQLModel):
|
|
43
|
+
"""Request model for saving solutions from any method's state."""
|
|
44
|
+
|
|
45
|
+
model_config = ConfigDict(use_attribute_docstrings=True)
|
|
46
|
+
|
|
47
|
+
problem_id: int
|
|
48
|
+
"""Database ID of the problem to solve."""
|
|
49
|
+
session_id: int | None = Field(default=None)
|
|
50
|
+
parent_state_id: int | None = Field(default=None)
|
|
51
|
+
"""State ID of the parent state, if any. Should be None if this is the first state in a session."""
|
|
52
|
+
|
|
53
|
+
solution_ids: list[int] = Field()
|
|
54
|
+
"""List of solution IDs to save."""
|
|
55
|
+
solution_names: list[str | None] | None = Field(default=None)
|
|
56
|
+
"""List of names for the solutions to save. If None, no names are given."""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class EMOScoreRequest(SQLModel):
|
|
60
|
+
"""Request model for getting SCORE bands visualization data from state."""
|
|
61
|
+
|
|
62
|
+
model_config = ConfigDict(use_attribute_docstrings=True)
|
|
63
|
+
|
|
64
|
+
problem_id: int
|
|
65
|
+
"""Database ID of the problem to solve."""
|
|
66
|
+
session_id: int | None = Field(default=None)
|
|
67
|
+
parent_state_id: int | None = Field(default=None)
|
|
68
|
+
"""State ID of the parent state, if any."""
|
|
69
|
+
|
|
70
|
+
config: SCOREBandsConfig | None = Field(default=None)
|
|
71
|
+
"""Configuration for the SCORE bands visualization."""
|
|
72
|
+
|
|
73
|
+
solution_ids: list[int] = Field()
|
|
74
|
+
"""List of solution IDs to score."""
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class EMOIterateResponse(SQLModel):
|
|
78
|
+
"""Model of the response to an EMO iterate request."""
|
|
79
|
+
|
|
80
|
+
model_config = ConfigDict(use_attribute_docstrings=True)
|
|
81
|
+
|
|
82
|
+
method_ids: list[str]
|
|
83
|
+
"""IDs of the EMO methods using websockets to get/send updates."""
|
|
84
|
+
client_id: str
|
|
85
|
+
"""Client ID to use when connecting to the websockets."""
|
|
86
|
+
state_id: int
|
|
87
|
+
"""The state ID of the newly created state."""
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class Solution(SQLModel):
|
|
91
|
+
solution_id: int
|
|
92
|
+
"""ID of the solution"""
|
|
93
|
+
objective_values: dict[str, list[float]]
|
|
94
|
+
"""Values of the objectives. Each inner list corresponds to a solution."""
|
|
95
|
+
constraint_values: dict[str, list[float]] | None = None
|
|
96
|
+
"""Values of the constraints. Each inner list corresponds to a solution."""
|
|
97
|
+
variable_values: dict[str, list[float | int | bool]]
|
|
98
|
+
"""Values of the decision variables. Each inner list corresponds to a solution."""
|
|
99
|
+
extra_func_values: dict[str, list[float]] | None = None
|
|
100
|
+
"""Values of the extra functions. Each inner list corresponds to a solution."""
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class EMOFetchResponse(SQLModel):
|
|
104
|
+
"""Model of the response to an EMO fetch request."""
|
|
105
|
+
|
|
106
|
+
model_config = ConfigDict(use_attribute_docstrings=True)
|
|
107
|
+
|
|
108
|
+
state_id: int
|
|
109
|
+
"""The state ID of the newly created state."""
|
|
110
|
+
objective_values: dict[str, list[float]]
|
|
111
|
+
"""Values of the objectives. Each inner list corresponds to a solution."""
|
|
112
|
+
constraint_values: dict[str, list[float]] | None = None
|
|
113
|
+
"""Values of the constraints. Each inner list corresponds to a solution."""
|
|
114
|
+
variable_values: dict[str, list[float | int | bool]]
|
|
115
|
+
"""Values of the decision variables. Each inner list corresponds to a solution."""
|
|
116
|
+
extra_func_values: dict[str, list[float]] | None = None
|
|
117
|
+
"""Values of the extra functions. Each inner list corresponds to a solution."""
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class EMOScoreResponse(SQLModel):
|
|
121
|
+
"""Model of the response to an EMO score request."""
|
|
122
|
+
|
|
123
|
+
model_config = ConfigDict(use_attribute_docstrings=True)
|
|
124
|
+
|
|
125
|
+
state_id: int | None = Field(default=None)
|
|
126
|
+
"""The state ID of the newly created state."""
|
|
127
|
+
|
|
128
|
+
result: SCOREBandsResult
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Models specific to the E-NAUTILUS point method."""
|
|
2
|
+
|
|
3
|
+
from sqlmodel import JSON, Column, Field, SQLModel
|
|
4
|
+
|
|
5
|
+
from desdeo.tools import SolverResults
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ENautilusStepRequest(SQLModel):
|
|
9
|
+
"""Model of the request to the E-NAUTILUS method."""
|
|
10
|
+
|
|
11
|
+
problem_id: int
|
|
12
|
+
session_id: int | None = Field(default=None)
|
|
13
|
+
parent_state_id: int | None = Field(default=None)
|
|
14
|
+
# non_dominated points fetched from problem metadata in endpoints
|
|
15
|
+
representative_solutions_id: int = Field(description="The id of the representative solutions to be used.")
|
|
16
|
+
|
|
17
|
+
current_iteration: int = Field(description="The number of the current iteration.")
|
|
18
|
+
iterations_left: int = Field(description="The number of iterations left.")
|
|
19
|
+
selected_point: dict[str, float] | None = Field(
|
|
20
|
+
sa_column=Column(JSON),
|
|
21
|
+
description=(
|
|
22
|
+
"The selected intermediate point. If first iteration, set this to be the (approximated) nadir point. "
|
|
23
|
+
"If not set, then the point is assumed to be the nadir point of the current approximating set."
|
|
24
|
+
),
|
|
25
|
+
)
|
|
26
|
+
reachable_point_indices: list[int] = Field(
|
|
27
|
+
description=(
|
|
28
|
+
"The indices indicating the point on the non-dominated set that are "
|
|
29
|
+
"reachable from the currently selected point."
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
number_of_intermediate_points: int = Field(description="The number of intermediate points to be generated.")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ENautilusStepResponse(SQLModel):
|
|
36
|
+
"""The response from E-NAUTILUS step endpoint."""
|
|
37
|
+
|
|
38
|
+
state_id: int | None = Field(description="The id of the state created by the request that generated this response")
|
|
39
|
+
|
|
40
|
+
current_iteration: int = Field(description="Number of the current iteration.")
|
|
41
|
+
iterations_left: int = Field(description="Number of iterations left.")
|
|
42
|
+
intermediate_points: list[dict[str, float]] = Field(sa_column=Column(JSON), description="New intermediate points")
|
|
43
|
+
reachable_best_bounds: list[dict[str, float]] = Field(
|
|
44
|
+
sa_column=Column(JSON),
|
|
45
|
+
description="Best bounds of the objective function values reachable from each intermediate point.",
|
|
46
|
+
)
|
|
47
|
+
reachable_worst_bounds: list[dict[str, float]] = Field(
|
|
48
|
+
sa_column=Column(JSON),
|
|
49
|
+
description="Worst bounds of the objective function values reachable from each intermediate point.",
|
|
50
|
+
)
|
|
51
|
+
closeness_measures: list[float] = Field(description="Closeness measures of each intermediate point.")
|
|
52
|
+
reachable_point_indices: list[list[int]] = Field(
|
|
53
|
+
description="Indices of the reachable points from each intermediate point."
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class ENautilusStateResponse(SQLModel):
|
|
58
|
+
"""The response model when requesting a state in E-NAUTILUS."""
|
|
59
|
+
|
|
60
|
+
request: ENautilusStepRequest = Field(description="The original request for generating the state.")
|
|
61
|
+
response: ENautilusStepResponse = Field(description="The state generated by the request.")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class ENautilusRepresentativeSolutionsResponse(SQLModel):
|
|
65
|
+
"""Model of the response when requesting representative solutions from E-NAUTILUS."""
|
|
66
|
+
|
|
67
|
+
solutions: list[SolverResults] = Field(
|
|
68
|
+
description="The solutions on the non-dominated front closest to the intermediate points."
|
|
69
|
+
)
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""Classes for group decision making, aggregating all different types of data classes."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
from sqlalchemy.types import TypeDecorator
|
|
6
|
+
from sqlmodel import JSON, Column, Field, Relationship, SQLModel
|
|
7
|
+
|
|
8
|
+
from desdeo.api.models.gdm.gdm_base import BaseGroupInfoContainer
|
|
9
|
+
from desdeo.api.models.gdm.gdm_score_bands import GDMSCOREBandFinalSelection, GDMSCOREBandInformation
|
|
10
|
+
from desdeo.api.models.gdm.gnimbus import EndProcessPreference, OptimizationPreference, VotingPreference
|
|
11
|
+
from desdeo.tools import SolverResults
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PreferenceType(TypeDecorator):
|
|
15
|
+
"""A converter of Preference types."""
|
|
16
|
+
|
|
17
|
+
impl = JSON
|
|
18
|
+
|
|
19
|
+
# Serialize
|
|
20
|
+
def process_bind_param(self, value, dialect):
|
|
21
|
+
"""Turns a preference item into json."""
|
|
22
|
+
if isinstance(value, BaseGroupInfoContainer):
|
|
23
|
+
return value.model_dump_json()
|
|
24
|
+
return None
|
|
25
|
+
|
|
26
|
+
# Deserialize
|
|
27
|
+
def process_result_value(self, value, dialect):
|
|
28
|
+
"""And the other way around."""
|
|
29
|
+
jsoned = json.loads(value)
|
|
30
|
+
if jsoned is not None:
|
|
31
|
+
match jsoned["method"]:
|
|
32
|
+
case "voting":
|
|
33
|
+
return VotingPreference.model_validate(jsoned)
|
|
34
|
+
case "optimization":
|
|
35
|
+
return OptimizationPreference.model_validate(jsoned)
|
|
36
|
+
# As the different methods are implemented, add new types
|
|
37
|
+
case "end":
|
|
38
|
+
return EndProcessPreference.model_validate(jsoned)
|
|
39
|
+
case "gdm-score-bands":
|
|
40
|
+
return GDMSCOREBandInformation.model_validate(jsoned)
|
|
41
|
+
case "gdm-score-bands-final":
|
|
42
|
+
return GDMSCOREBandFinalSelection.model_validate(jsoned)
|
|
43
|
+
case _:
|
|
44
|
+
print(f"Unable to deserialize Preference with method {jsoned['method']}.")
|
|
45
|
+
return None
|
|
46
|
+
return None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class GroupBase(SQLModel):
|
|
50
|
+
"""Base class for group table model and group response model."""
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class Group(GroupBase, table=True):
|
|
54
|
+
"""Table model for Group."""
|
|
55
|
+
|
|
56
|
+
id: int | None = Field(primary_key=True, default=None)
|
|
57
|
+
name: str | None = Field(default=None)
|
|
58
|
+
|
|
59
|
+
owner_id: int | None = Field(foreign_key="user.id", default=None)
|
|
60
|
+
user_ids: list[int] | None = Field(sa_column=Column(JSON))
|
|
61
|
+
|
|
62
|
+
problem_id: int = Field(default=None)
|
|
63
|
+
|
|
64
|
+
"""The id of the head GroupIteration."""
|
|
65
|
+
head_iteration_id: int | None
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class GroupPublic(GroupBase):
|
|
69
|
+
"""Response model for Group."""
|
|
70
|
+
|
|
71
|
+
id: int
|
|
72
|
+
name: str
|
|
73
|
+
owner_id: int
|
|
74
|
+
user_ids: list[int]
|
|
75
|
+
problem_id: int
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class GroupIteration(SQLModel, table=True):
|
|
79
|
+
"""Table model for Group Iteration (we could extend this in various ways)."""
|
|
80
|
+
|
|
81
|
+
id: int | None = Field(primary_key=True, default=None)
|
|
82
|
+
problem_id: int | None = Field(default=None)
|
|
83
|
+
|
|
84
|
+
"""ID of the associated Group."""
|
|
85
|
+
group_id: int
|
|
86
|
+
|
|
87
|
+
"""The preferences are stored in this item while the iteration is in progress."""
|
|
88
|
+
info_container: BaseGroupInfoContainer = Field(sa_column=Column(PreferenceType))
|
|
89
|
+
# NOTE: This used to be called "preferences" and the class used to be called "BasePreference"
|
|
90
|
+
|
|
91
|
+
notified: dict[int, bool] = Field(sa_column=Column(JSON))
|
|
92
|
+
|
|
93
|
+
"""State for storing post optimization/voting related data (dec vars, objectives, etc.)"""
|
|
94
|
+
state_id: int | None = Field()
|
|
95
|
+
|
|
96
|
+
"""Linked list emerges."""
|
|
97
|
+
parent_id: int | None = Field(foreign_key="groupiteration.id", default=None)
|
|
98
|
+
parent: "GroupIteration" = Relationship(
|
|
99
|
+
back_populates="children", sa_relationship_kwargs={"remote_side": "GroupIteration.id"}
|
|
100
|
+
)
|
|
101
|
+
# If parent is removed, remove the child too
|
|
102
|
+
children: list["GroupIteration"] = Relationship(
|
|
103
|
+
back_populates="parent", sa_relationship_kwargs={"cascade": "all, delete-orphan"}
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class GroupInfoRequest(SQLModel):
|
|
108
|
+
"""Class for requesting group information."""
|
|
109
|
+
|
|
110
|
+
group_id: int
|
|
111
|
+
|
|
112
|
+
class GroupRevertRequest(SQLModel):
|
|
113
|
+
"""Class for requesting reverting to certain iteration."""
|
|
114
|
+
|
|
115
|
+
group_id: int = Field(description="The ID of the group we wish to revert.")
|
|
116
|
+
state_id: int = Field(
|
|
117
|
+
description="The state's ID to which we want to revert to. "\
|
|
118
|
+
"Corresponds to state_id in GroupIteration."
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class GroupResult(SQLModel):
|
|
123
|
+
"""Class for group's result."""
|
|
124
|
+
|
|
125
|
+
solver_results: list[SolverResults]
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class GroupModifyRequest(SQLModel):
|
|
129
|
+
"""Used for adding a user into group and removing a user from group."""
|
|
130
|
+
|
|
131
|
+
group_id: int
|
|
132
|
+
user_id: int
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class GroupCreateRequest(SQLModel):
|
|
136
|
+
"""Used for requesting a group to be created."""
|
|
137
|
+
|
|
138
|
+
group_name: str
|
|
139
|
+
problem_id: int
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Base classes for Group Decision Making. Here one can add some common data types for serialization."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
from pydantic import ValidationError
|
|
6
|
+
from sqlalchemy.types import TypeDecorator
|
|
7
|
+
from sqlmodel import JSON, SQLModel
|
|
8
|
+
|
|
9
|
+
from desdeo.api.models.preference import ReferencePoint
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ReferencePointDictType(TypeDecorator):
|
|
13
|
+
"""A converter for dict of int and preferences."""
|
|
14
|
+
|
|
15
|
+
impl = JSON
|
|
16
|
+
|
|
17
|
+
def process_bind_param(self, value, dialect):
|
|
18
|
+
"""Turns a reference point dict into json."""
|
|
19
|
+
if isinstance(value, dict):
|
|
20
|
+
for key, item in value.items():
|
|
21
|
+
if isinstance(item, ReferencePoint):
|
|
22
|
+
value[key] = item.model_dump_json()
|
|
23
|
+
return json.dumps(value)
|
|
24
|
+
return None
|
|
25
|
+
|
|
26
|
+
def process_result_value(self, value, dialect):
|
|
27
|
+
"""And the other way around."""
|
|
28
|
+
dictionary = json.loads(value)
|
|
29
|
+
for key, item in dictionary.items():
|
|
30
|
+
if item is None:
|
|
31
|
+
print("Something's wrong... Database has a NoneType entry.")
|
|
32
|
+
try:
|
|
33
|
+
dictionary[key] = ReferencePoint.model_validate(json.loads(item))
|
|
34
|
+
except ValidationError as e:
|
|
35
|
+
print(f"Validation error when deserializing PreferencePoint: {e}")
|
|
36
|
+
return dictionary
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class BooleanDictTypeDecorator(TypeDecorator):
|
|
40
|
+
"""A converter of bool into json, surprising that this needs to exists."""
|
|
41
|
+
|
|
42
|
+
impl = JSON
|
|
43
|
+
|
|
44
|
+
def process_bind_param(self, value, dialect):
|
|
45
|
+
"""Turns boolean dict to json."""
|
|
46
|
+
if isinstance(value, dict):
|
|
47
|
+
for key, item in value.items():
|
|
48
|
+
if isinstance(item, bool):
|
|
49
|
+
value[key] = json.dumps(item)
|
|
50
|
+
return json.dumps(value)
|
|
51
|
+
return None
|
|
52
|
+
|
|
53
|
+
def process_result_value(self, value, dialect):
|
|
54
|
+
"""And the other way around."""
|
|
55
|
+
dictionary = json.loads(value)
|
|
56
|
+
for key, item in dictionary.items():
|
|
57
|
+
if item is None:
|
|
58
|
+
print("Something's wrong... Database has a NoneType entry.")
|
|
59
|
+
try:
|
|
60
|
+
dictionary[key] = bool(item)
|
|
61
|
+
except Exception as e:
|
|
62
|
+
print(f"Validation error when deserializing boolean: {e}")
|
|
63
|
+
return dictionary
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class BaseGroupInfoContainer(SQLModel):
|
|
67
|
+
"""A base class for a method specific iteration information."""
|
|
68
|
+
|
|
69
|
+
method: str = "unset"
|