MinLCA algorithms
|
Generic simulated annealing algorithm. More...
#include <simulated-annealing.hh>
Public Member Functions | |
SimulatedAnnealing (int steps, int stIter, int k, double lambda, int seed=0) | |
Constructor with seed. More... | |
SimulatedAnnealing (int maxSteps, int stIter, int k, double lambda, Random &r) | |
Constructor using pre-built random number generator. More... | |
~SimulatedAnnealing () | |
Default destructor. More... | |
void | init (Node *start) |
Initialiser for the class. More... | |
virtual double | temperature () const |
Returns the current temperature. More... | |
Node * | run () |
Run the algorithm. More... | |
Node * | best () |
Get the best node. More... | |
Protected Types | |
typedef lemon::Random | Random |
Protected Member Functions | |
void | runStep () |
Run a single step. More... | |
Protected Attributes | |
Node * | _current |
Current node. | |
Node * | _best |
int | _steps |
Total steps done. | |
int | _max_steps |
Maximum number of steps. | |
int | _stiter |
Steps per iteration. | |
int | _k |
Coefficient for the temperature. | |
double | _lambda |
Coefficient in the exponent of the temperature. | |
bool | _delete_random |
Delete the random number generator in destructor. | |
Random * | _r |
Pointer to random number generator. | |
Generic simulated annealing algorithm.
Definition at line 17 of file simulated-annealing.hh.
|
inline |
Constructor with seed.
Constructor for the class requesting an initial seed for the random number generator.
[in] | steps | Maximum number of steps |
[in] | stIter | Number of steps per iteration group |
[in] | k | Coefficient for temperature function |
[in] | lambda | Factor in the exponent of the temperature |
[in] | seed | Seed for the random number generator |
Definition at line 89 of file simulated-annealing.hh.
|
inline |
Constructor using pre-built random number generator.
Constructor for the class requiring an existing random number generator.
[in] | maxSteps | Maximum number of steps |
[in] | stIter | Number of steps per iteration group |
[in] | k | Coefficient for temperature function |
[in] | lambda | Factor in the exponent of the temperature |
[in] | r | Already initialised random number generator |
Definition at line 106 of file simulated-annealing.hh.
|
inline |
Default destructor.
This destructor takes care of deleting the random number generator if it was not given by the user.
Definition at line 127 of file simulated-annealing.hh.
|
inline |
Get the best node.
Returns the best node found, the same obtained after executing run().
Definition at line 203 of file simulated-annealing.hh.
|
inline |
Initialiser for the class.
Resets the status of the search and sets the initial node to start
.
start | Initial node for the search |
Definition at line 146 of file simulated-annealing.hh.
|
inline |
Run the algorithm.
Runs the whole search. Needs to have the initial search node set by using function SimulatedAnnealing::init(Node*).
Definition at line 178 of file simulated-annealing.hh.
|
inlineprotected |
Run a single step.
This function runs a single simulated annealing step. If SA_VERBOSE
is defined during compilation, this function writes to standard output the information about the current step.
Definition at line 36 of file simulated-annealing.hh.
|
inlinevirtual |
Returns the current temperature.
Returns the current temperature using the formula
\[ k\,\exp\left( -\lambda\,\left\lfloor\frac{steps}{stiter}\right\rfloor\,stiter \right) \]
Definition at line 162 of file simulated-annealing.hh.