= MaxConsRej; Break;
ELSE
T = CoolSched (T); % Update T according to cooling schedule.
END
NewParam = Generator (Parent); % Generate a new solution.
IF pertc == 30 % Every 30 repetitions, jump to another area.
NewParam = NewParam + randi([-1000,1000]);
END
NewReward = EvModel(NewParam); % Evaluate the new solution.
incNewReward = NewReward - OldReward;
% If the new solution is better than the old solution, accept the new solution.
IF (incNewReward > 1e-6)
Parent = NewParam; OldReward = NewReward;
% Otherwise, accept the new solution with a probability obtained from the Boltzman distribution.
ELSE
IF (rand > exp(-incNewReward/(k*T) ));
Parent = NewParam; OldReward = NewReward;
END
END
END
% Decide the optimal solution and the reward where the optimal solution is used.
OptSol = Parent; OptV = OldReward;