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 sub-class implementation) and executes the solution search in order 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
  • Method Details

    • getSolveTime

      public double getSolveTime()
      Specified by:
      getSolveTime in interface Heuristic<S extends HeuristicSolution<?>>
      Returns:
      the time taken to finish the solution search (in seconds).
      See Also:
    • setSolveTime

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

      protected ContinuousDistribution getRandom()
      Returns:
      a random number generator
    • updateSystemState

      protected abstract void updateSystemState()
      Updates the state of the system in order 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:
    • getBestSolutionSoFar

      public S getBestSolutionSoFar()
      Specified by:
      getBestSolutionSoFar in interface Heuristic<S extends HeuristicSolution<?>>
      Returns:
      best solution found out up to now
    • getNeighborSolution

      public S getNeighborSolution()
      Specified by:
      getNeighborSolution in interface Heuristic<S extends HeuristicSolution<?>>
      Returns:
      latest neighbor solution created
      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.
    • getSearchesByIteration

      public int getSearchesByIteration()
      Gets the number of neighborhood searches by each iteration of the heuristic.
      Specified by:
      getSearchesByIteration in interface Heuristic<S extends HeuristicSolution<?>>
      Returns:
    • setSearchesByIteration

      public void setSearchesByIteration(int searches)
      Sets the number of neighborhood searches by each iteration of the heuristic.
      Specified by:
      setSearchesByIteration in interface Heuristic<S extends HeuristicSolution<?>>
      Parameters:
      searches - the number of neighborhood searches to set