:py:mod:`desdeo_mcdm.interactive.ReferencePointMethod`
======================================================

.. py:module:: desdeo_mcdm.interactive.ReferencePointMethod


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   desdeo_mcdm.interactive.ReferencePointMethod.RPMInitialRequest
   desdeo_mcdm.interactive.ReferencePointMethod.RPMRequest
   desdeo_mcdm.interactive.ReferencePointMethod.RPMStopRequest
   desdeo_mcdm.interactive.ReferencePointMethod.ReferencePointMethod



Functions
~~~~~~~~~

.. autoapisummary::

   desdeo_mcdm.interactive.ReferencePointMethod.validate_reference_point
   desdeo_mcdm.interactive.ReferencePointMethod.f1



.. py:exception:: RPMException

   Bases: :py:obj:`Exception`

   Raised when an exception related to Reference Point Method (RFM) is encountered.


.. py:function:: validate_reference_point(ref_point: numpy.ndarray, ideal: numpy.ndarray, nadir: numpy.ndarray) -> None

   Validate Decion maker's reference point.

   :param ref_point: Reference point.
   :type ref_point: np.ndarray
   :param ideal: Ideal vector.
   :type ideal: np.ndarray
   :param nadir: Nadir vector.
   :type nadir: np.ndarray

   :raises RPMException: In case reference point is invalid.


.. py:class:: RPMInitialRequest(ideal: numpy.ndarray, nadir: numpy.ndarray)

   Bases: :py:obj:`desdeo_tools.interaction.request.BaseRequest`

   A request class to handle the Decision Maker's initial preferences for the first iteration round.

   .. py:method:: init_with_method(method: desdeo_mcdm.interactive.InteractiveMethod.InteractiveMethod)
      :classmethod:

      Initialize request with given instance of ReferencePointMethod.

      :param method: Instance of ReferencePointMethod-class.
      :type method: ReferencePointMethod

      :returns: Initial request.
      :rtype: RPMInitialRequest



.. py:class:: RPMRequest(f_current: numpy.ndarray, f_additionals: numpy.ndarray, ideal: numpy.ndarray, nadir: numpy.ndarray)

   Bases: :py:obj:`desdeo_tools.interaction.request.BaseRequest`

   A request class to handle the Decision Maker's preferences after the first iteration round.

   :param f_current: Current solution.
   :type f_current: np.ndarray
   :param f_additionals: Additional solutions.
   :type f_additionals: np.ndarray
   :param ideal: Idea vector.
   :type ideal: np.ndarray
   :param nadir: Nadir vector.
   :type nadir: np.ndarray


.. py:class:: RPMStopRequest(x_h: numpy.ndarray, f_h: numpy.ndarray)

   Bases: :py:obj:`desdeo_tools.interaction.request.BaseRequest`

   A request class to handle termination.


.. py:class:: ReferencePointMethod(problem: Union[desdeo_problem.problem.MOProblem, desdeo_problem.problem.DiscreteDataProblem], ideal: numpy.ndarray, nadir: numpy.ndarray, epsilon: float = 1e-06, objective_names: Optional[List[str]] = None, minimize: Optional[List[int]] = None)

   Bases: :py:obj:`desdeo_mcdm.interactive.InteractiveMethod.InteractiveMethod`

   Implements the Reference Point Method as presented in |Wierzbicki_1982|.

   In the Reference Point Method, the Decision Maker (DM) specifies **desirable aspiration levels** for objective
   functions. Vectors formed of these aspiration levels are then used to derive scalarizing functions having minimal
   values at weakly, properly or Pareto optimal solutions. It is important that reference points are intuitive and easy
   for the DM to specify, their consistency is not an essential requirement. Before the solution process starts, some
   information is given to the DM about the problem. If possible, the ideal objective vector and the
   (approximated) nadir objective vector are presented.

   At each iteration, the DM is asked to give desired aspiration levels for the objective functions. Using this
   information to formulate a **reference point**, achievement function is minimized and a (weakly, properly or) Pareto
   optimal solution is obtained. This solution is then presented to the DM. In addition, k other (weakly,
   properly or) Pareto optimal solutions are calculated using **perturbed reference points**, where k is the
   number of objectives in the problem. The alternative solutions are also presented to the DM. If (s)he finds any of
   the k + 1 solutions satisfactory, the solution process is ended. Otherwise, the DM is asked to present a new
   reference point and the iteration described above is repeated.

   The idea in perturbed reference points is that the DM gets **better understanding** of the possible solutions around
   the current solution. If the reference point is far from the Pareto optimal set, the DM gets a **wider** description
   of the Pareto optimal set and if the reference point is near the Pareto optimal set, then a **finer** description of
   the Pareto optimal set is given.

   In this method, the DM has to specify aspiration levels and compare objective vectors. The DM is **free to change**
   her/his mind during the process and can direct the solution process without being forced to understand complicated
   concepts and their meaning. On the other hand, the method does not necessarily help the DM to find more satisfactory
   solutions.

   :param problem: Problem to be solved.
   :type problem: MOProblem
   :param ideal: The ideal objective vector of the problem.
   :type ideal: np.ndarray
   :param nadir: The nadir objective vector of the problem. This may also be the "worst" objective vector
                 provided by the Decision Maker if the approximation of Nadir vector is not applicable or if
                 the Decision Maker wishes to provide even worse objective vector than what the
                 approximated Nadir vector is.
   :type nadir: np.ndarray
   :param epsilon: A small number used in calculating the utopian point.
   :type epsilon: float
   :param epsilon: A small number used in calculating the utopian point. Default value is 1e-6.
   :type epsilon: float
   :param objective_names: Names of the objectives. The length of the list must match the
                           number of elements in ideal vector.
   :type objective_names: Optional[List[str]], optional
   :param minimize: Multipliers for each objective. '-1' indicates maximization
                    and '1' minimization. Defaults to all objective values being
                    minimized.
   :type minimize: Optional[List[int]], optional

   :raises RPMException: Dimensions of ideal, nadir, objective_names, and minimize-list do not match.

   .. py:method:: start() -> RPMInitialRequest

      Start the solution process with initializing the first request.

      :returns: Initial request.
      :rtype: RPMInitialRequest


   .. py:method:: iterate(request: Union[RPMInitialRequest, RPMRequest, RPMStopRequest]) -> Union[RPMRequest, RPMStopRequest]

      Perform the next logical iteration step based on the given request type.

      :param request: Either initial or intermediate request.
      :type request: Union[RPMInitialRequest, RPMRequest]

      :returns: A new request with content depending on the Decision Maker's
                preferences.
      :rtype: Union[RPMRequest, RPMStopRequest]


   .. py:method:: handle_initial_request(request: RPMInitialRequest) -> RPMRequest

      Handles the initial request by parsing the response appropriately.

      :param request: Initial request including the Decision Maker's initial preferences.
      :type request: RPMInitialRequest

      :returns: New request with updated solution process information.
      :rtype: RPMRequest


   .. py:method:: handle_request(request: RPMRequest) -> Union[RPMRequest, RPMStopRequest]

      Handle the Decision Maker's requests after the first iteration round, so-called **intermediate requests.**

      :param request: Intermediate request including the Decision Maker's response.
      :type request: RPMRequest

      :returns: In case last iteration, request to stop the solution process.
                Otherwise, new request with updated solution process information.
      :rtype: Union[RPMRequest, RPMStopRequest]


   .. py:method:: calculate_prp(ref_point: numpy.ndarray, f_current: numpy.ndarray) -> numpy.ndarray

      Calculate perturbed reference points.

      :param ref_point: Current reference point.
      :type ref_point: np.ndarray
      :param f_current: Current solution.
      :type f_current: np.ndarray

      :returns: Perturbed reference points.
      :rtype: np.ndarray


   .. py:method:: solve_asf(ref_point: numpy.ndarray, x0: numpy.ndarray, preferential_factors: numpy.ndarray, nadir: numpy.ndarray, utopian: numpy.ndarray, objectives: Callable, variable_vectors: Optional[numpy.ndarray] = None, variable_bounds: Optional[numpy.ndarray] = None, method: Union[desdeo_tools.solver.ScalarSolver.ScalarMethod, str, None] = None) -> dict

      Solve Achievement scalarizing function.

      :param ref_point: Reference point.
      :type ref_point: np.ndarray
      :param x0: Initial values for decision variables.
      :type x0: np.ndarray
      :param preferential_factors: Preferential factors on how much would the Decision Maker wish to improve
                                   the values of each objective function.
      :type preferential_factors: np.ndarray
      :param nadir: Nadir vector.
      :type nadir: np.ndarray
      :param utopian: Utopian vector.
      :type utopian: np.ndarray
      :param objectives: The objective function values for each input vector.
      :type objectives: np.ndarray
      :param variable_bounds: Lower and upper bounds of each variable
                              as a 2D numpy array. If undefined variables, None instead.
      :type variable_bounds: Optional[np.ndarray
      :param method: The optimization method the scalarizer should be minimized with.
      :type method: Union[ScalarMethod, str, None]

      :returns: A dictionary with at least the following entries: 'x' indicating the optimal variables found,
                'fun' the optimal value of the optimized function, and 'success' a boolean indicating whether
                the optimization was conducted successfully.
      :rtype: dict



.. py:function:: f1(xs)


