Djinni
2.2
|
An Annealer specialized for Ohlmann-Thomas compressed annealing. More...
#include <Annealer.h>
Public Types | |
typedef Compressed | PenaltyFunc |
typedef PenaltyFunc::ReturnType | PenaltyType |
typedef unsigned long | u_int32_t |
Public Member Functions | |
Annealer (PenaltyFunc &pfunc, SolutionType &sol, double multT, double accept, u_int32_t tBI, u_int32_t minIter, u_int32_t maxIter) | |
Annealer (SolutionType &solution, double multT, double accept, u_int32_t tBI, u_int32_t minIter, u_int32_t maxIter) | |
Annealer (PenaltyFunc &pfunc, SolutionType &sol) | |
virtual | ~Annealer () |
PenaltyFunc & | getPenaltyFunc () |
const SolutionType & | best () const |
const SolutionType & | current () const |
void | solve () |
std::string | solution () const |
void | setParameters (double multT, double accept, u_int32_t tBI, u_int32_t minIterations, u_int32_t maxIterations) |
void | setSolutionParameters (const char *foo) |
std::ostream & | dump (std::ostream &os) const |
double | cost () const |
double | penalty () const |
u_int32_t | bestIter () const |
u_int32_t | iterations () const |
u_int32_t | maxIterations () const |
u_int32_t | minIterations () const |
double | multiplier () const |
double | probability () const |
PenaltyType | getLambda () const |
Protected Member Functions | |
void | initializeParam () |
void | tuneTemperature () |
void | testNeigh () |
void | updateParam () |
Protected Attributes | |
SHARED_PTR< SolutionType > | _best |
SHARED_PTR< SolutionType > | _current |
SHARED_PTR< SolutionType > | _neighbor |
u_int32_t | _bestIter |
u_int32_t | _iterations |
u_int32_t | _maxIterations |
u_int32_t | _minIterations |
u_int32_t | _terminalBestIter |
double | _multiplierT |
double | _acceptProb |
double | _currentT |
PenaltyFunc | _pfunc |
PenaltyType | _lambda |
Static Protected Attributes | |
static const int | _sampleSize = 10000 |
An Annealer specialized for Ohlmann-Thomas compressed annealing.
For details on Ohlmann-Thomas annealing, please see [FIXME REFERENCE].
Definition at line 343 of file Annealer.h.
Annealer< Compressed, SolutionType >::Annealer | ( | PenaltyFunc & | pfunc, |
SolutionType & | sol, | ||
double | multT, | ||
double | accept, | ||
u_int32_t | tBI, | ||
u_int32_t | minIter, | ||
u_int32_t | maxIter | ||
) | [inline] |
An Annealer constructor which takes all necessary parameters in one fell swoop.
pfunc | The penalty function to be applied to this annealer |
sol | A solution, populated randomly, to be applied to this annealer |
multT | A value in the range 0.0 - 0.9999 representing the temperature multiplier |
accept | A value in the range 0.0 - 0.9999 representing our willingness to accept an inferior solution |
tBI | The terminal best iteration |
minIter | The minimum number of annealing iterations to apply |
maxIter | The maximum number of annealing iterations to apply |
Definition at line 362 of file Annealer.h.
References Annealer< PenaltyFunc, SolutionType >::setParameters().
Annealer< Compressed, SolutionType >::Annealer | ( | SolutionType & | solution, |
double | multT, | ||
double | accept, | ||
u_int32_t | tBI, | ||
u_int32_t | minIter, | ||
u_int32_t | maxIter | ||
) | [inline] |
An Annealer constructor appropriate for use with PenaltyFuncs which have a default constructor.
solution | A solution, populated randomly, to be applied to this annealer |
multT | A value in the range 0.0 - 0.9999 representing the temperature multiplier |
accept | A value in the range 0.0 - 0.9999 representing our willingness to accept an inferior solution |
tBI | The terminal best iteration |
minIter | The minimum number of annealing iterations to apply |
maxIter | The maximum number of annealing iterations to apply |
Definition at line 381 of file Annealer.h.
References Annealer< PenaltyFunc, SolutionType >::setParameters().
Annealer< Compressed, SolutionType >::Annealer | ( | PenaltyFunc & | pfunc, |
SolutionType & | sol | ||
) | [inline] |
An Annealer constructor for use when the parameters will be set after initialization.
pfunc | The penalty function to be applied to this annealer |
sol | A solution, populated randomly, to be applied to this annealer |
Definition at line 394 of file Annealer.h.
virtual Annealer< Compressed, SolutionType >::~Annealer | ( | ) | [inline, virtual] |
A no-op destructor.
This destructor is virtualized to allow end users to subclass off this template. Whether an end user should subclass off this template is a different question.
Definition at line 404 of file Annealer.h.
const SolutionType& Annealer< Compressed, SolutionType >::best | ( | ) | const [inline] |
Returns the best solution found by the annealer.
Definition at line 410 of file Annealer.h.
u_int32_t Annealer< Compressed, SolutionType >::bestIter | ( | ) | const [inline] |
Returns the number of the iteration on which the best solution was encountered.
Definition at line 524 of file Annealer.h.
double Annealer< Compressed, SolutionType >::cost | ( | ) | const [inline] |
Returns the cost of the best solution found by the annealer.
Definition at line 515 of file Annealer.h.
const SolutionType& Annealer< Compressed, SolutionType >::current | ( | ) | const [inline] |
Returns the current solution in use by the annealer.
It is unlikely this method will be of use to end users. Once you hit the solve() method, you're on an uninterruptible trip to the end. However, in the event you want to subclass and do funky things, you have an accessor.
Definition at line 418 of file Annealer.h.
std::ostream& Annealer< Compressed, SolutionType >::dump | ( | std::ostream & | os | ) | const [inline] |
Allows for an Annealer object's internal state to be dumped in human-readable format to an output stream.
Please note that this is not meant to be called directly. Rather, an operator<< will be set up as a proxy to invoke this method.
os | The output stream to dump it to |
Definition at line 496 of file Annealer.h.
PenaltyType Annealer< Compressed, SolutionType >::getLambda | ( | ) | const [inline] |
PenaltyFunc& Annealer< Compressed, SolutionType >::getPenaltyFunc | ( | ) | [inline] |
Returns this Annealer's PenaltyFunc
Definition at line 407 of file Annealer.h.
void Annealer< Compressed, SolutionType >::initializeParam | ( | ) | [inline, protected] |
Performs housekeeping to make sure our parameters are properly set before entering annealing runs.
Definition at line 556 of file Annealer.h.
References Compressed::getCapPercentage(), and Compressed::setPressureCap().
u_int32_t Annealer< Compressed, SolutionType >::iterations | ( | ) | const [inline] |
Returns the current iteration number.
Definition at line 529 of file Annealer.h.
u_int32_t Annealer< Compressed, SolutionType >::maxIterations | ( | ) | const [inline] |
Returns the maximum number of annealer iterations to run.
Definition at line 534 of file Annealer.h.
u_int32_t Annealer< Compressed, SolutionType >::minIterations | ( | ) | const [inline] |
Returns the minimum number of annealer iterations to run.
Definition at line 539 of file Annealer.h.
double Annealer< Compressed, SolutionType >::multiplier | ( | ) | const [inline] |
Returns the temperature multiplier.
Definition at line 543 of file Annealer.h.
double Annealer< Compressed, SolutionType >::penalty | ( | ) | const [inline] |
Returns the penalty incurred by the best solution found by the annealer.
Definition at line 520 of file Annealer.h.
double Annealer< Compressed, SolutionType >::probability | ( | ) | const [inline] |
Returns the probability of accepting an inferior move.
Definition at line 548 of file Annealer.h.
void Annealer< Compressed, SolutionType >::setParameters | ( | double | multT, |
double | accept, | ||
u_int32_t | tBI, | ||
u_int32_t | minIterations, | ||
u_int32_t | maxIterations | ||
) | [inline] |
Sets the parameters of the annealer.
multT | A value in the range 0.0 - 0.9999 representing the temperature multiplier |
accept | A value in the range 0.0 - 0.9999 representing our willingness to accept an inferior solution |
tBI | The terminal best iteration |
minIterations | The minimum number of annealing iterations to apply |
maxIterations | The maximum number of annealing iterations to apply |
Definition at line 470 of file Annealer.h.
References Annealer< PenaltyFunc, SolutionType >::maxIterations(), and Annealer< PenaltyFunc, SolutionType >::minIterations().
void Annealer< Compressed, SolutionType >::setSolutionParameters | ( | const char * | foo | ) | [inline] |
Sets the parameters of this annealer's SolutionType by calling that class' constructor.
foo | A char* containing the solution parameters |
Definition at line 483 of file Annealer.h.
std::string Annealer< Compressed, SolutionType >::solution | ( | ) | const [inline] |
Return a std::string representation of the best solution found by the annealer.
Definition at line 455 of file Annealer.h.
void Annealer< Compressed, SolutionType >::solve | ( | ) | [inline] |
For a completely-constructed annealer, initiate the solution process and do not return until termination.
Definition at line 421 of file Annealer.h.
References Annealer< PenaltyFunc, SolutionType >::initializeParam(), Annealer< PenaltyFunc, SolutionType >::testNeigh(), Annealer< PenaltyFunc, SolutionType >::tuneTemperature(), and Annealer< PenaltyFunc, SolutionType >::updateParam().
void Annealer< Compressed, SolutionType >::testNeigh | ( | ) | [inline, protected] |
Tests a neighbor for superiority or inferiority, and may update our _current solution based on the result.
Definition at line 629 of file Annealer.h.
References Twister::generateDouble().
void Annealer< Compressed, SolutionType >::tuneTemperature | ( | ) | [inline, protected] |
Run some initial annealing iterations in order to set the temperature to the proper initial value.
Definition at line 588 of file Annealer.h.
References Twister::generateDouble(), and Annealer< PenaltyFunc, SolutionType >::iterations().
void Annealer< Compressed, SolutionType >::updateParam | ( | ) | [inline, protected] |
Updates the temperature and lambda each iteration.
Definition at line 645 of file Annealer.h.