# Heuristic callback CPLEX frequency

 1 I am trying to get the heuristic callback working in CPLEX 12.4 (C++, concert) . I have an MILP and a heuristic to convert fractional LP solution to a feasible integer solution and am implementing this algorithm in the heuristic callback. I also have user cuts implemented using the usercutcallback. At every node in the branch and bound tree, CPLEX calls the heuristic call back first followed by the usercutcallback. Is there a way to change the frequency at which the heuristiccallback is called. Typically I would like CPLEX to call the heuristic callback once every 5 times the LP is being solved at a node. Any help is appreciated. asked 21 May '14, 23:18 pondy 43●1●4 accept rate: 0%

 3 You could use a node callback to count the number of nodes cplex creates ILONODECALLBACKI(...){ ++numofnodes; }  And then as suggested above by David (I don't know how to make the smart tags): ILOHEURISTICCALLBACKI(...){ if(numofnodes % 5 == 0) Heuristic(); }  answered 22 May '14, 08:08 Sune 958●4●14 accept rate: 20% Aren't heuristic callbacks called at each node ? In this case, one call back is enough, don't you think so ? (22 May '14, 18:13) David I actually think you are right. The manual says "During branching, the heuristic callback is called after each node subproblem has been solved, including any cuts that may have been newly generated. Before branching, at the root node, the heuristic callback is also called before each round of cuts is added to the problem and re-solved." Therefore one callback is enough. (23 May '14, 02:49) Sune
 4 Since both callbacks are activated at every node, I suggest you add a counter member to your heuristic callback and in the main code of the heuristic callback , you condition the search for a new incumbent in the condition (here once every 5 times)  if (mycounter++ %5 ==0){ ... //heuristic to find a new incumbent }  answered 22 May '14, 06:28 David 306●1●6 accept rate: 12% A quite late comment: The heuristic callback can be called multiple times at the root node if more than one round of cuts is added. So if one want to employ the heuristic at every k node, one has to take care of that. However, if it should be called for every k solved LP, one should use the counter in the heuristic callback! (12 Jun '14, 09:20) Sune
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×191
×30