Class model::Pubo
Inherited Members
Methods
calculate_cost()
Definition of the cost function.
Evaluate the entire cost function for the state being passed. For instance, in the case of a model from statistical mechanics, this would be the Hamiltonian.
Declaration
double model::Pubo::calculate_cost(const State_T&state) const override
calculate_cost_difference()
Partial evaluation of the cost function.
This method should calculate the difference in cost if we move from state
(=before) to the one resulting from applying transition
to state
(=after):
\Delta_{C} = C_{\mathrm{after}} - C_{\mathrm{before}}
In code:
State state = get_random_state(rng); Transition transition = get_random_transition(rng); double cost_before = calculate_cost(state); double cost_diff = calculate_cost_difference(state, transition); apply_transition(transition, state); // modify state double cost_after = calculate_cost(state); // before + diff should correspond to after
(up to double precision) assert(cost_before + cost_diff == cost_after);
Declaration
double model::Pubo::calculate_cost_difference(const State_T&state, const Transition_T&transition) const override
apply_transition()
Apply a transition to a state.
This changes the configuration represented by *state
. Depending on the optimization algorithm, transition can either be applied conditionally or alaways (e.g., population dynamics). Separating the functionality into the three interfaces random_transition
, calculate_cost_difference
, apply_transition
leaves control over the strategy with the optimization method.
Declaration
void model::Pubo::apply_transition(const Transition_T&transition, State_T&state) const override