0

I want to find the solution time of my model in CPLEX and I used the following code:

float temp;
execute{
var before = new Date();
temp = before.getTime();
 }
// solve the model
execute{
var after = new Date();
writeln("solving time ~= ",after.getTime()-temp);
 }

But the result is : 1.5592e+ 12, which is a huge number. So, do you know how can I reach to the the solution time in second or millisecond?

MOn
  • 11
  • 5
  • From [these docs](https://www-01.ibm.com/support/docview.wss?uid=swg21401522) (where it seems your code snippet comes from): "The getTime function returns the number of milliseconds since 00:00:00 UTC, January 1, 1970. As this number might be huge, make sure that numerical issues don't disrupt your results. If they do affect your results, you might have to subtract a big number from both variables, in order to manipulate smaller numbers and avoid a loss of accuracy." – LarrySnyder610 May 30 '19 at 00:50
  • This is more of a pure javascript question rather than something related to cplex, correct? The number you're getting is in milliseconds, but you can convert that into seconds, minutes, etc. using the techniques described at https://stackoverflow.com/questions/41632942. – rkersh May 30 '19 at 15:39
  • I did this code in CPLEX. Thankd for your response. – MOn May 30 '19 at 16:05

1 Answers1

0

This is more of a pure javascript question rather than something related to CPLEX. The number you're getting is in milliseconds, but you can convert that into seconds, minutes, etc. using the techniques described at stackoverflow.com/questions/41632942. For example:

var timeDiff = after.getTime() - temp;
// Convert from milliseconds to seconds.
timeDiff /= 1000;
// Display diff in seconds.
writeln("solving time ~= ", timeDiff);
rkersh
  • 4,447
  • 2
  • 22
  • 31