A library for solving optimization problems by simulated annealing, based on pathfinder's original implementation.
Using jitpack.io
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.kochab</groupId>
<artifactId>simulatedannealing</artifactId>
<version>0.0.19</version>
</dependency>
You will need to implement the SearchState<T>
interface. It defines only one method, T step()
, which should return a randomly chosen perturbation of the current state. Also, you will need to implement the Problem<T>
interface, which initializes a state and evaluates the energey of states.
You will need to choose a Scheduler
implementation, which determines the speed and shape of the annealing process. We provide two built-in options, LinearDecayScheduler
and ExponentialDecayScheduler
.
Finally, just create a Solver
and call solve!
Scheduler scheduler = new LinearDecayScheduler(INITIAL_TEMPERATURE, NUMBER_OF_STEPS);
Problem<VRPSearchState> problem = new VehicleRoutingProblem(...);
Solver<VRPSearchState> solver = new Solver(problem, scheduler);
VRPSearchState solution = solver.solve();
See kochab/simulatedannealing-examples for a simple demo program that uses simulated annealing to solve a graphical optimization problem (minimizing adjacent difference between pixels).
MIT.