MaxSA - Example
SimAnn
Included in the package is a sample program simann.ox where a simple objective function according to Judge et al. is implemented.The main program essentially looks like
#include <oxstd.h> // Include the Ox standard library header #include <oxfloat.h> #import <maximize> #import <packages/maxsa/maxsa> main() { decl vP, dFunc, dT, ir; println ("\nEstimating using MaxBFGS"); ir= MaxBFGS(fnc, &vP, &dFunc, 0, TRUE); println (MaxConvergenceMsg(ir), " at parameters ", vP', "with function value ", double(dFunc)); // Estimate using MaxSA, to find global optimum println ("\nEstimating using MaxSA"); ir= MaxSA(fnc, &vP, &dFunc, &dT); println (MaxSAConvergenceMsg(ir), " at parameters ", vP', "with function value ", double(dFunc), " and temperature ", double(dT)); }On the output, you'll see information like
Estimating using MaxBFGS Strong convergence at parameters 2.3545 -0.31919 with function value -20.9805 Estimating using MaxSA Strong convergence at parameters 0.86480 1.2357 with function value -16.0817 and temperature 7.45058e-08which indicates how MaxBFGS indeed did not get away from the local maximum, whereas the Simulated Annealing algorithm managed to get away to the global optimum.