Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix to rebuild_platypus_population #276

Merged
merged 6 commits into from
Jun 14, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 21 additions & 3 deletions ema_workbench/em_framework/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ def epsilon_nondominated(results, epsilons, problem):
Returns
-------
DataFrame

Notes
-----
this is a platypus based alternative to pareto.py (https://github.com/matthewjwoodruff/pareto.py)
Expand Down Expand Up @@ -872,13 +873,30 @@ def rebuild_platypus_population(archive, problem):
list of platypus Solutions

"""

if len(archive.columns) != problem.nvars + problem.nobjs:
raise EMAError(
"the number of columsn in the archive don't match the expected"
" number of decision variables and objectives"
)
quaquel marked this conversation as resolved.
Show resolved Hide resolved

solutions = []
for row in archive.itertuples():
decision_variables = [getattr(row, attr) for attr in problem.parameter_names]
objectives = [getattr(row, attr) for attr in problem.outcome_names]
try:
decision_variables = [getattr(row, attr) for attr in problem.parameter_names]
except AttributeError as e:
raise EMAError("parameter name not found in archive")

try:
objectives = [getattr(row, attr) for attr in problem.outcome_names]
except AttributeError as e:
raise EMAError("outcome name not found in archive'")
quaquel marked this conversation as resolved.
Show resolved Hide resolved

solution = Solution(problem)
solution.variables = decision_variables
solution.variables = [
platypus_type.encode(value)
for platypus_type, value in zip(problem.types, decision_variables)
]
solution.objectives = objectives
solutions.append(solution)
return solutions
Expand Down