optim_sa — A Simulated Annealing optimization method
[x_best,f_best,mean_list,var_list,f_history,temp_list,x_history] = optim_sa(x0,f,ItExt,ItInt,T0,Log,temp_law,param_temp_law,neigh_func,param_neigh_func)
the initial solution
the objective function to be optimized (the prototype if f(x))
the number of temperature decrease
the number of iterations during one temperature stage
the initial temperature (see compute_initial_temp to compute easily this temperature)
if %T, some information will be displayed during the run of the simulated annealing
the temperature decrease law (see temp_law_default for an example of such a function)
a structure (of any kind - it depends on the temperature law used) which is transmitted as a parameter to temp_law
a function which computes a neighbor of a given point (see neigh_func_default for an example of such a function)
a structure (of any kind like vector, list, it depends on the neighborhood function used) which is transmitted as a parameter to neigh_func
the best solution found so far
the objective function value corresponding to x_best
the mean of the objective function value for each temperature stage. A vector of float (optional)
the variance of the objective function values for each temperature stage. A vector of float (optional)
the computed objective function values for each iteration. Each input of the list corresponds to a temperature stage. Each input of the list is a vector of float which gathers all the objective function values computed during the corresponding temperature stage - (optional)
the list of temperature computed for each temperature stage. A vector of float (optional)
the parameter values computed for each iteration. Each input of the list corresponds to a temperature stage. Each input of the list is a vector of input variables which corresponds to all the variables computed during the corresponding temperature stage - (optional - can slow down a lot the execution of optim_sa)
function y = rastrigin(x) y = x(1)^2+x(2)^2-cos(12*x(1))-cos(18*x(2)); endfunction x0 = [2 2]; Proba_start = 0.7; It_Pre = 100; It_extern = 100; It_intern = 1000; x_test = neigh_func_default(x0); comp_t_params = init_param(); comp_t_params = add_param(comp_t_params,'neigh_func', neigh_func_default); T0 = compute_initial_temp(x0, rastrigin, Proba_start, It_Pre, comp_t_sa); [x_opt, f_opt, sa_mean_list, sa_var_list] = optim_sa(x0, rastrigin, It_extern, It_intern, T0, Log = %T); printf('optimal solution:\n'); disp(x_opt); printf('value of the objective function = %f\n', f_opt); t = 1:length(sa_mean_list); plot(t,sa_mean_list,'r',t,sa_var_list,'g');