## ./

# anneal__define.pro

The anneal class performs simulated annealing to maximize a fitness function. This is a little different than normal, where annealing minimizes a penalty (or energy) function.

Simulated annealing maximizes a function by taking random steps in parameter space from the current input. At each step, the function to maximize is evaluated given the current input. If the input yields a higher fitness than the previous input, it is automatically accepted and the old input discarded. If it is lower, than it is accepted with a probability that decreases as the simulation continues. The process continues, drawing new random inputs and occasionally swapping out the old inputs, until the simulation ends. Thus, the process transitions from a random walk to a hill-climbing algorithm; this helps prevent getting stuck at local maxima.

## Class description for anneal

## Routines

`result = anneal::selectTrial(state)`

This function selects the next trial input, given the current input.

`result = anneal::fitness(state)`

This function evaluates the target function on a given input.

`result = anneal::temperature(step)`

This function calculates the "temperature" at a given iteration of the simulation.

`result = anneal::getBestState( [fitness=fitness])`

This function returns the best set of inputs encountered during the run

`result = anneal::getBestFitness( [state=state])`

Returns the best maximum function output encountered during the simulation

`result = anneal::getAllStates(fitnesses=fitnesses)`

Returns the sequence of inputs attempted during the simulation.

`result = anneal::getAllFitnesses(states=states)`

Returns all of the function evaluations computed during the simulation.

`anneal::run`

`result = anneal::init(start_state, nstep, save=save, verbose=verbose)`

This function initializes the object

`anneal::cleanup`

`anneal__define`

## Routine details

## topanneal::selectTrial

`result = anneal::selectTrial(state)`

This function selects the next trial input, given the current input. This is not implemented; each individual problem must subclass this class, overriding the selectTrial method.

### Parameters

- state in required
The current input

## topanneal::fitness

`result = anneal::fitness(state)`

This function evaluates the target function on a given input. Again, this function must be overridden in a subclass in order for the procedure to work.

### Parameters

- state in required
The input to evaluate

## topanneal::temperature

`result = anneal::temperature(step)`

This function calculates the "temperature" at a given iteration of the simulation. This should probably be overridden for specific implementations, though a default cooling function is provided.

### Parameters

- step in required
The iteration number of the simulation

## topanneal::getBestState

`result = anneal::getBestState( [fitness=fitness])`

This function returns the best set of inputs encountered during the run

### Keywords

- fitness in optional
Set to a named variable to hold the function's output at the returned set of inputs

## topanneal::getBestFitness

`result = anneal::getBestFitness( [state=state])`

Returns the best maximum function output encountered during the simulation

### Keywords

- state in optional
Set to a named variable to hold the input corresponding to the maximum function output

## topanneal::getAllStates

`result = anneal::getAllStates(fitnesses=fitnesses)`

Returns the sequence of inputs attempted during the simulation. Only works if /SAVE was set during object creation

KEYWORD_PARAMETERS: fitnesses: Set to a named variable to hold all of the function evaluations.

### Return value

An array of all the states _

### Keywords

- fitnesses

## topanneal::getAllFitnesses

`result = anneal::getAllFitnesses(states=states)`

Returns all of the function evaluations computed during the simulation. Only works if /SAVE was set during object creation.

KEYWORD_PARAMETERS: states: Set to a named variable to hold all of the inputs tried.

### Keywords

- states

## topanneal::run

`anneal::run`

## topanneal::init

`result = anneal::init(start_state, nstep, save=save, verbose=verbose)`

This function initializes the object

### Parameters

- start_state in required
The seed input value to start the simulation on.

- nstep in required
The number of iterations to run the simulation for

### Keywords

- save
- verbose

## topanneal::cleanup

`anneal::cleanup`

## topanneal__define

`anneal__define`

## File attributes

Modifcation date: | Fri Jul 8 13:46:48 2011 |

Lines: | 275 |