The following pseudocode presents the simulated annealing heuristic as described above. It starts from a state {{math|''s''<sub>0</sub>}} and continues until a maximum of {{math|''k''<sub>max</sub>}} steps have been taken. In the process, the call {{math|neighbour(''s'')}} should generate a randomly chosen neighbour of a given state {{mvar|s}}; the call {{math|random(0, 1)}} should pick and return a value in the range {{math|[0, 1]}}, [[Uniform distribution (continuous)|uniformly at random]]. The annealing schedule is defined by the call {{math|temperature(''r'')}}, which should yield the temperature to use, given the fraction {{mvar|r}} of the time budget that has been expended so far. | The following pseudocode presents the simulated annealing heuristic as described above. It starts from a state {{math|''s''<sub>0</sub>}} and continues until a maximum of {{math|''k''<sub>max</sub>}} steps have been taken. In the process, the call {{math|neighbour(''s'')}} should generate a randomly chosen neighbour of a given state {{mvar|s}}; the call {{math|random(0, 1)}} should pick and return a value in the range {{math|[0, 1]}}, [[Uniform distribution (continuous)|uniformly at random]]. The annealing schedule is defined by the call {{math|temperature(''r'')}}, which should yield the temperature to use, given the fraction {{mvar|r}} of the time budget that has been expended so far. |