Class SimulatedAnnealingAbstract<S extends HeuristicSolution<?>>

java.lang.Object
org.cloudsimplus.heuristics.HeuristicAbstract<S>
org.cloudsimplus.heuristics.SimulatedAnnealingAbstract<S>
Type Parameters:
S - the class of solutions the heuristic will deal with, starting with a random solution and execute the solution search in order to achieve a satisfying solution (defined by a stop criteria)
All Implemented Interfaces:
Heuristic<S>
Direct Known Subclasses:
CloudletToVmMappingSimulatedAnnealing

public abstract class SimulatedAnnealingAbstract<S extends HeuristicSolution<?>> extends HeuristicAbstract<S>
An abstract class for implementation of Simulated Annealing algorithms used to find a suboptimal solution for a problem defined by sub-classes of this one. The Simulated Annealing is a heuristic that starts with a random solution and iteratively generates a random neighbor solution that its fitness is assessed in order to reach a sub-optimal result. The algorithm try to avoid local maximums, randomly selecting worse solutions to get away from being stuck in these locals.

The algorithm basically works as follows:

  1. Starts generating a random solution as you wish;
  2. Computes its fitness using some function (defined by the developer implementing the heuristic);
  3. Generates a neighbor random solution from the current solution and computes its fitness;
  4. Assesses the neighbor and current solution (the conditions below are ensured by the getAcceptanceProbability() method):
    • if neighbor.getFitness() > current.getFitness() then move to the new solution;
    • if neighbor.getFitness() < current.getFitness() then randomly decide if move to the new solution;
  5. Repeat steps 3 to 4 until an acceptable solution is found or some number of iterations or time is reached. These conditions are defined by the developer implementing the heuristic.

Since:
CloudSim Plus 1.0
Author:
Manoel Campos da Silva Filho
See Also:
  • Method Details

    • getAcceptanceProbability

      public double getAcceptanceProbability()
      Computes the acceptance probability to define if a neighbor solution has to be accepted or not, compared to the Heuristic.getBestSolutionSoFar().

      It is used the Boltzmann distribution to define the probability of a worse solution (considering its cost) to be accepted or not in order to avoid local minima. The computed Boltzmann factor also ensures that better solutions are always accepted. The Boltzmann Constant has different values depending of the used unit. In this case, it was used the natural unit of information.

      Returns:
      the acceptance probability, in scale from [0 to 1] where: 0 is to maintain the current solution; 1 is to accept the neighbor solution; intermediate values defines the probability that the neighbor solution will be randomly accepted.
      See Also:
    • isToStopSearch

      public boolean isToStopSearch()
      Checks if the solution search can be stopped.
      Returns:
      true if the system is cold enough and solution search can be stopped, false otherwise
    • updateSystemState

      public void updateSystemState()
      Updates the state of the system in order to keep looking for a suboptimal solution. Cools the system at a defined cooling rate.
      Specified by:
      updateSystemState in class HeuristicAbstract<S extends HeuristicSolution<?>>
      See Also:
    • getCurrentTemperature

      public double getCurrentTemperature()
      Gets the current system temperature that represents the system state at the time of the method call.
      Returns:
      the current system temperature
    • setCurrentTemperature

      protected void setCurrentTemperature(double currentTemperature)
      Sets the current system temperature.
      Parameters:
      currentTemperature - the temperature to set
    • getCoolingRate

      public double getCoolingRate()
      Returns:
      percentage rate in which the system will be cooled, in scale from [0 to 1[.
    • setCoolingRate

      public void setCoolingRate(double coolingRate)
      Sets the percentage rate in which the system will be cooled, in scale from [0 to 1[.
      Parameters:
      coolingRate - the rate to set
    • getColdTemperature

      public double getColdTemperature()
      Returns:
      the temperature that defines the system is cold enough and solution search may be stopped.
    • setColdTemperature

      public void setColdTemperature(double coldTemperature)
      Sets the temperature that defines the system is cold enough and solution search may be stopped.
      Parameters:
      coldTemperature - the cold temperature to set