import numpy as np
from desdeo.method.base import InteractiveMethod
from .base import Direction, ReferencePoint
[docs]class PercentageSpecifictation(Direction):
[docs] def __init__(self, method: InteractiveMethod, percentages: np.ndarray) -> None:
super().__init__(method)
self.pref_input = percentages
[docs] def _weights(self) -> np.ndarray:
return np.array(self.pref_input) / 100.
[docs]class RelativeRanking(Direction):
[docs] def __init__(self, method: InteractiveMethod, ranking) -> None:
super().__init__(method)
self.pref_input = ranking
[docs] def _weights(self) -> np.ndarray:
return 1. / np.array(self.pref_input)
[docs]class PairwiseRanking(Direction):
[docs] def __init__(self, method: InteractiveMethod, selected_obj, other_ranking) -> None:
super().__init__(method)
self.pref_input = (selected_obj, other_ranking)
[docs] def _weights(self) -> np.ndarray:
ranks = self.pref_input[1]
fi = self.pref_input[0]
ranks[:fi] + [1.0] + ranks[fi:]
return np.array(ranks)
[docs]class DirectSpecification(Direction, ReferencePoint):
[docs] def __init__(
self, method: InteractiveMethod, direction: np.ndarray, reference_point=None
) -> None:
super().__init__(method, **{"reference_point": reference_point})
self.pref_input = direction
[docs] def _weights(self) -> np.ndarray:
return self.pref_input
[docs] def reference_point(self) -> np.ndarray:
return self.weights()