forum.alglib.net

ALGLIB forum
It is currently Thu Mar 28, 2024 8:19 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: reusing many times of minqpstate object
PostPosted: Wed Jul 29, 2015 9:13 pm 
Offline

Joined: Wed Jul 29, 2015 8:57 pm
Posts: 2
Hi Sergey,

I run a code like this:
Code:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#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?


Top
 Profile  
 
 Post subject: Re: reusing many times of minqpstate object
PostPosted: Thu Jul 30, 2015 12:07 am 
Offline

Joined: Wed Jul 29, 2015 8:57 pm
Posts: 2
This code is trapped in infinite loop
Code:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string>
#include "optimization.h"
#include <time.h>

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 findfeasiblepoint
Code:
       
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 55 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group