The Szu and Hartley Fast simulated annealing
T_out = temp_law_fsa(T_in,step_mean,step_var,temp_stage,n,param)
the temperature at the current stage
the mean value of the objective function computed during the current stage
the variance value of the objective function computed during the current stage
the index of the current temperature stage
the dimension of the decision variable (the x in f(x))
not used for this temperature law
the temperature for the temperature stage to come
This function implements the Fast simulated annealing of Szu and Hartley.
function y=rastrigin(x) y = x(1)^2+x(2)^2-cos(12*x(1))-cos(18*x(2)); endfunction x0 = [-1, -1]; Proba_start = 0.8; It_intern = 1000; It_extern = 30; It_Pre = 100; mprintf('SA: the FSA algorithm\n'); T0 = compute_initial_temp(x0, rastrigin, Proba_start, It_Pre, neigh_func_default); mprintf('Initial temperature T0 = %f\n', T0); saparams = init_param(); saparams = add_param(saparams, "neigh_func", neigh_func_fsa); saparams = add_param(saparams, "temp_law", temp_law_fsa); [x_opt, f_opt, sa_mean_list, sa_var_list, temp_list] = optim_sa(x0, rastrigin, It_extern, It_intern, T0, Log = %T, saparams); mprintf('optimal solution:\n'); disp(x_opt); mprintf('value of the objective function = %f\n', f_opt); scf(); subplot(2,1,1); xtitle('Fast simulated annealing','Iteration','Mean / Variance'); t = 1:length(sa_mean_list); plot(t,sa_mean_list,'r',t,sa_var_list,'g'); legend(['Mean','Variance']); subplot(2,1,2); xtitle('Temperature evolution','Iteration','Temperature'); plot(t,temp_list,'k-'); | ![]() | ![]() |