forum.alglib.nethttp://forum.alglib.net/ reusing many times of minqpstate objecthttp://forum.alglib.net/viewtopic.php?f=2&t=3118 Page 1 of 1

 Author: siava [ Wed Jul 29, 2015 9:13 pm ] Post subject: reusing many times of minqpstate object Hi Sergey,I run a code like this:Code:#include #include #include #include "optimization.h"using namespace alglib;int main(){        real_2d_array H = "[[1.22299, 0, 0 ],                        [ 0, 1.9349, 0 ],                        [ 0, 0, 0.603924 ]]";        real_1d_array f = "[ -4.97245, -9.09039, -4.63856 ]";        real_2d_array A = "[[ 1, 0, 0, 4.94298 ],                        [ 1, 0, 0, 4.79981 ],                        [ 0, 1, 0, -0.4848 ],                        [ 0, 1, 0, -0.73804 ],                        [ 0, 0, 1, 0.575729 ],                        [ 0, 0, 1, 0.458645 ],                        [ 1, 0, -1, -0.0546574 ],                        [ 1, 0, -1, -0.590044 ]]";        integer_1d_array ct = "[ -1, 1, -1, 1, -1, 1, -1, 1 ]";        real_1d_array s = "[ 0.143171, 0.25324, 0.117084 ]";        real_1d_array x0 = "[ 3.51126, 4.05731, 6.63307 ]";        minqpstate state;        minqpreport rep;        minqpcreate(3, state);        minqpsetquadraticterm(state, H);        minqpsetlinearterm(state, f);        minqpsetlc(state, A, ct);        real_1d_array x;        minqpsetalgobleic(state, 0.0, 0.0, 0.0, 0);        minqpoptimize(state);        minqpresults(state, x, rep);        printf("%s\n", x.tostring(1).c_str());}many times in a loop with different parameters. Very frequently I change linear term of the task, and less frequently a constraints matrix. At some iteration my program falls in infinite loop somewhere in the alglib code. This stuck arises with sime probability when the constraints passed to the solver seems to be inconsistent. In a single run of the same problem solving alglib code works without stuck. So, my question is: do You have any ideas why this problem happen? Maybe some reinitialization/clearing of the minqpstate object is needed?

 Author: siava [ Thu Jul 30, 2015 12:07 am ] Post subject: Re: reusing many times of minqpstate object This code is trapped in infinite loopCode:#include #include #include #include #include "optimization.h"#include int main(int argc, char **argv){   srand( time( 0 ) );   //test_qpsolver();   real_2d_array H = "[[1.22299,0,0],[0,1.9349,0],[0,0,0.603924]]";    real_1d_array f = "[-4.97245,-9.09039,-4.63856]";    real_2d_array A = "[[1,0,0,4.94298],[1,0,0,4.79981],[0,1,0,-0.4848 ],[0,1,0,-0.73804],[0,0,1,0.575729],[0,0,1,0.458645],[1,0,-1,-0.0546574],[1,0,-1,-0.590044]]"; //    integer_1d_array ct = "[-1,1,-1,1,-1,1,-1,1]"; //    real_1d_array s = "[0.143171,0.25324,0.117084]";    real_1d_array x0 = "[3.51126,4.05731,6.63307]";    minqpstate state;    minqpreport rep;   minqpcreate(3, state);   minqpsetquadraticterm(state, H);   for( unsigned i = 0; i < 100000; i++ )   {      if( i > 0 )      {      for( unsigned j = 0; j < f.length(); j++ )         f(j) += ( rand() % 2 ) ? (+0.1) : (-0.1);      for( unsigned j = 0; j < 6; j++ )         A(j,A.cols()-1) += ( rand() % 2 ) ? (+0.1) : (-0.1);      }            minqpsetlinearterm(state, f);      minqpsetlc(state, A, ct);      real_1d_array x;      minqpsetalgobleic(state, 0.0, 0.0, 0.0, 0);      minqpsetstartingpoint(state, x0);      minqpoptimize(state);      minqpresults(state, x, rep);      printf( "%d ", i );      //printf("%s\n", x.tostring(1).c_str());      //printf("Termination code: %d", rep.terminationtype );   }   getchar();    return 0;}In ALGLIB findfeasiblepointCode:        if( !findfeasiblepoint(&state->tmpfeas, &state->bndl, &state->hasbndl, &state->bndu, &state->hasbndu, n, state->nic, &state->tmpm0, state->nec+state->nic, 1.0E-6, &i, &j, _state) )        {            return result;        }runs infinitely long. When I checked error, it was about 0.2, but I suppose at the end of iterations it must be 1e-6.Is it possible to fix this stuck?

 Page 1 of 1 All times are UTC Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/