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! :)
Original Message:
Sent: Wed February 28, 2024 05:58 AM
From: ALEX FLEISCHER
Subject: Infeasible integer column
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]
Original Message:
Sent: Wed February 28, 2024 05:14 AM
From: Samuele Viaro
Subject: Infeasible integer column
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
Original Message:
Sent: Wed February 28, 2024 05:00 AM
From: ALEX FLEISCHER
Subject: Infeasible integer column
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 nbBus30Subject To c1: 40 nbBus40 + 30 nbBus30 >= 300Bounds nbBus40 >= 0 nbBus30 >= 0Generals nbBus40 nbBus30 End
------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]
Original Message:
Sent: Wed February 28, 2024 02:28 AM
From: Samuele Viaro
Subject: Infeasible integer column
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
Original Message:
Sent: Tue February 27, 2024 02:17 PM
From: Paul Rubin
Subject: Infeasible integer column
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
Original Message:
Sent: Tue February 27, 2024 12:42 PM
From: Samuele Viaro
Subject: Infeasible integer column
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
Original Message:
Sent: Tue February 27, 2024 11:41 AM
From: Paul Rubin
Subject: Infeasible integer column
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
Original Message:
Sent: Tue February 27, 2024 04:20 AM
From: Samuele Viaro
Subject: Infeasible integer column
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
------------------------------