Skip to content
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

[WIP] Add COPT support for Pyomo #2880

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft

Conversation

wujianjack
Copy link

Fixes

None, new interface.

Summary/Motivation:

This PR adds COPT support to Pyomo, including APPSI, IIS, the NL IO (coptampl), the Python IO (copt_direct and copt_persistent). The first two features are not tested so far, will do as soon as possible.

The copt_direct and copt_persistent depends on coptpy, which can be installed with pip install coptpy.

For larger instances, a valid COPT license is required, you can apply one from https://www.shanshu.ai/copt.

Changes proposed in this PR:

  • COPT support to APPSI
  • COPT support to IIS
  • COPT support to NL(coptampl) and Python IO (copt_direct and copt_persistent)

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@mrmundt
Copy link
Contributor

mrmundt commented Jun 26, 2023

Hi @wujianjack - Please read the contribution guide for details on how to resolve the black/typos errors: https://pyomo.readthedocs.io/en/stable/contribution_guide.html

@wujianjack
Copy link
Author

Hi @wujianjack - Please read the contribution guide for details on how to resolve the black/typos errors: https://pyomo.readthedocs.io/en/stable/contribution_guide.html
@mrmundt Thanks, I have resolved the typos. Sorry for the late reply!

@mrmundt
Copy link
Contributor

mrmundt commented Jul 18, 2023

Hi @wujianjack - It looks like you are missing an import statement which is causing these failures. Please let me know if you need any assistance.

@blnicho blnicho marked this pull request as draft September 5, 2023 18:59
@blnicho blnicho changed the title Add COPT support for Pyomo [WIP] Add COPT support for Pyomo Sep 5, 2023
@blnicho blnicho closed this Sep 19, 2023
@blnicho
Copy link
Member

blnicho commented Sep 19, 2023

@wujianjack feel free to reopen this if you have time to come back to it.

@wujianjack
Copy link
Author

wujianjack commented Sep 20, 2023

@wujianjack feel free to reopen this if you have time to come back to it.

Thanks, I updated on my fork, but still failed on those checks, I will try to figure out what's going on.

@wujianjack
Copy link
Author

@wujianjack feel free to reopen this if you have time to come back to it.

BTW, I have no access to reopen this PR, can you please reopen it?

@wujianjack
Copy link
Author

Hi @wujianjack - It looks like you are missing an import statement which is causing these failures. Please let me know if you need any assistance.

Sorry for the delay. Now it passes the style and typos check, but still failed on other checks, like bare-env, where the CI throw exception RuntimeError: Attempting to use an unavailable solver., and I have no idea how to fix it. Thanks.

@blnicho blnicho reopened this Sep 20, 2023
@mrmundt
Copy link
Contributor

mrmundt commented Sep 26, 2023

@wujianjack - I am seeing a lot of Segmentation faults; does that happen when you run the tests locally?

@wujianjack
Copy link
Author

@wujianjack - I am seeing a lot of Segmentation faults; does that happen when you run the tests locally?

Sorry for the delay, the latest update fixes the segfault, now there are some mismatch regarding to the slack values. (In COPT, slack means activity of constraints in fact). I will think about how to resolve it.

Thanks!

@wujianjack
Copy link
Author

@wujianjack - I am seeing a lot of Segmentation faults; does that happen when you run the tests locally?

Hi @mrmundt

I tried to fix most of the failures and there are 5 failures remains with latest change.

One failure is related to IIS, we writes out as c2: y + 100 x <= 0 instead of c2: 100 x + y <= 0 required by the testing script;
The other four failures are related to accuracy issue of variable solution (up to 4 digits).
See below for details.

FAILED pyomo/contrib/appsi/solvers/tests/test_persistent_solvers.py::TestSolvers::test_mutable_quadratic_coefficient_6_copt_only_child_vars_True - AssertionError: 0.41003838775982643 != 0.41024548525899274 within 4 places (0.00020709749916630882 difference)
FAILED pyomo/contrib/appsi/solvers/tests/test_persistent_solvers.py::TestSolvers::test_mutable_quadratic_coefficient_7_copt_only_child_vars_False - AssertionError: 0.41003838775982643 != 0.41024548525899274 within 4 places (0.00020709749916630882 difference)
FAILED pyomo/contrib/appsi/solvers/tests/test_persistent_solvers.py::TestSolvers::test_mutable_quadratic_objective_6_copt_only_child_vars_True - AssertionError: 0.696075712924909 != 0.6962249634573562 within 4 places (0.0001492505324471871 difference)
FAILED pyomo/contrib/appsi/solvers/tests/test_persistent_solvers.py::TestSolvers::test_mutable_quadratic_objective_7_copt_only_child_vars_False - AssertionError: 0.696075712924909 != 0.6962249634573562 within 4 places (0.0001492505324471871 difference)
FAILED pyomo/contrib/iis/tests/test_iis.py::TestIIS::test_write_iis_copt - Exception: The file /tmp/tmpl9qyjxo7/copt_iis.ilp is not as expected. Missing constraints:
c2: 100 x + y <= 0

Any suggestion on how to fix these failures? Thanks!

@mrmundt mrmundt marked this pull request as ready for review October 24, 2023 19:01
@mrmundt mrmundt marked this pull request as draft October 24, 2023 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants