1

I have a data file inputpy.xlsx and I am converting this file to an opl input language(1 and 0) called outputpy.xlsx, and I have a working opl model that takes my outputpy.xlsx file and outputs to an excel file(oploutput.xlsx) from cplex ide.

However, my problem is I am currently running both of them separately. First I am running python code to make outputpy.xlsx and than I am using cplex ide to make oploutput.xlsx.

My question is :

How can I call/run my cplex code from my python code, after I created the outputpy.xlsx in python? I don't want to run python code and then run the cplex ide separately.

what I find online is some suggest using python API or doccplex, I am not sure the difference between them. I believe that using python API I have to change the cplex code for the python language, and I also can't find the nice tutorial for this.

Do you have suggestions? Thank you in advance.

amelda
  • 11
  • 2

1 Answers1

0

One very simple way to do this is to use oplrun instead of the IDE. Using oplrun you can run a project and/or mod file from the command line. Then you can invoke this from Python using subprocess.popen() or just os.system() (see this related question).

The description of oplrun can be found in the reference documentation in chapter IDE and OPL > oplrun command line interface

In order to run OPL directly from Python you could have a look at the doopl package.

Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22