Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  . dll error

    Posted Mon September 14, 2020 11:14 AM

    hello,

    I coded the following small MIP model and trying to solve it concert technology;

    #include<ilcplex/ilocplex.h>

    ILOSTLBEGIN

    int main() {

    IloEnv env;

    IloModel model(env);

    IloNumVarArray x(env);

    x.add(IloNumVar(env, 0, 1, ILOINT));

    x.add(IloNumVar(env, 0, 1, ILOINT));

    x.add(IloNumVar(env, 0, 1, ILOINT));

    x.add(IloNumVar(env, 0, 1, ILOINT));

    model.add (8 * x[1] + 2 * x[2] + x[3] + 4 * x[4] <= 10);

    model.add(x[1] + x[2]<= 1);

    model.add(x[3] + x[4] <= 1);

    model.add(IloMaximize(env, 16 * x[1] + 10 * x[2] + 4*x[4]));

    IloCplex cplex(model);

    cplex.solve();

    cout << "Objective Value" << cplex.getObjValue() << endl;

    env.end();

    system("pause");

    return 0;

    }

    I get two errors at the same time in the output screen it is written :

    X& IloArray::operator[] (IloInt i) : Out of bounds operation: index superior to size of array

    Assertion failed: (i < _impl->getSize()) || (ILOSTD(cerr) << "X& IloArray::operator[] (IloInt i) : Out of bounds operation: index superior to size of array" << ILOSTD(endl), ilo_stop_assert()), file c:\program files\ibm\ilog\cplex_studio129\concert\include\ilconcert\iloenv.h, line 2248

    on the other hand execution is stopped with the message:

    Exception non gérée à 0x00007FFECEC3284E (ucrtbase.dll) dans Projet1.exe : Fermeture de programme requise suite à une erreur irrécupérable.

    All the variables are binary integer btw;

    How can I fix this problem ?

    Thank you in advance






    #DecisionOptimization
    #Support
    #SupportMigration


  • 2.  RE: . dll error
    Best Answer

    Posted Mon September 14, 2020 12:38 PM

    Hello Milena,

    You added 4 IloNumVar into the IloNumvarArray x. So the right indices for this array are 0,1,2,3 . The value 4 leads to a "Out of bounds" exception.

    I hope this clarifies,

    Chris.






    #DecisionOptimization
    #Support
    #SupportMigration


  • 3.  RE: . dll error
    Best Answer

    Posted Mon September 14, 2020 01:20 PM

    Thank you so much Chris :) It worked :)






    #DecisionOptimization
    #Support
    #SupportMigration