Solved

Issue with retrieving optimality gap and solution time

  • 17 July 2020
  • 9 replies
  • 123 views

Hi.

I am trying a generate a plot of optimality gap vs solution time. For that, I am trying to retrieve incumbent solution, best bound and solution time after every 5 iterations. But, for some reason, I am having issues with callback and I don’t get anything retrieved. Attached herewith are the images giving implementation of callback operation. Could anyone please tell where I am going wrong?

Thanks, 

Sujit

icon

Best answer by Marcel Hunting 17 July 2020, 11:14

I would set a break-point inside the callback procedure to first check whether the callback procedure is called. To do so you should add

  DebuggerBreakPoint;

at the beginning of the callback procedure, and rerun the model.

 

Note that you installed an iteration callback but named it as a time callback, which is confusing. To install a time callback you should use the suffix CallbackTime instead of CallbackProcedure. By default the time callback is called every two seconds; the interval is controlled by the option Progress Time Interval.

View original

9 replies

Userlevel 3

I would set a break-point inside the callback procedure to first check whether the callback procedure is called. To do so you should add

  DebuggerBreakPoint;

at the beginning of the callback procedure, and rerun the model.

 

Note that you installed an iteration callback but named it as a time callback, which is confusing. To install a time callback you should use the suffix CallbackTime instead of CallbackProcedure. By default the time callback is called every two seconds; the interval is controlled by the option Progress Time Interval.

Hi, Marcel.

You are right. I am using time callback after every 5 seconds.

I will try to implement your suggestion on break-point and see whether the callback procedure is called.

Thanks.

Any comments on the code in the callback procedure body?

Sujit 

 

 

Marcel,

I added a debugger break point and the procedure is being called.

 However, what I observed is optimality gaps/ solution time points are not being added to ‘Gap_Timepoints’/ ‘Set_ILP_Timepoints’ after every callback.

Could you help me on this part?

Thanks,

Sujit

 

 

Userlevel 3

Is the set GapPlot_TimePoints_Set filled? It could be that BestBoundSol and IncumSol are 'na’ at the beginning of the solve in which case Gap_TimePoints remains empty. You can check this by setting a break-point and look at the values of BestBoundSol and IncumSol.

The values of BestBoundSol and IncumSol were ‘na’ at the beginning. However, I obtained values for both these as the solution process progressed and OptGap got calculated. I also got values of solution time after every callback. But, the set GapPlot_TimePoints_Set did not get filled neither Gap_TimePoints did.

 

I again ran the simulation after commenting everything except ‘GapPlot_TimePoints_Set’ in the body of procedure ‘NewTimeCallback’ to see if time points were getting added. But, they weren’t and the set ‘GapPlot_TimePoints_Set’ was still empty. I am attaching an image of declaration of set ‘GapPlot_TimePoints_Set’. Please check if there is something wrong in the declaration of the set.

 

Thanks for your help on this. 

 

Userlevel 3

The set ‘GapPlot_TimePoints_Set’ is defined as a subset of Integers, which is ok. I don't see any mistakes. I tried something similar in AIMMS 4.74 and that worked fine. I assume that you do not empty the set ‘GapPlot_TimePoints_Set’ after the solve, and that the math program that you use inside the callback procedure is the same as the one that you are solving. Which AIMMS version are you using? Which options did you set in the project (if any)?

I am not emptying the contents of the set after the solve. The math program is also same as the one I have mentioned. The AIMMS version that I am using is v4.73. Other options set are for MIP relative optimality tolerance and simulation time limit. Attached is the script which I use for callback time procedure.

Userlevel 3

At this point I would have to inspect the AIMMS project to find out what is going on. Would you be able to share your project by sending it to our support? If that is not possible, we could schedule an online meeting such that I can look at your screen. Please send an email to our support if you want to schedule a meeting.

Sure, thanks. Let me write an email to Support to schedule a meeting.

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator