Class HeuristicAbstract<S extends HeuristicSolution<?>>

java.lang.Object
org.cloudsimplus.heuristics.HeuristicAbstract<S>
Type Parameters:
S - The class of solutions the heuristic will deal with. It starts with an initial solution (usually random, depending on each subclass implementation) and executes the search to find a satisfying solution (defined by a stop criteria).
All Implemented Interfaces:
Heuristic<S>
Direct Known Subclasses:
SimulatedAnnealingAbstract

public abstract class HeuristicAbstract<S extends HeuristicSolution<?>> extends Object implements Heuristic<S>
An abstract class for Heuristic implementations.
Since:
CloudSim Plus 1.0
Author:
Manoel Campos da Silva Filho
  • Constructor Details

    • HeuristicAbstract

      public HeuristicAbstract(@NonNull @NonNull ContinuousDistribution random, @NonNull @NonNull Class<S> solutionClass)
      Creates a heuristic.
      Parameters:
      random - a pseudo-random number generator
      solutionClass - reference to the generic class that will be used to instantiate heuristic solutions
  • Method Details

    • setSolveTime

      protected void setSolveTime(double solveTime)
      Sets the time taken to solve the heuristic.
      Parameters:
      solveTime - the time to set (in seconds)
    • updateSystemState

      protected abstract void updateSystemState()
      Updates the state of the system to keep looking for a suboptimal solution.
    • getRandomValue

      public int getRandomValue(int maxValue)
      Description copied from interface: Heuristic
      Gets a random number between 0 (inclusive) and maxValue (exclusive).
      Specified by:
      getRandomValue in interface Heuristic<S extends HeuristicSolution<?>>
      Parameters:
      maxValue - the max value to get a random number (exclusive)
      Returns:
      the random number
    • solve

      public S solve()
      Description copied from interface: Heuristic
      Starts the heuristic to find a suboptimal solution. After the method finishes, you can call the Heuristic.getBestSolutionSoFar() to get the final solution.
      Specified by:
      solve in interface Heuristic<S extends HeuristicSolution<?>>
      Returns:
      the final solution
      See Also:
    • setBestSolutionSoFar

      protected final void setBestSolutionSoFar(S solution)
      Sets a solution as the current one.
      Parameters:
      solution - the solution to set as the current one.
    • setNeighborSolution

      protected final void setNeighborSolution(S solution)
      Sets a solution as the neighbor one.
      Parameters:
      solution - the solution to set as the neighbor one.