1

I want to run the MOD file from Python, which was written in CPLEX with OPL before. Information about this is discussed in some links, for example, explanations about the zootupleset.mod and doopl package are available at the following links:

How to run a .mod file (CPLEX) using python?

https://pypi.org/project/doopl/

https://optmsr.com/very-simple-opl-call-opl-from-python/

But what I want to ask that is it possible to define parameters in python and send them in CPLEX instead of data file? What can not be done for this? In this case, how should parameters be defined in mod and Python files? Is it necessary to define an initial in the mod file and then receive it from Python?

Aydin
  • 167
  • 1
  • 7

1 Answers1

2

3 ways to set Cplex parameters in making optimization simple

https://github.com/AlexFleischerParis/zooopl/blob/master/zoosetting1.mod

If your parameters are in python and you want to send them to opl through doopl what I recommend is to send a tuple set with the parameters in python and then in opl scripting part you use that tuple set to set Cplex settings through scripting

Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • 1
    Thank you so much for your reply. I would like to ask one more question; in the next example: https://stackoverflow.com/questions/60598747/how-to-run-a-mod-file-cplex-using-python `tuple bus { key int nbSeats; float cost; }` This part is defined in Cplex. Is the corresponding part in Python the following: `Buses = [ (40,500), (30,400) ] ` is it? Is this sent for the bus tuple? As: `opl.set_input("buses", Buses)`? – Aydin Sep 06 '20 at 21:00
  • 2
    Yes and many other opl Cplex simple examples at https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer – Alex Fleischer Sep 07 '20 at 05:13