Originally posted by: Alireza.M
Hi,
Is there a way to define a problem in python using a model defined as a *.mod file and its external data in a *.dat file?
I know a workaround for this is to add an export statement at the end of mod file
main {
thisOplModel.generate();
cplex.exportModel("lpmodel.lp")
}
and then create the lp model either in command line or using "subprocess" or a similar module in python.
Then the problem can be built using
problem = cplex.Cplex("lpmodel.lp")
The problem with this approach is that I want to have the external data of dat file read into the problem and be able to change them dynamically. For example if there is a variable "n = 5;" in the dat file which is fed as an external data to the mod file, I want to be able to solve my problem with n=5 and then change n to 6 solve the problem again and so on (Obviously lp model changes if I change the value of n in this example, but the mod file does not need to change).
Is there a way to read the problem using the mod and dat file into python API of Cplex directly and then change values of the dat file, inside python, as data variables of the problem?
#CPLEXOptimizers#DecisionOptimization