esa / pagmo2

A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
https://esa.github.io/pagmo2/
GNU General Public License v3.0
808 stars 160 forks source link

Optimisation return status: Invalid_Number_Detected (value = -13) #499

Closed A5troB0y closed 2 years ago

A5troB0y commented 2 years ago

using the ipopt with pagmo2, got the error "Optimization return status: Invalid_Number_Detected (value = -13)" for the problem

double  obj = 0;
    for(int i=0 ;i<3;i++)
        {
            obj += pow((x[2*i-2]-3),2) / 1000. - (x[2*i-2]-x[2*i-1]) + exp(20.*(x[2*i - 2]-x[2*i-1]));
        }
    auto ce1 = 4*pow((x[0]-x[1]),2)   +x[1] - pow(x[2],2) + x[2]-pow(x[3],2);
    auto ce2 = 8*x[1]*(  pow(x[1],2)    -x[0])-2*(1-x[1])+4*  pow((x[1]-x[2]),2)   + pow(x[0],2)  +  x[2]  -  pow(x[3],2) +x[3]     -pow(x[4],2);
    auto ce3 = 8*x[2]*(  pow(x[2],2)    -x[1])-2*(1-x[2])+4*  pow((x[2]-x[3]),2)   + pow(x[1],2)  -  x[0]  +  x[3]    -pow(x[4],2)  +pow(x[0],2) + x[4] - pow(x[5],2);
    auto ce4 = 8*x[3]*(  pow(x[3],2)    -x[2])-2*(1-x[3])+4*  pow((x[3]-x[4]),2)   + pow(x[2],2)  -  x[1]  +  x[4]    -pow(x[5],2)  +pow(x[1],2) + x[5] - x[0];
    auto ci1 = 8*x[4]*(  pow(x[4],2)    -x[3])-2*(1-x[4])+4*  pow((x[4]-x[5]),2)   + pow(x[3],2)  -  x[2]  +  x[5]    +pow(x[2],2)  -x[1];
    auto ci2 = -(8*x[5] * (pow(x[5],2)-x[4])-2*(1-x[5]) +pow(x[4],2)-x[3]+ pow(x[3],2) - x[4])    ;

    return {obj,ce1,ce2,ce3,ce4,ci1,ci2};
gradient is computed using the following code

    //gradient & estimate_gradient
    vector_double gradient(const vector_double &dv) const
    {
        return estimate_gradient([this](const vector_double &x) {return this->fitness(x);},dv);
    }

got the above error.

the code is working for a simple convex problems. could not figure out the error. kindly post a solution for this and how to make it work