|
10 | 10 | # Implementation |
11 | 11 | # --------------------------------------------------------------------------------------------------------- |
12 | 12 |
|
| 13 | + |
13 | 14 | class Problem: |
14 | 15 | def __init__(self, |
15 | 16 | n_var=-1, |
@@ -92,11 +93,9 @@ def __init__(self, |
92 | 93 | self.exclude_from_serialization = exclude_from_serialization if exclude_from_serialization is not None else [] |
93 | 94 |
|
94 | 95 | # the loader for the pareto set (ps) |
95 | | - def calc_ps(*args, **kwargs): return at_least_2d_array(self._calc_pareto_set(*args, **kwargs)) |
96 | 96 | self._pareto_set = Cache(calc_ps, raise_exception=False) |
97 | 97 |
|
98 | 98 | # the loader for the pareto front (pf) |
99 | | - def calc_pf(*args, **kwargs): return at_least_2d_array(self._calc_pareto_front(*args, **kwargs)) |
100 | 99 | self._pareto_front = Cache(calc_pf, raise_exception=False) |
101 | 100 |
|
102 | 101 | self._ideal_point, self._nadir_point = None, None |
@@ -192,10 +191,10 @@ def ideal_point(self): |
192 | 191 | return self._ideal_point |
193 | 192 |
|
194 | 193 | def pareto_front(self, *args, **kwargs): |
195 | | - return self._pareto_front.exec(*args, **kwargs) |
| 194 | + return self._pareto_front.exec(self, *args, **kwargs) |
196 | 195 |
|
197 | 196 | def pareto_set(self, *args, **kwargs): |
198 | | - return self._pareto_set.exec(*args, **kwargs) |
| 197 | + return self._pareto_set.exec(self, *args, **kwargs) |
199 | 198 |
|
200 | 199 | @abstractmethod |
201 | 200 | def _evaluate(self, x, out, *args, **kwargs): |
@@ -241,6 +240,14 @@ def __getstate__(self): |
241 | 240 | return self.__dict__ |
242 | 241 |
|
243 | 242 |
|
| 243 | +def calc_ps(problem, *args, **kwargs): |
| 244 | + return at_least_2d_array(problem._calc_pareto_set(*args, **kwargs)) |
| 245 | + |
| 246 | + |
| 247 | +def calc_pf(problem, *args, **kwargs): |
| 248 | + return at_least_2d_array(problem._calc_pareto_front(*args, **kwargs)) |
| 249 | + |
| 250 | + |
244 | 251 | # --------------------------------------------------------------------------------------------------------- |
245 | 252 | # Elementwise Problem |
246 | 253 | # --------------------------------------------------------------------------------------------------------- |
|
0 commit comments