0

I asked my question before. However, because I did not put my code I never get my answer. I'm new in CPLEX and I need help. my code tries to solve a p median problem. I created an OPL project which contains one mod and one data file. The code is :

//
execute{
var before = new Date();
temp = before.getTime();
}

execute {

  var f = new IloOplInputFile("1.csv");
 ...
    }
  }
  writeln(index);
  writeln(weight);
}
 float d[...][...];
execute {
var f = new IloOplInputFile("2.csv");
...     
    }
  writeln(d);
}
}

 dvar boolean x[...][...];
 dvar boolean y[...];   
// Objective Function
dvar float obj;
minimize obj;
//Constraints
 subject to {
...
 } 

 //Get the runtime in ms
 float soltime;
  execute{
var after = new Date();
soltime = after.getTime()-temp;
}
...
//Output in a CSV file
execute{
...
var f=new IloOplOutputFile("3.csv");
f.writeln(...);
f.close();
}

This is not a complete code. I just want to show what my code contains some execute block and minimizing objective function and its constraints. Because I work with large dataset solving this problem takes so much time. I wanted to limit this solving time to 1 hour and also try to change the gap between the lower and upper bound. But when I tried to use :

execute PARAMS{
CPLEX.tilim=...
CPLEX.egap=...
} 

in the following of my code, nothing happened. I know I got some answers like I need to do it in flow control or scripts or... but I want to know with more details that what should I exactly do. Do I need to mod files? Should I add some file? Please help me.

MOn
  • 11
  • 5
  • 1
    Possible duplicate of [Set limitation on gap tolerance and run time](https://stackoverflow.com/questions/56448457/set-limitation-on-gap-tolerance-and-run-time) – Xavier Nodet Jun 08 '19 at 07:49
  • 1
    I modified the answer that you received to your first question. Note also that `egap` is incorrect. It should be `epgap`. – Xavier Nodet Jun 08 '19 at 07:58
  • You have a pmedian example in CPLEX_Studio129\opl\examples\opl\pmedian – Alex Fleischer Jun 08 '19 at 12:03
  • Somewhat off topic, but: how large is your dataset? Cplex should be able to solve very large p-median instances in minutes. Is there anything weird or pathological about your data? – LarrySnyder610 Jun 09 '19 at 13:52
  • It has more than 400 number of nodes but less than 1000. It tried to allocate a different number of facilities. The problem is that it takes more than an hour and I cannot change this in any way. – MOn Jun 09 '19 at 19: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 10 '19 at 21:12
  • Can you show the relevant parts of your mod file and also the engine log output? By how much does CPLEX overshoot your time limit? What is the time limit and what is the solution time? – Daniel Junglas Jul 10 '19 at 10:19

0 Answers0