Package edu.wpi.first.math.optimization
Class SimulatedAnnealing<State>
java.lang.Object
edu.wpi.first.math.optimization.SimulatedAnnealing<State>
- Type Parameters:
State
- The type of the state to optimize.
public final class SimulatedAnnealing<State> extends Object
An implementation of the Simulated Annealing stochastic nonlinear optimization method.
-
Constructor Summary
Constructors Constructor Description SimulatedAnnealing(double initialTemperature, Function<State,State> neighbor, ToDoubleFunction<State> cost)
Constructor for Simulated Annealing that can be used for the same functions but with different initial states. -
Method Summary
-
Constructor Details
-
SimulatedAnnealing
public SimulatedAnnealing(double initialTemperature, Function<State,State> neighbor, ToDoubleFunction<State> cost)Constructor for Simulated Annealing that can be used for the same functions but with different initial states.- Parameters:
initialTemperature
- The initial temperature. Higher temperatures make it more likely a worse state will be accepted during iteration, helping to avoid local minima. The temperature is decreased over time.neighbor
- Function that generates a random neighbor of the current state.cost
- Function that returns the scalar cost of a state.
-
-
Method Details
-
solve
Runs the Simulated Annealing algorithm.- Parameters:
initialGuess
- The initial state.iterations
- Number of iterations to run the solver.- Returns:
- The optimized stater.
-