Hi Sergey,
I can't share my code because it involves many classes, so I have tried to replicate a simpler function that returns more or less the same issue:
Code:
#include <iomanip>
#include <iostream>
#include "optimization.h"
using namespace std;
using namespace alglib;
void func(const real_1d_array& x, real_1d_array& fi, void* ptr)
{
fi[0] = 50 * pow(x[0], 3) * x[1] - pow(x[2],2);
fi[1] = x[1] * pow(x[2], 3);
double g = 100 * sin(x[0]);
double f = 300 * sin(x[1] * 0.9);
fi[0] = -x[2];
fi[1] = f + g - 1e-3 * pow(x[2], 2) - 265.;
fi[2] = f - 1.5 * g;
}
int main()
{
real_1d_array x0 = "[0, 0, 0]";
real_1d_array s = "[1, 1, 1]";
double epsx = 1e-9;
double diffstep = 1e-6;
ae_int_t maxits = 100000;
real_1d_array bndl = "[-inf, -inf, -inf]";
real_1d_array bndu = "[+inf, +inf, +inf]";
real_1d_array nlcl = "[0, 0]";
real_1d_array nlcu = "[0, 0]";
minnlcstate state;
minnlccreatef(x0, diffstep, state);
minnlcsetcond(state, epsx, maxits);
minnlcsetscale(state, s);
minnlcsetalgoslp(state);
minnlcsetbc(state, bndl, bndu);
minnlcsetnlc2(state, nlcl, nlcu);
minnlcoptguardsmoothness(state);
minnlcreport rep;
minnlcoptimize(state, func);
minnlcresults(state, x0, rep);
for (int i = 0; i < x0.length(); i++)
{
cout << setprecision(10) << x0[i] << endl;
}
cout << endl;
cout << "nlc\t" << rep.nlcidx << "\t" << rep.nlcerr << endl;
cout << "bc\t" << rep.bcidx << "\t" << rep.bcerr << endl;
cout << "Termination Type:\t" << rep.terminationtype << endl;
optguardreport ogrep;
minnlcoptguardresults(state, ogrep);
printf("%s\n", ogrep.badgradsuspected ? "true" : "false"); // EXPECTED: false
printf("%s\n", ogrep.nonc0suspected ? "true" : "false"); // EXPECTED: false
printf("%s\n", ogrep.nonc1suspected ? "true" : "false"); // EXPECTED: false
}
This will be the output:
Quote:
1.570793632
0.6214630454
1.006445372
nlc 1 9.182153749
bc -1 0
Termination Type: 2
false
false
false
As you see, the second non linear condition is not respected, but the termination type is 2.
Mine code has similar outputs, except termintation type that is 7.