-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Replace deprecated SCIP cons_quadratic.h #3027
base: main
Are you sure you want to change the base?
Conversation
The function `SCIPcreateConsBasicQuadratic()` along with the entire `cons_quadratic.h` file are deprecated -- instead, we should use `SCIPcreateConsBasicQuadraticNonlinear()` which takes the same arguments. For reference see the SCIP docs: SCIPcreateConsBasicQuadratic: https://www.scipopt.org/doc/html/group__CONSHDLRS.php#gad3707e7f7166bea83b7713cf2e52b0db SCIPcreateConsBasicQuadraticNonlinear: https://www.scipopt.org/doc/html/group__CONSHDLRS.php#gabef6770f404754e7503f68a7da9ad6da
This break the bazel build, trace: ERROR: /home/runner/work/or-tools/or-tools/ortools/linear_solver/BUILD.bazel:50:11: Compiling ortools/linear_solver/scip_proto_solver.cc failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 55 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
In file included from ortools/linear_solver/scip_proto_solver.cc:36:
ortools/linear_solver/scip_proto_solver.cc: In function 'absl::lts_20211102::Status operations_research::{anonymous}::AddQuadraticConstraint(const operations_research::MPGeneralConstraintProto&, const std::vector<SCIP_Var*>&, SCIP*, SCIP_CONS**, std::vector<SCIP_Var*>*, std::vector<double>*, std::vector<SCIP_Var*>*, std::vector<SCIP_Var*>*, std::vector<double>*)':
ortools/linear_solver/scip_proto_solver.cc:243:7: error: 'SCIPcreateConsBasicQuadraticNonlinear' was not declared in this scope; did you mean 'SCIPcreateConsBasicQuadratic2'?
243 | SCIPcreateConsBasicQuadraticNonlinear(scip,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./ortools/base/status_macros.h:33:40: note: in definition of macro 'RETURN_IF_ERROR'
33 | if (const ::absl::Status status = (expr); status.ok()) { \
| ^~~~
./ortools/linear_solver/scip_helper_macros.h:39:49: note: in expansion of macro 'SCIP_TO_STATUS'
39 | #define RETURN_IF_SCIP_ERROR(x) RETURN_IF_ERROR(SCIP_TO_STATUS(x));
| ^~~~~~~~~~~~~~
ortools/linear_solver/scip_proto_solver.cc:242:3: note: in expansion of macro 'RETURN_IF_SCIP_ERROR'
242 | RETURN_IF_SCIP_ERROR(
| ^~~~~~~~~~~~~~~~~~~~
ortools/linear_solver/scip_proto_solver.cc: In function 'absl::lts_20211102::Status operations_research::{anonymous}::AddQuadraticObjective(const operations_research::MPQuadraticObjective&, SCIP*, std::vector<SCIP_Var*>*, std::vector<SCIP_Cons*>*)':
ortools/linear_solver/scip_proto_solver.cc:492:24: error: 'SCIPcreateConsBasicQuadraticNonlinear' was not declared in this scope; did you mean 'SCIPcreateConsBasicQuadratic2'?
492 | RETURN_IF_SCIP_ERROR(SCIPcreateConsBasicQuadraticNonlinear(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./ortools/base/status_macros.h:33:40: note: in definition of macro 'RETURN_IF_ERROR'
33 | if (const ::absl::Status status = (expr); status.ok()) { \
| ^~~~
./ortools/linear_solver/scip_helper_macros.h:39:49: note: in expansion of macro 'SCIP_TO_STATUS'
39 | #define RETURN_IF_SCIP_ERROR(x) RETURN_IF_ERROR(SCIP_TO_STATUS(x));
| ^~~~~~~~~~~~~~
ortools/linear_solver/scip_proto_solver.cc:492:3: note: in expansion of macro 'RETURN_IF_SCIP_ERROR'
492 | RETURN_IF_SCIP_ERROR(SCIPcreateConsBasicQuadraticNonlinear(
| ^~~~~~~~~~~~~~~~~~~~
INFO: Elapsed time: 896.160s, Critical Path: 38.07s Maybe need to bump the version first: Lines 84 to 90 in 2cb85b4
|
Hmm, strange because
It seems to be a Python/SWIG issue -- the C++ function expects |
The linear_solver.i is missing the wrapping of the MPModelRequest.
I will fix this asap.
Laurent Perron | Operations Research | ***@***.*** | (33) 1 42 68 53
00
Le dim. 2 janv. 2022 à 02:17, Jediah Katz ***@***.***> a
écrit :
… Hmm, strange because nonlinear.h exists in commit
6acb7222e1b871041445bee75fc05bd1bcaed089 of the SCIP repo. Unfortunately
though, I realized that the issue is less simple than I originally thought.
The all-zero values problem was caused by me using Solve() instead of
SolveWithProto(), but when I use SolveWithProto() then I get an error
with the following trace:
Traceback (most recent call last):
File "ortools_samples/quadratic.py", line 88, in <module>
print(pywraplp.Solver.SolveWithProto(linear_solver_pb2.MPModelRequest(model=input_proto.model), solution))
File "/home/jediahkatz/.cache/pypoetry/virtualenvs/pythonsat-yDcEWZll-py3.8/lib/python3.8/site-packages/ortools/linear_solver/pywraplp.py", line 358, in SolveWithProto
return _pywraplp.Solver_SolveWithProto(model_request, response)
TypeError: in method 'Solver_SolveWithProto', argument 1 of type 'operations_research::MPModelRequest const &'
It seems to be a Python/SWIG issue -- the C++ function expects operations_research::MPModelRequest
const &, and I think the Python MPModelRequest object is not properly
passed as const. For now I have given up on using the quadratics with
ortools but maybe at some point I will take another look (but feel free to
close the PR if you don't care about such a niche bug).
—
Reply to this email directly, view it on GitHub
<#3027 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3NWZQTVLI265B6BWG3UT6RRFANCNFSM5KMT7AUA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
And pushed to master.
EDIT: ce02461
Laurent Perron | Operations Research | ***@***.*** | (33) 1 42 68 53
00
Le dim. 2 janv. 2022 à 10:28, Laurent Perron ***@***.***> a écrit :
… The linear_solver.i is missing the wrapping of the MPModelRequest.
I will fix this asap.
Laurent Perron | Operations Research | ***@***.*** | (33) 1 42 68
53 00
Le dim. 2 janv. 2022 à 02:17, Jediah Katz ***@***.***> a
écrit :
> Hmm, strange because nonlinear.h exists in commit
> 6acb7222e1b871041445bee75fc05bd1bcaed089 of the SCIP repo. Unfortunately
> though, I realized that the issue is less simple than I originally thought.
> The all-zero values problem was caused by me using Solve() instead of
> SolveWithProto(), but when I use SolveWithProto() then I get an error
> with the following trace:
>
> Traceback (most recent call last):
> File "ortools_samples/quadratic.py", line 88, in <module>
> print(pywraplp.Solver.SolveWithProto(linear_solver_pb2.MPModelRequest(model=input_proto.model), solution))
> File "/home/jediahkatz/.cache/pypoetry/virtualenvs/pythonsat-yDcEWZll-py3.8/lib/python3.8/site-packages/ortools/linear_solver/pywraplp.py", line 358, in SolveWithProto
> return _pywraplp.Solver_SolveWithProto(model_request, response)
> TypeError: in method 'Solver_SolveWithProto', argument 1 of type 'operations_research::MPModelRequest const &'
>
> It seems to be a Python/SWIG issue -- the C++ function expects operations_research::MPModelRequest
> const &, and I think the Python MPModelRequest object is not properly
> passed as const. For now I have given up on using the quadratics with
> ortools but maybe at some point I will take another look (but feel free to
> close the PR if you don't care about such a niche bug).
>
> —
> Reply to this email directly, view it on GitHub
> <#3027 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ACUPL3NWZQTVLI265B6BWG3UT6RRFANCNFSM5KMT7AUA>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
> You are receiving this because your review was requested.Message ID:
> ***@***.***>
>
|
Ah, thanks so much. I'm not super familiar with how SWIG works but I'll check out your commit for curiosity's sake. Bonne année! |
The function
SCIPcreateConsBasicQuadratic()
along with the entirecons_quadratic.h
file are deprecated -- instead, we should useSCIPcreateConsBasicQuadraticNonlinear()
which takes the same arguments. Right now, attempting to use quadratic constraints or objectives results in all variables taking a zero value.For reference see the SCIP docs:
SCIPcreateConsBasicQuadratic: https://www.scipopt.org/doc/html/group__CONSHDLRS.php#gad3707e7f7166bea83b7713cf2e52b0db
SCIPcreateConsBasicQuadraticNonlinear: https://www.scipopt.org/doc/html/group__CONSHDLRS.php#gabef6770f404754e7503f68a7da9ad6da