Skip to main content
Solved

Issue with retrieving optimality gap and solution time

  • July 16, 2020
  • 11 replies
  • 267 views

Forum|alt.badge.img

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

Best answer by Marcel Hunting

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.

11 replies

Marcel Hunting
AIMMSian
Forum|alt.badge.img+4
  • AIMMSian
  • 258 replies
  • Answer
  • July 17, 2020

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.


Forum|alt.badge.img
  • Author
  • Ace
  • 13 replies
  • July 17, 2020

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 

 

 


Forum|alt.badge.img
  • Author
  • Ace
  • 13 replies
  • July 17, 2020

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

 

 


Marcel Hunting
AIMMSian
Forum|alt.badge.img+4
  • AIMMSian
  • 258 replies
  • July 20, 2020

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.


Forum|alt.badge.img
  • Author
  • Ace
  • 13 replies
  • July 20, 2020

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. 

 


Marcel Hunting
AIMMSian
Forum|alt.badge.img+4
  • AIMMSian
  • 258 replies
  • July 20, 2020

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)?


Forum|alt.badge.img
  • Author
  • Ace
  • 13 replies
  • July 20, 2020

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.


Marcel Hunting
AIMMSian
Forum|alt.badge.img+4
  • AIMMSian
  • 258 replies
  • July 20, 2020

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.


Forum|alt.badge.img
  • Author
  • Ace
  • 13 replies
  • July 21, 2020

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


Can you tell what the solution was?


mohansx
Forum|alt.badge.img+5
  • Former AIMMSian
  • 223 replies
  • August 17, 2021

@Hannah Forster ,  the other user’s issue was related to time units/quantities and rounding that they used for the x-axis of the plot. 

 

What difficulties are you having ? 



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

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