Skip to content

Commit

Permalink
Merge pull request #48 from industrial-optimization-group/bshavazipou…
Browse files Browse the repository at this point in the history
…r-new-ASFs-used-in-KneeOA-DSS
  • Loading branch information
light-weaver authored Sep 25, 2023
2 parents df4a421 + 9115876 commit 9211e6d
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions desdeo_tools/scalarization/ASF.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,106 @@ def __call__(self, objective_vectors: np.ndarray, reference_point: np.ndarray):
max_term = np.max((f - nad) / (nad - z), axis=1)

return max_term


Check failure on line 389 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L389

Blank line contains whitespace (W293)
class AspResASF(ASFBase):
"""Implementation of an ASF using both aspiration and reservation levels.
directly consider both upper and lower bounds of the preferred ranges within the solution

Check failure on line 392 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L392

Trailing whitespace (W291)
generation process, the variant of ASF utilizing both aspirations and reservations levels.

Check failure on line 393 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L393

Trailing whitespace (W291)
Originally proposed by Wierzbicki (1986), and also used in the PIE method (Sindhya et al. (2011)).

Check failure on line 395 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L395

Blank line contains whitespace (W293)
Args:
nadir (np.ndarray): The nadir point.
ideal (np.ndarray): The ideal point.
rho A small number to form the utopian point.
rho_sum (float): A small number to be used as a weight for the sum term.
alpha (float): An extricly positive number.
beta(float): An extricly positive number.

Check failure on line 403 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L403

Blank line contains whitespace (W293)
References:
Wierzbicki, A. P.
On the completeness and constructiveness of parametric characterizations to vector optimization

Check failure on line 406 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L406

Trailing whitespace (W291)
problems,

Check failure on line 407 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L407

Trailing whitespace (W291)
OR Spektrum, 1986, 8(2), 73–87.

Check failure on line 409 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L409

Blank line contains whitespace (W293)
Sindhya, K., Ruiz, A. B. and Miettinen, K.
A preference based interactive evolutionary algorithm for multi-objective optimization: PIE
in H. Takahashi, K. Deb, E. Wanner and S. Greco, eds, ‘Evolutionary Multi-Criterion Optimization:

Check failure on line 412 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L412

Trailing whitespace (W291)
6th International Conference’, Proceedings, Springer-Verlag, Berlin, Heidelberg, 2011, pp. 212–225.
"""

def __init__(self, nadir: np.ndarray, ideal: np.ndarray, rho: float = 1e-6, rho_sum: float = 1e-6,
alpha: float = 1e-1, beta: float = 1e-1,):

Check failure on line 417 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L417

Continuation line under-indented for visual indent (E128)
self.nadir = nadir
self.ideal = ideal
self.rho = rho
self.rho_sum = rho_sum
self.alpha = alpha
self.beta = beta

def __call__(self, objective_vectors: np.ndarray, reference_point: np.ndarray, reservation_point: np.ndarray):
# assure this function works with single objective vectors
if objective_vectors.ndim == 1:
f = objective_vectors.reshape((1, -1))
else:
f = objective_vectors

z = reference_point
r = reservation_point - self.rho
nad = self.nadir
ide = self.ideal
uto = self.ideal - self.rho
phi = np.zeros((objective_vectors.ndim,))

Check failure on line 438 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L438

Blank line contains whitespace (W293)
for i in range(objective_vectors.ndim):
if ide[i] <= f[0][i] <= z[i]:
phi[i] = -1 + self.alpha * (1/(z-uto))[i] * (f[0][i] - z[i])

Check failure on line 442 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L442

Blank line contains whitespace (W293)
if z[i] <= f[0][i] <= r[i]:
phi[i] = (1/(r-z))[i] * (f[0][i] - r[i])

Check failure on line 445 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L445

Blank line contains whitespace (W293)
if r[i] <= f[0][i] <= nad[i]:
phi[i] = self.beta * (1/(nad-r))[i] * (f[0][i] - r[i])

Check failure on line 448 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L448

Blank line contains whitespace (W293)

Check failure on line 449 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L449

Blank line contains whitespace (W293)
max_term = np.array([np.max(phi)])

Check failure on line 450 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L450

Too many blank lines (2) (E303)
sum_term = np.array([self.rho_sum * np.sum(phi)])

return max_term + sum_term


Check failure on line 455 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L455

Blank line contains whitespace (W293)
class STEM(ASFBase):
"""Implementation of the Step Method (STEM).

Check failure on line 458 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L458

Blank line contains whitespace (W293)
Args:
nadir (np.ndarray): The nadir point.
ideal (np.ndarray): The ideal point.
rho A small number to form the utopian point.

Check failure on line 463 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L463

Blank line contains whitespace (W293)
References:
Benayoun, R., De Montgolfier, J., Tergny, J. and Laritchev, O.
Linear programming with multiple objective functions: Step method (STEM)’,

Check failure on line 466 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L466

Trailing whitespace (W291)
Mathematical programming, 1971, 1(1), 366–375.
"""

def __init__(self, nadir: np.ndarray, ideal: np.ndarray, rho: float = 1e-6):
self.nadir = nadir
self.ideal = ideal
self.rho = rho

def __call__(self, objective_vectors: np.ndarray):
# assure this function works with single objective vectors
if objective_vectors.ndim == 1:
f = objective_vectors.reshape((1, -1))
else:
f = objective_vectors

nad = self.nadir
uto = self.ideal - self.rho
phi = np.zeros((objective_vectors.ndim,))

Check failure on line 485 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L485

Local variable 'phi' is assigned to but never used (F841)

Check failure on line 485 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Run linters

Ruff (F841)

desdeo_tools/scalarization/ASF.py:485:9: F841 Local variable `phi` is assigned to but never used
e = abs(nad-uto)/np.max((nad, uto), axis=0)

Check failure on line 486 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L486

Trailing whitespace (W291)

Check failure on line 487 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L487

Blank line contains whitespace (W293)
max_term = np.array([(e/e.sum() * (f - uto)).max()])

return max_term

Check failure on line 490 in desdeo_tools/scalarization/ASF.py

View workflow job for this annotation

GitHub Actions / Flake8

desdeo_tools/scalarization/ASF.py#L490

Trailing whitespace (W291)

0 comments on commit 9211e6d

Please sign in to comment.