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

Add wrapper to MODAct problems #94

Merged
merged 1 commit into from
Sep 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/portfolio.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ <h4>Problems</h4>
<b>Constrained:</b>
CTP,
<a href="problems/constrained/dascmop.html">DASCMOP</a>,
<a href="problems/constrained/modact.html">MODAct</a>,
<a href="problems/constrained/mw.html">MW</a>,
CDTLZ
<br>
Expand Down
160 changes: 160 additions & 0 deletions doc/source/problems/constrained/modact.ipynb

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions doc/source/problems/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@
"|[MW13](constrained/mw.ipynb)|15|2|2||\n",
"|[MW14](constrained/mw.ipynb)|15|3|1||\n",
"|[SymPart](multi/sym_part.ipynb)|2|2|&nbsp;||\n",
"|[OmniTest](multi/omni_test.ipynb)|s|2|&nbsp;||"
"|[OmniTest](multi/omni_test.ipynb)|s|2|&nbsp;||\n",
"|[MODAct](constrained/modact.ipynb)|20|2-5|7-10|Real-world mechanical design problems|"
]
},
{
Expand Down Expand Up @@ -525,4 +526,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
11 changes: 11 additions & 0 deletions doc/source/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,14 @@ @inproceedings{sym_part
}



@article{modact,
title = {Realistic {{Constrained Multi}}-{{Objective Optimization Benchmark Problems}} from {{Design}}},
author = {Picard, Cyril and Schiffmann, J{\"u}rg},
year = {2020},
pages = {1--1},
issn = {1941-0026},
doi = {10.1109/TEVC.2020.3020046},
journal = {IEEE Transactions on Evolutionary Computation},
}

1 change: 1 addition & 0 deletions pymoo/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def get_problem_options():
('dascmop7', DASCMOP7),
('dascmop8', DASCMOP8),
('dascmop9', DASCMOP9),
('modact', MODAct),
('mw1', MW1),
('mw2', MW2),
('mw3', MW3),
Expand Down
1 change: 1 addition & 0 deletions pymoo/problems/multi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pymoo.problems.multi.ctp import *
from pymoo.problems.multi.dascmop import *
from pymoo.problems.multi.kursawe import *
from pymoo.problems.multi.modact import *
from pymoo.problems.multi.mw import *
from pymoo.problems.multi.osy import *
from pymoo.problems.multi.tnk import *
Expand Down
60 changes: 60 additions & 0 deletions pymoo/problems/multi/modact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import os

import numpy as np

from pymoo.model.problem import Problem
from pymoo.problems.util import load_pareto_front_from_file


class MODAct(Problem):
"""Multi-Objective Design of Actuators

MODAct is a framework for real-world constrained multi-objective optimization.
Refer to the python package https://github.com/epfl-lamd/modact from requirements.

Best-known Pareto fronts must be downloaded from here: https://doi.org/10.5281/zenodo.3824302

Parameters
----------

function: str or modact.problems
The name of the benchmark problem to use either as a string or the
problem object instance. Example values: cs1, cs3, ct2, ct4, cts3

References:
----------
C. Picard and J. Schiffmann, “Realistic Constrained Multi-Objective Optimization Benchmark Problems from Design,”
IEEE Transactions on Evolutionary Computation, pp. 1–1, 2020.
"""
def __init__(self, function, **kwargs):
import modact.problems as pb

if isinstance(function, pb.Problem):
self.fct = function
else:
self.fct = pb.get_problem(function)
lb, ub = self.fct.bounds()
n_var = len(lb)
n_obj = len(self.fct.weights)
n_constr = len(self.fct.c_weights)
xl = lb
xu = ub

self.weights = np.array(self.fct.weights)
self.c_weights = np.array(self.fct.c_weights)

super().__init__(n_var=n_var, n_obj=n_obj, n_constr=n_constr, xl=xl,
xu=xu, elementwise_evaluation=True, type_var=np.double,
**kwargs)

def _evaluate(self, x, out, *args, **kwargs):
f, g = self.fct(x)
out["F"] = np.array(f)*-1*self.weights
out["G"] = np.array(g)*self.c_weights

def _calc_pareto_front(self, *args, **kwargs):
"""Loads the corresponding PF if it exists"""
fname = f"{self.fct.name}_PF.dat"
F = load_pareto_front_from_file(os.path.join("modact", fname))
if F is not None:
return F*self.weights*-1