-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for constraint handlers #109
Conversation
Very early sketches, still. First idea is to have an I wanted to define methods (with nice Julia signatures) for the callbacks. But it's not quite clear yet how I will get a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it's not quite clear yet how I will get a
@cfunction
pointer of these (after dispatch!).
You don't. You provide a top-level function that redirects to the user methods. See, e.g., https://github.com/JuliaOpt/Ipopt.jl/blob/7aa1943f263a9b5ea29cf5e66c85c1c6e3aede49/src/Ipopt.jl#L195.
Yeah, we did something similar in the old SCIP.jl (lazycb_wrapper). In the IPOPT example, the user-defined Julia function is stored in the |
I've also wondered whether to use |
Codecov Report
@@ Coverage Diff @@
## master #109 +/- ##
==========================================
+ Coverage 16.63% 17.72% +1.09%
==========================================
Files 135 138 +3
Lines 4311 4377 +66
==========================================
+ Hits 717 776 +59
- Misses 3594 3601 +7
Continue to review full report at Codecov.
|
Have a bare-bones implementation, with a minimal (passing) test of a dummy constraint handler that does nothing (but the callbacks are being called). Next step would be a more involved test/example that involves MOI, to see what kind of utility methods will be needed to make the mappings between I'm already worrying about using Julia objects (that can be GCed) as |
src/conshdlr.jl
Outdated
# https://scip.zib.de/doc-6.0.1/html/CONS.php#CONS_FUNDAMENTALCALLBACKS | ||
|
||
# possible return values: | ||
# SCIP_FEASIBLE: given solution is satisfies the constraint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/is satisfies/satisfies/ (below as well)
src/conshdlr.jl
Outdated
|
||
# possible return values: | ||
# SCIP_FEASIBLE: given solution is satisfies the constraint | ||
# SCIP_INFEASIBLE: given solution is violates the constraint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/is violates/violates/
Do you mean for the pure SCIP interface or for MOI? For MOI, could you create (and then free) these during the |
I feel that it can affect both. I imagine that these objects are really created by the (MOI) user, just like you would create a A related issue is that the callback (on the SCIP/C side) receive a By the way, I appreciate that you read the updated code, but I don't think it's ready for review, yet. I have not figured out what level of detail to expose to the SCIP.jl users and the variable naming is all over the place. For instance, I would like to make it clear whether a an argument is of type I already started working on the example of a lazy linear constraint handler and it's not so obvious how to give the user access to the solution values. A |
- still need to reference conshdlr by name (string) :-\
- store mapping from Julia object to SCIP pointer - no longer rely on name for mapping - protect against GC (somewhat)
- we need at least the SCIP_SOL* for CHECK
- don't actually free any memory (should be handled by Julia GC) - but set some pointer to NULL in SCIP, to pretend it was freed - TODO: check this with valgrind or similar?
Co-Authored-By: Mathieu Besançon <[email protected]>
- they are failing often (which we allow) - they take quite a while, especially on OSX - the MINLPTests will only start after these have finished, taking even longer
OK, I have now done everything that I had planned to do, so I consider it ready for review. Before merging it, I would like to test it with a real-word usage case (PipeLayout.jl) first, which will take some time. |
I was pondering on changing the MOI-facing function include_conshdlr to use But it's not clear what the benefits are, for the user. Would it be easier to |
So, this works well enough for my use-case (treetopohdlr.jl, semisubhdlr.jl, cbtopo.jl) that I would like to merge & release at this point, if there are no objections or questions. |
Seems reasonable to merge this and look at proper support from JuMP in a separate PR. |
You mean in a solver-independent way? I find the way I create constraints from callbacks nice enough, based thinly on |
@rschwarz, just in a documented way that's usable without PipeLayout.jl, not solver-independent :) |
Good point. Maybe this calls for a tested example, as another JuMP-dependent test stage just like MINLPTests. |
Or even in an example folder called from the normal travis build (if small enough that should be fine with build time) |
But then we have the problem again that we can not upgrade SCIP to a new version of MOI as long as a compatible JuMP is not released. |
Adresses part of #94.