Class Objective<M extends Move<S,I>,S extends Solution<S,I>,I extends Instance>

java.lang.Object
es.urjc.etsii.grafo.solution.Objective<M,S,I>
Type Parameters:
S - Solution class
I - Instance class
Direct Known Subclasses:
Objective.SimpleObjective

public abstract class Objective<M extends Move<S,I>,S extends Solution<S,I>,I extends Instance> extends Object
Represents an objective function to be optimized for a given problem. In general, an objective function is a function that takes a solution and returns a double value representing the quality of the solution. In this class, we also include a method to evaluate the quality of a move, which is the difference or delta in the objective function value between the solution before applying the move and the solution after applying the move. Objective functions can be of two types: MINIMIZE or MAXIMIZE. It is important to correctly set the type of the objective function, as it will affect the behavior of the algorithms. In single objective optimization, usually there is a single objective to optimize. However, sometimes it can be useful to use secondary functions, for example when the solution landscape is flat. Usage of objectives is left to the user discretion. In multi-objective optimization, of course there are multiple objective functions.
  • Constructor Details

    • Objective

      public Objective()
  • Method Details

    • ofMinimizing

      public static <M extends Move<S, I>, S extends Solution<S, I>, I extends Instance> Objective<M,S,I> ofMinimizing(String name, ToDoubleFunction<S> evaluateSolution, ToDoubleFunction<M> evaluateMove)
    • ofMaximizing

      public static <M extends Move<S, I>, S extends Solution<S, I>, I extends Instance> Objective<M,S,I> ofMaximizing(String name, ToDoubleFunction<S> evaluateSolution, ToDoubleFunction<M> evaluateMove)
    • of

      public static <M extends Move<S, I>, S extends Solution<S, I>, I extends Instance> Objective<M,S,I> of(String name, FMode fMode, ToDoubleFunction<S> evaluateSolution, ToDoubleFunction<M> evaluateMove)
    • evalSol

      public abstract double evalSol(S solution)
    • evalMove

      public abstract double evalMove(M move)
    • getFMode

      public abstract FMode getFMode()
    • getName

      public abstract String getName()
    • isBetterOrEquals

      public boolean isBetterOrEquals(S a, double b)
    • isBetterOrEqual

      public boolean isBetterOrEqual(S a, S b)
    • isBetterOrEqual

      public boolean isBetterOrEqual(double a, double b)
    • isBetter

      public boolean isBetter(S a, double b)
    • isBetter

      public boolean isBetter(S a, S b)
    • isBetter

      public boolean isBetter(double a, double b)
    • getBadValue

      public double getBadValue()
    • improves

      public boolean improves(double a)
    • comparator

      public Comparator<S> comparator()
      Comparator that orders solutions by quality
      Returns:
      a comparator that sorts solutions from best to worse
    • comparatorMove

      public Comparator<? super Move<S,I>> comparatorMove()
      Comparator that orders moves by quality
      Returns:
      a comparator that sorts moves from best to worse
    • bestSolution

      public S bestSolution(Iterable<S> list)
    • bestMove

      public M bestMove(Iterable<M> list)
    • best

      public double best(double a, double b)
    • bestMove

      public M bestMove(M m1, M m2)
    • bestSolution

      public S bestSolution(S s1, S s2)