#include #include #include #include #include //declare a class derived from func_obj class foo :public opt_utilities::func_obj > // ^^^^^^^^double is the return type // vector is the parameter type { double do_eval(const std::vector& p) { double result=0; for(int i=0;i > op; //set the optimization method op.set_opt_method(opt_utilities::powell_method >()); //attach the object function op.set_func_obj(foo()); //define the starting point std::vector p(3); p[0]=p[1]=p[2]=10; //set the starting point op.set_start_point(p); std::cout<<"starting optimization from:"<< p[0]<<" "< >()); //define the lower and upper limit p[0]=p[1]=p[2]=-10; op.set_lower_limit(p); p[0]=p[1]=p[2]=10; op.set_upper_limit(p); //set the start point op.set_start_point(p); //set precision op.set_precision(1E-10); //start optimize p=op.optimize(); std::cout<<"optimization result:"<< p[0]<<" "<