Forum Discussion
FICO
9 years agoCommunity Manager
Implementing Lazy Constraints (C++)
I'm implementing a B&Cut algorithm with BCL - C++ using the cut manager callback.
Also I have to implement Lazy Constraints, that is, after each integer solution, search the violated constraints and add it.
Now, I'm using XPRSsetcbintsol callback to detect all the integer solutions during the B&B. In my actual code, after some interations yes... the callback detect an integer solution, for that, there are a violated constraint, I indicate that this constraint is a lazy constraint with "setDelayed(true)" but, in the next iteration the MIP optimizer said "optimal solution"... that is, finish the search through the tree and the last solution is the same that if i don't add the lazy constrait... some help? I'm not sure if i'm using the correct callback (setcbintsol), or if I need to disable (or able) come option for this function.
5 Replies
- FICOCommunity Manager
The delayed constraint property can only be set before you load the problem into the solver, not during the MIP search.
If you wish to add cuts, you need to do so via the 'addCuts' routine in the cutmanager callback.
Furthermore, if you wish to be able to reject an integer solution, this can be done in the 'preintsol' callback.
- FICOCommunity Manager
Thanks,
And... inside the preintsol callback...what is the funtion to reject the integer solution? there are some example code?
- FICOCommunity Manager
From within the preintsol callback in a Mosel model you can call the subroutines 'rejectintsol' and 'setcbcutoff' to pass information back to Xpress-Optimizer (see documentation of 'setcallback' in the Mosel Language Reference Manual).
For instance, using some code like the following where the test 'check_some_condition' is assumed to be implemented by your model:
public procedure mypreintsol(isheur:boolean,cutoff:real)
if check_some_condition then
rejectintsol
end-if
end-function
! ... problem definition ...
setcallback(XPRS_CB_PREINTSOL, "mypreintsol")
! ... start optimization ...
- FICOCommunity Manager
I'm working with BCL C++, which is the way to used 'rejectintsol' and 'setcbcutoff' callbacks... (I've searched in the Mosel Language Reference Manual as you suggested, but is not available to C++).
- FICOCommunity Manager
With BCL you can directly use the callback functions of the Xpress Optimizer library; for BCL C++ these would be the C library functions of the solver as shown, for example, in https://examples.xpress.fico.com/example.pl?id=bcl_cpp_18_6
The subroutines 'rejectintsol' and 'setcbcutoff' that I have mentioned earlier are auxiliary routines for working with Optimizer callbacks in Mosel; if you are directly using the C functions, all information is passed back via arguments of the corresponding callback function. Please take a look at the documentation of 'XPRSsetcbpreintsol' in the Xpress-Optimizer Manual for a description of its arguments. Its use is similar to some of the other node callback functions shown in https://examples.xpress.fico.com/example.pl?id=optimizer_c_1
Related Content
Related Content
- 0Views0likes1Comment
Implementation of B&B with python
HI! I'm trying to implement a branc-and-bound solver by using the python interface of Xpress. I implemented a MINLP model, and I am trying to solve the linearization with the B&B algorithm. Even t...8 months agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum4 unread comments4 unread2Views0likes4CommentsImplementing Lazy Constraints (Java)
We are interested in using Lazy Constraints in Xpress (Java) to implement a TSP algorithm. In particular, after each integer solution is generated, we would like to search for violated constraints an...10 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum6 unread comments6 unread0Views0likes6Comments