forum.alglib.net http://forum.alglib.net/ |
|
About the Optimization: How to optimize the N dimention pro http://forum.alglib.net/viewtopic.php?f=2&t=310 |
Page 1 of 1 |
Author: | frainbbs [ Mon Feb 28, 2011 7:33 am ] |
Post subject: | About the Optimization: How to optimize the N dimention pro |
About the Optimization: How to optimize the functon with N dimention? example: minlm Improved Levenberg-Marquardt optimizer int main(int argc, char **argv) { // // This example demonstrates minimization of F(x0,x1) = f0^2+f1^2, where // // f0(x0,x1) = 10*(x0+3)^2 // f1(x0,x1) = (x1-3)^2 // // using "V" mode of the Levenberg-Marquardt optimizer. // // Optimization algorithm uses: // * function vector f[] = {f1,f2} // // No other information (Jacobian, gradient, etc.) is needed. // real_1d_array x = "[0,0]"; double epsg = 0.0000000001; double epsf = 0; double epsx = 0; ae_int_t maxits = 0; minlmstate state; minlmreport rep; minlmcreatev(2, x, 0.0001, state); minlmsetcond(state, epsg, epsf, epsx, maxits); minlmoptimize(state, function1_fvec); minlmresults(state, x, rep); printf("%d\n", int(rep.terminationtype)); // EXPECTED: 4 printf("%s\n", x.tostring(2).c_str()); // EXPECTED: [-3,+3] return 0; } ///********************************************///////////// real_1d_array x = "[0,0]"; I have a function to optimize, sunch as f(x1,x2,x3,x4,,,,,,,x500) in C++,it can be do like this : float x[500]; or. float *x = new float[500]; But in alglib, How to declaration the array x with N(N is big,such as N>100)????? Like this:????? real_1d_array x = "[0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,.......]"; |
Author: | frainbbs [ Mon Feb 28, 2011 7:55 am ] |
Post subject: | Re: About the Optimization: How to optimize the N dimention |
I know real_1d_array x ; double epsg = 0.0000000001; double epsf = 0; double epsx = 0; ae_int_t maxits = 0; minlmstate state; minlmreport rep; int N=100; double *y = new double[N]; for(int i=0; i< N ;i++) y[i]=2*i; x.setcontent(N,y); for(int i=0;i<N;i++) cout<<i<<" "<<x[i]<<endl; |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |