In the Options Tree, I have been changing the MIP Relative Optimality Tolerance to 0.5%, 1.0%, 5.0% and 10.0% to analyse the performance of the solution, gap and solving time.
I wish to change the gap to 0.5%, 1.0%, 5.0% and 10.0% to analyse whether the solving time can be reduce by changing the gap. However, the CPLEX always stop at either 0.04%, 0.12% or 0.00% of gap. Is there any way to stop the CPLEX at 10% of gap?
OptionSetValue('MIP Relative Optimality Tolerance', 0.10);
Your model might be finding the first integer feasible solution with 0.00%/0.04% GAP.
I would also check if the model type in your Mathematical Program Identifier is set to MIP.
I have try the code that you mentioned. I also have tried these methods:
- Mathematical Program Identifier is set to MIP
- changing the MIP Relative Optimality Tolerance in the Options Tree
- and lastly:
solve MathProg where MIP_Relative_Optimality_Tolerance := 0.1;
However, the CPLEX stop at 0.00%. Is there any way to stop the CPLEX at 10% of gap?
I have try the code that you mentioned. I also have tried these methods:
- Mathematical Program Identifier is set to MIP
- changing the MIP Relative Optimality Tolerance in the Options Tree
- and lastly:
solve MathProg where MIP_Relative_Optimality_Tolerance := 0.1;
However, the CPLEX stop at 0.00%. Is there any way to stop the CPLEX at 10% of gap?
Like
Can you share a screenshot of the progress window after this solve ? CTRL+P to open the progress window. Looking at the number of iterations, time it to reach optimality will help in finding out what's happening here.
Also, you do not need both "changing the MIP Relative Optimality Tolerance in the Options Tree" and "using the where keyword in the solve statement". Using solve mathprogram where .... would be better for your use case as changing the options tree will apply that option value to all solve statements in your project.
Before you mention this, i did set both "changing the MIP Relative Optimality Tolerance in the Options Tree" and "using the where keyword in the solve statement". Attached together is the screenshot of the progress window and the two setting that i change.
For your information, right now I'm trying to re-run the model with only one setting, which is using the where keyword in the solve statement as you suggested. I will share the latest progress window later after the AIMMS stop running.
By the way, can you explain this to me:
- In the progress window, what exactly is means by (Gap = 0.04%)? is it 0.04% of optimality gap, or 4% of optimality gap, or something else?
- and if it is 4% of optimality gap, does it means that 96% of it is the best solution, meanwhile 4% of it is the less best solution?
Thanks for your help, I really appreciate it.
Hi
In the progress window, what exactly is means by (Gap = 0.04%)? is it 0.04% of optimality gap, or 4% of optimality gap, or something else?
I think it is 0.04% of optimality gap.
Gap is defined as below
" |Incumbent - bestbound| / |Incumbent| ]*100
where Incumbent is the objective value of the current integer solution found and bestbound is the objective value of the LP relaxation. It is an indication of how far off is the integer solution from the relaxed solution.
Based on the progress window, your model is quite large and it would be unusual for the very first incumbent to be at gap 0%. Your math program should have terminated based on the stop criteria you used. However, you can do a simple experiment using callback functions to get the data you want. The below code will retrieve the gap of the math program every 10 seconds.
First, create a set and parameter as below.
Set sIntervals {
Index: iInterval;
Parameter: epInterval;
}
Parameter pGap {
IndexDomain: iInterval;
}
Now create a procedure as below.
Procedure prTimeCallback {
Body: {
!will dynamically create elements in set sIntervals
SetElementAdd(
Setname : sIntervals ,
Elempar : epInterval ,
Newname : FormatString("%n s", MathProgram.SolutionTime ));
!calculate the gap and store in pGap. Retrieves Incumbent and bestbound value
pGap(epInterval) := (abs(MathProgram.Incumbent - MathProgram.bestbound)/$abs(MathProgram.Incumbent)) * 100;
}
}
Now, edit your solve statement as below.
!sets interval as every 10 seconds, change this value for more or less frequency
option progress_time_interval := 10;
!sets prTimeCallback as the procedure to be executed every 10 seconds
MathProgram.CallbackTime := 'prTimeCallback';
solve MathProgram;
Replace MathProgram with the name of your mathematical program, in your case it would be UniversityCourseTimetabling. As your solve took ~200 seconds, you should get 20 values showing how the gap is changing with time.
If you want to do this every time an incumbent is found instead of every 10 seconds, use MathProgram.Callbackincumbent instead of MathProgram.Callbacktime
In situations like this where you want to find out what CPLEX is doing during the solve you should print the CPLEX status file which can be done by setting the folllowing options:
- Solvers General option 'Solver listing messages' to 'All'
- CPLEX option 'MIP display' to 'Display each nth node'
The CPLEX status file will be printed in the log folder. It will tell you exactly which incumbent solutions it found and the corresponding gap. Please attach the CPLEX status file here if you find it difficult to interpret it.
Hi
In the progress window, what exactly is means by (Gap = 0.04%)? is it 0.04% of optimality gap, or 4% of optimality gap, or something else?
I think it is 0.04% of optimality gap.
Hi
Attached together is the screenshot of the latest progress window for this request:
Can you share a screenshot of the progress window after this solve ? CTRL+P to open the progress window. Looking at the number of iterations, time it to reach optimality will help in finding out what's happening here.
Also, you do not need both "changing the MIP Relative Optimality Tolerance in the Options Tree" and "using the where keyword in the solve statement". Using solve mathprogram where .... would be better for your use case as changing the options tree will apply that option value to all solve statements in your project.
For your information, CPLEX still give me the result of 0.0% gap.
I will try the coding that you share to see the result.
However, you can do a simple experiment using callback functions to get the data you want. The below code will retrieve the gap of the math program every 10 seconds.
Please attach the CPLEX status file here if you find it difficult to interpret it.
Hi
Can you please interpret the file for me? Thank you in advance.
The CPLEX status file shows that CPLEX only finds one integer solution (incumbent) during the solve, with a gap of 0.01%. (So, the only integer solution that CPLEX finds is very good, namely optimal or nearly optimal.)
That means that if you set the relative optimality gap to a value that is higher than 0.01% then CPLEX will immediately stop after finding this integer solution, and the final gap will always be 0.01%. (So for this instance it is not possible to make CPLEX stop with a gap of 10%.)
Hi
Noted. Thanks for your help.
As your solve took ~200 seconds, you should get 20 values showing how the gap is changing with time.
Hi
When the CPLEX is done running, where can I see the values?
When the CPLEX is done running, where can I see the values?
You can see those values in the data of parameter pGap.
However, from your log file and Marcel’s comments - it seems like CPLEX is finding only one incumbent solution, which is at gap 0%. So, doing this experiment might not be helpful to you.
You could replace Mathprogram.Incumbent with Mathprogram.objective in the definition of gap, but I expect that to not be helpful either.
However, from your log file and Marcel’s comments - it seems like CPLEX is finding only one incumbent solution, which is at gap 0%. So, doing this experiment might not be helpful to you.
You could replace Mathprogram.Incumbent with Mathprogram.objective in the definition of gap, but I expect that to not be helpful either.
Noted. Thank you for the help, Mohan.
Reply
Sign up
Already have an account? Login
Please use your business or academic e-mail address to register
Login to the community
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.