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?