I'm trying to run the CPLEX .mod file within Python. An instructor on how to do this exists in the following link:
How to run a .mod file (CPLEX) using python?
But it seems that (maybe) only the tuple is sent from Python into CPLEX. In my case, there is a loop in the CPLEX .mod file like the following:
for (var i = lowerBound; i <= upperBound; i++) {
...
}
I want to send parameters lowerBound and upperBound from Python to CPLEX .mod file. For this aim, I define a variable inside the CPLEX .mod file, before the for loop, as follows:
var lowerBound = ...;
var upperBound = ...;
Then, I use the following command in Python:
from doopl.factory import *
with create_opl_model(model="model.mod") as opl:
opl.set_input("upperBound", 50)
opl.set_input("lowerBound", 1)
opl.run()
but the following error comes out:
ERROR at 17:18 model.mod: Scripting parser error: missing expression.
I would like to say that in the CPLEX .mod lines 17 and 18 are:
var lowerBound = ...;
var upperBound = ...;
Question: I wonder if only tuples are sent with opl.set_input ()
?
To understand this, I did something like the followings:
Inside CPLEX .mod:
tuple bounds {
int lowerBound;
int upperBound;
}
for (var i = lowerBound; i <= upperBound; i++) {
...
}
Inside Python:
from doopl.factory import *
Bounds = [
(1, 50),
]
with create_opl_model(model=" model.mod") as opl:
opl.set_input("bounds", Bounds)
opl.run()
But this time, there is an error like the following:
ERROR at 20:7 model.mod: Scripting parser error: missing ';' or newline between statements.
I would like to say that in the CPLEX .mod file line 20 is related to the definition of tuple bounds, which is:
tuple bounds {
int lowerBound;
int upperBound;
}
What could be the solution to this?