-
Notifications
You must be signed in to change notification settings - Fork 252
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 method for adding piecewise linear constraints #776
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #776 +/- ##
==========================================
- Coverage 52.72% 52.49% -0.24%
==========================================
Files 17 18 +1
Lines 3831 3848 +17
==========================================
Hits 2020 2020
- Misses 1811 1828 +17 ☔ View full report in Codecov by Sentry. |
@Joao-Dionisio I'm not sure on this change. I'll put some reasons as to why.
Also as a small question (haven't yet written everything down to check fully): Is the SOS1 constraint necessary? Or would a sum of the binary variables suffice? Regardless I think something like this should be made into an example or a test. I just disagree with making it a foreard facing functionality for users. |
Yeah, I understand your reservations, but I think having the possibility of doing something like this does not prevent the user from using their own formulations. Also, if I'm not an expert and just want to use SCIP to solve a simple industry problem, having to go through all the trouble of defining a piecewise linear constraint can be super annoying, especially considering the many ways of doing it. I agree that before an eventual merge, some more research into something more efficient than the direct way of doing this is necessary, and maybe we should add a disclaimer to the documentation saying that the method is precisely to facilitate modeling, it's not supposed to be the best way of solving the user's problem. Regarding the SOS1, you're right, the sum would suffice. I just figured that SCIP's SOS1 constraints would somehow be more efficient, but I have no clue. Your final comment about turning this into an example is interesting because what I did was just grabbing this from the examples :) But yeah, in the end, it does come down to how user-friendly we want PySCIPOpt to be, and you guys should have the final word on this, of course. |
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.
Thanks a lot @Joao-Dionisio! I'm all for convenience functions. I will respond to @Opt-Mucca's reservations in another comment.
Hey @Opt-Mucca 😄
We can solve this by adding a disclaimer or clearly defining where the formulation comes from.
It does not decide on it. Maybe even in the future when there are multiple formulations implemented another parameter
This can be mentioned in the docstring of the method and could be improved in a next iteration without changing the API I believe.
This ultimately saves some time for users who are new to the topic. I think what we should guarantee is that the function is correct and that the documentation is clear and try to make it more general. So with the changes I mentioned above, what do you think? |
@Joao-Dionisio for the SOS1 constraint you should interpret it as the following: At most one entry in the constraint can be non-zero. |
@mmghannam Hallo! So I do feel that this automatic formulation is a current trend, and is probably very helpful to users. It just starts blurring the line between what packages like these are traditionally supposed to offer. Before adding such a function I would suggest making thorough tests to ensure the formulation is correct. Functionality like this now allows a new type of error to exist, in that it's not a communication issue with SCIP or a simple SCIP error, but an actual incorrect model (of course this has existed before, but it was very easy to locate and fix because the functions are mostly just wrappers). I would also be more for making the function more general than just 2-D. Could we not just accept and a list of lists and pretend it's a matrix and then model arbitrary dimensions? |
Thanks for the explanation on SOS1 constraints, @Opt-Mucca! I had never really looked into them. Agreed on the generalization and on the more thorough testing. |
… into piecewise-linear
Someone requested a method for adding piecewise linear constraints. I just converted the relevant finished example to
scip.pxi
. Using a draft because there are more efficient ways of doing this (both algorithmically but also by using more C functions).