2

Anyone know how to set the epgap parameter for CPLEX solver when calling CMD_CPLEX() from PULP (python)?

I have tried everything from an options file in the folder to tons of different syntax attempts like:

prob.solve(CPLEX_CMD(options = ['epgap = 0.25']))

Any tips would be greatly appreciated!

senderle
  • 145,869
  • 36
  • 209
  • 233
user3431083
  • 404
  • 5
  • 19

1 Answers1

4

As you probably know, the CPLEX_CMD solver is a wrapper around the CPLEX interactive. To set parameters, you need to use the same syntax that you'd use within the interactive. So, to set the relative MIP gap tolerance parameter, you'd want to use the following syntax:

prob.solve(CPLEX_CMD(options=['set mip tolerances mipgap 0.25']))
rkersh
  • 4,447
  • 2
  • 22
  • 31
  • It worked! Thank you so much. How did you know this? The documentation is sparse - I searched online for weeks. Is there a repository to your knowledge with more commands and parameter syntax? – user3431083 Sep 18 '17 at 23:01
  • 1
    I had to look at the [source code](https://github.com/coin-or/pulp) and run a few experiments. As you said, the documentation is sparse. – rkersh Sep 18 '17 at 23:18
  • rkersh, I searched the source code like you did, I think, for WorkMem [link](https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.4.0/ilog.odms.cplex.help/CPLEX/User_manual/topics/uss_solveMIP_61.html). It does not look like PULP support setting that parameter, if I am doing this right - could you confirm? I looked through pulp/src/pulp/solvers.py – user3431083 Sep 21 '17 at 14:18
  • The source code shows us that you can enter any parameter in the `options` list. As I said, you just have to use the syntax that is supported in the CPLEX interactive. So, for [WorkMem](https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.1/ilog.odms.cplex.help/CPLEX/Parameters/topics/WorkMem.html), you would add `'set workmem 2048'` to the options list (where 2048 is the number of megabytes). – rkersh Sep 21 '17 at 16:08
  • Thanks rkersh! I understand now and will use this method going forward. Kind regards and thanks again friend. – user3431083 Sep 21 '17 at 16:11