Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Infeasible integer column

    Posted Tue February 27, 2024 04:21 AM

    Hello!!

    I am running a simulation via terminal in ubuntu, and the simulation stopped with

            Default variable names x1, x2 ... being created.

            Integer infeasible column 'x489'.

            terminate called after throwing an instance of 'NoSolutionAvailable'

    x489 should be one of my variables...is there a way to translate default variables created by cplex to the original name of the variables I gave them? 

    This would help in debugging...

    Thanks

    Sam



    ------------------------------
    Samuele Viaro
    ------------------------------


  • 2.  RE: Infeasible integer column

    Posted Tue February 27, 2024 11:42 AM

    If you are using one of the programming APIs to create the model, there will be an option in the variable creation commands to add a name as a string. For instance, the following Java snippet creates a vector of real variables named "x" and gives each one a name.

    IloCplex model = new IloCplex();
    // ...
    IloNumVar[] x = new IloNumVar[n];
    for (int i = 0; i < n; i++) {
      x[i] = model.numVar(0, 100, "x_" + i);
    }


    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 3.  RE: Infeasible integer column

    Posted Tue February 27, 2024 12:42 PM

    I am writing the model in OPL, then I read the model in a .cpp file and solve it in the .cpp file...

    any suggestions on how to do it with C++?

    Thank you



    ------------------------------
    Samuele Viaro
    ------------------------------



  • 4.  RE: Infeasible integer column

    Posted Tue February 27, 2024 02:18 PM

    This probably depends on how you are building the model in OPL (and how OPL is converting it to C++). If you look up the IloNumVar class in the C++ API, you'll find constructors whose last argument is const char * name=0. If you (or OPL) is using IloNumVarArray, the constructor will not let you add names. However, once the variable array is constructed, you can loop over it and apply public void setName(const char * name) const to each array element. 



    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 5.  RE: Infeasible integer column

    Posted Wed February 28, 2024 02:29 AM

    I define the variables names and constraint in the .mod file such as:
    dvar float+ t[I0p1];

    dvar boolean z[I0,H];

    subject to 
    {
        c_b:
              sum(i in I0) L[i] == 1;
    };

    Originally I wrote this model in AMPL using CPLEX as solver. Now I switched to IBM directly and I am having troubles rewriting the model in OPL...



    ------------------------------
    Samuele Viaro
    ------------------------------



  • 6.  RE: Infeasible integer column

    Posted Wed February 28, 2024 05:01 AM

    Hi,

    OPL keeps the names.

    For instance https://medium.com/ibm-data-ai/optimization-simply-do-more-with-less-zoo-buses-and-kids-66940178db6

    int nbKids=300;
    float costBus40=500;
    float costBus30=400;
     
    dvar int+ nbBus40;
    dvar int+ nbBus30;
     
    minimize
     costBus40*nbBus40  +nbBus30*costBus30;
     
    subject to
    {
     40*nbBus40+nbBus30*30>=nbKids;
    } 

    gives the lp file

    Minimize
     obj1: 500 nbBus40 + 400 nbBus30
    Subject To
     c1: 40 nbBus40 + 30 nbBus30 >= 300
    Bounds
          nbBus40 >= 0
          nbBus30 >= 0
    Generals
     nbBus40  nbBus30 
    End


    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 7.  RE: Infeasible integer column

    Posted Wed February 28, 2024 05:14 AM

    Hello! 

    I guess I am doing something wrong...I wrote my model in  cyclic.mod file, data in cyclic.dat file. Then, in my .cpp file I have

          IloOplRunConfiguration rc(env, "./cyclic.mod", "./cyclic.dat");

          ...

          rc.getCplex().exportModel("cyclicModelCpp.lp");

          ...

        rc.getCplex().solve()

    Is any of these passages causing the .lp file not to show the original names?



    ------------------------------
    Samuele Viaro
    ------------------------------



  • 8.  RE: Infeasible integer column

    Posted Wed February 28, 2024 05:59 AM

    See this technote : https://www.ibm.com/support/pages/display-variable-and-constraint-names-using-opl-api

    You should write

    IloOplSettings settings = oplF.createOplSettings(errHandler);
    
    settings.setWithNames(true);


    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 9.  RE: Infeasible integer column

    Posted Wed February 28, 2024 08:16 AM

    Thank you!

    However, isn't this for Java?? I tried the equivalent function in Cpp and I was able to display the original names of the constraints but not the decision variables...I'll keep looking! :)



    ------------------------------
    Samuele Viaro
    ------------------------------