I encounter the same problem with two different objective functions.
The most simple of them is a least squares approximation to some data. My code is written in C++.
Code:
void function_ConicTilted(const real_1d_array &x, real_1d_array &fi, void *ptr)
{
double sum = 0;
for (i = 0; i < vLensfX.n_elem; i++){
fi[i] = pow((vZ(i) - (((vX(i) * vX(i) + vY(i) * vY(i)) / x[0]) / (1 + sqrt(1 - (1 + x[1])*(vX(i)* vX(i) + vY(i) * vY(i)) / (x[0] * x[0]))) + dc1 )),2);
sum = sum + fi[i];
}
cout << sum << ", " << x[0] << ", " << x[1] << endl;
}
The vecotrs vZ,vX,vY contain the x,y,z coordinates of the points to be fitted, dc1 is just a constant.All of them are real valued and of identical size.
The display of the objective function "sum" starts with 14.753 and goes down to 3.58 after the function is called about 20 times. Than it increases again. The final value is reported for 3.6634. The terminationtype is 2 and iterationscount is 34.
The calling sequence for the minimization routine is very similar to the one posted above.
Code:
real_1d_array x = "[+10,-30 ]";
real_1d_array bndl = "[+5,-200]"; //Form shall be convex and radicant shall be positive any time!
real_1d_array bndu = "[+INF,-1]";
double epsg = 0.00000000001;
double epsf = 0;
double epsx = 0;
ae_int_t maxits = 0;
minlmstate state;
minlmreport rep;
minlmcreatev(2,vX.n_elem, x, 0.01, state);
minlmsetbc(state, bndl, bndu);
minlmsetcond(state, epsg, epsf, epsx, maxits);
alglib::minlmoptimize(state, function_ConicTilted);
minlmresults(state, x, rep);
Is there a recommended way to determine the best size of the differentiation step?
Thank you for your help!