-2

I have two questions:

  1. In IBM ILOG CPLEX, I wrote an OPL project. Because the code works with large scale data, it takes a lot of time to solve. What is the code for limitation the gap tolerance of MIP Problem and limitation the time?

  2. I want to have a CSV file containing my desired results. For example, I want to have an objective function and runtime and the facility variable in a CSV file. I got all these results but I want them to be written in a CSV file too.

Pika Supports Ukraine
  • 3,612
  • 10
  • 26
  • 42
MOn
  • 11
  • 5

1 Answers1

2

1) Add the following code before the minimize statement in your .mod file.

execute
{
   cplex.tilim=30; // 20 s time limt
   cplex.epgap=0.01 // 1% gep
}

You can confirm that it is taken into account by examining the engine log. It should have something like this at the very beginning:

CPXPARAM_TimeLimit                               30
CPXPARAM_MIP_Tolerances_MIPGap                   0.01

2) You may rely on IloOplOutputFile

See example in https://www.ibm.com/developerworks/community/forums/html/topic?id=3fd44d41-210b-4b81-a005-819530d6377b&ps=25

halfer
  • 19,824
  • 17
  • 99
  • 186
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • Thanks for your response. My problem for writing results in CSV file is that one of the things is a variable y=[10000101010] and I just want to write indexes of the columns equal to 1. Do you have any idea? Also when I use cplex.tilim in my code it doesn't affect and my code run so much longer than what I want. – MOn Jun 04 '19 at 19:47
  • See the example warehouse.mod {int} Storesof[w in Warehouses] = { s | s in Stores : Supply[s][w] == 1 }; is an example on how to get all indexes with value 1 – Alex Fleischer Jun 05 '19 at 05:58
  • Instead of writing the parameter settings in your code, you may also use a settings (OPS) file. – Daniel Junglas Jun 06 '19 at 11:11
  • I tried this code and in engine log, it's exactly brought my desired limitation. But the solution time that I get from my code is more than the limitation that I choose. – MOn Jun 09 '19 at 19:09