-
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
Support nonlinear constraints. #100
Conversation
- and scip/intervalarith.h for types - and nlpi/type_exprinterpret.h for types
- use Vector{Ptr{SCIP_EXPR}} instead for Julia calls - will be converted automatically be ccall
- don't use separate EXPR_CONST - this would lead to memory leak - see discussion at scipopt/CSIP#28
- was resetting bound for binary variables - needed to change order (first change type, then reset to old bounds) - error only appeared when using SCIP in debug mode
- don't recurse to create a subexpression for the exponent - instead, extract the numeric value and add directly
- replace :(child) with :(0 - child) in the MOI wrapper - can not easily fix this in the ManagedSCIP or risk memory leak. - enable (and fix) test
Hm, the Travis tests are inconsistent. Locally, the results seem to be non-deterministic:
|
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.
We just had a discussion how to test MINLP solvers. Basically JuMP is the most practical format to write down small test problems at the moment. You can try running against https://github.com/lanl-ansi/MINLPTests.jl in a separate travis stage to avoid the dependency on JuMP, e.g., https://github.com/JuliaOpt/AmplNLWriter.jl/blob/0aaad316c7b99907f619b4b00337d87ab4a0facf/.travis.yml#L28.
Output for the unbounded result:
|
Let me know if you need a hand interfacing MINLPTests. It is definitely the way to go. You should be able to pass all nlp and nlp-cvx tests. There are some issues with the mixed integed ones. |
OK, so I feel there is still some work on the table, in several steps:
|
Unfortunately, adding a |
Codecov Report
@@ Coverage Diff @@
## master #100 +/- ##
=========================================
+ Coverage 11.62% 12.9% +1.28%
=========================================
Files 130 134 +4
Lines 3967 4240 +273
=========================================
+ Hits 461 547 +86
- Misses 3506 3693 +187
Continue to review full report at Codecov.
|
While having SCIP print the problem in its representation, I found that weird values are shown for the constants in the failing cases (rather than
These look like access to unitialized memory. I checked the values just before the Just to be sure, I added |
In the other testset, it becomes more apparent that all constant values (inside the expressions) are corrupted:
In particular, the second argument of |
I was able to narrow down the problem further:
The three methods |
does it also go away if you just disable block memory (-DNOBLKMEM)? The idea of block memory is that scip allocates memory itself and the re-uses it. I don't see how this can cause this though |
I guess the problem has to be the way julia handles variadic c functions. I implemented a |
The Julia signatures for the call to |
Yes, that must be it. Changing the signature for |
Turns out that the expression that JuMP produces is actually this: Expr head: Symbol ref args: Array{Any}((2,)) 1: Symbol x 2: MathOptInterface.VariableIndex value: Int64 2 While I just tried `dump(:(x[MathOptInterface.VariableIndex(2)]))`, which gives something completely different: Expr head: Symbol ref args: Array{Any}((2,)) 1: Symbol x 2: Expr head: Symbol call args: Array{Any}((2,)) 1: Expr head: Symbol . args: Array{Any}((2,)) 1: Symbol MathOptInterface 2: QuoteNode value: Symbol VariableIndex 2: Int64 2
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.
Any reason to only test a couple of MINLPTests instead of the full set (excluding the ones with trig functions etc)?
Yes: I had to change the Also, I handpicked the few that are supported, which is a smaller list than the excluded ones:
|
It's not very had to add support for |
Well, I meant that with an objective bridge, we could support quadratic and nonlinear objectives. The objective bridge itself will probably require SingleVariabe objectives, so that it makes sense to support it manually. |
- operator `\`, is not even supported through JuMP/MOI?
- previously only allowed one type of constraint per variable - now also allow simultaneous LessThan and GreaterThan constraints
- allow JuMP's sum(...) for singleton sets
So, the major thing left to do is the C wrapper for Actually, I'm not so sure how to do that after all. For The only workaround I can figure out now is to pass an array of UPDATE: I'd rather merge this PR now, and deal with that issue later (#101). |
Fixes #93.
This adds support for nonlinear constraints based on
:ExprGraph
. The Julia expression is converted to an intermediate array-based representation which is then converted to a SCIP-style expression graph.The code is mostly translated from CSIP and the old MathProgBase wrapper. However, the handling of powers (with constant exponent) and unary minus is done earlier, to avoid memory leaks or worse.
I hope that the tests that I created use the same expression format that would also be generated by JuMP. I'm tempted to use JuMP for additional tests, but don't want cyclic dependencies.
EDIT: No longer using the intermediate representation, so the CSIP layer is basically removed now.
EDIT: Still waiting for input on how to fix the non-deterministic behavior related to constant expressions.