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

Added MAiNGO appsi-interface #3165

Merged
merged 45 commits into from
May 8, 2024
Merged

Conversation

MAiNGO-github
Copy link
Contributor

Fixes:

None

Summary/Motivation:

Added an interface to our global optimization solver MAiNGO

Changes proposed in this PR:

Add appsi-interface for MAiNGO

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.

@jsiirola
Copy link
Member

We took a quick look at this during the Dev Call this week. Most of the test failures are do to a test that tracks the modules that are automatically imported by pyomo.environ, and the failure is because the maingopy import is getting triggered by

class SolverModel(maingopy.MAiNGOmodel):

The easiest workaround is probably to move the SolverModel class definition to its own module, and then conditionally import that module into solvers/maingo.py (using attempt_import).

@MAiNGO-github
Copy link
Contributor Author

We took a quick look at this during the Dev Call this week. Most of the test failures are do to a test that tracks the modules that are automatically imported by pyomo.environ, and the failure is because the maingopy import is getting triggered by

class SolverModel(maingopy.MAiNGOmodel):

The easiest workaround is probably to move the SolverModel class definition to its own module, and then conditionally import that module into solvers/maingo.py (using attempt_import).

Thank you for the advice, now the import works just fine.

@MAiNGO-github MAiNGO-github changed the title [WIP] Added MAiNGO appsi-interface Added MAiNGO appsi-interface Mar 22, 2024
Copy link

codecov bot commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 91.38277% with 43 lines in your changes are missing coverage. Please review.

Project coverage is 88.46%. Comparing base (6393961) to head (0c14380).

Files Patch % Lines
pyomo/contrib/appsi/solvers/maingo.py 91.61% 27 Missing ⚠️
pyomo/contrib/appsi/solvers/maingo_solvermodel.py 90.69% 16 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #3165    +/-   ##
========================================
  Coverage   88.45%   88.46%            
========================================
  Files         849      851     +2     
  Lines       95329    95825   +496     
========================================
+ Hits        84327    84773   +446     
- Misses      11002    11052    +50     
Flag Coverage Δ
linux 86.43% <91.38%> (+0.02%) ⬆️
osx 76.33% <90.58%> (+0.07%) ⬆️
other 86.62% <91.38%> (+0.01%) ⬆️
win 83.94% <91.38%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@mrmundt mrmundt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I did an initial pass and have some comments. Also, can you please add our standard copyright statement to all new files? It can be found in any other existing *.py file.

@MAiNGO-github
Copy link
Contributor Author

Dear @mrmundt
We have adressed all your comments and fixed some bugs. The interface does no pass all tests (locally on our machine).

There are a few points we need your input on:

  • MAiNGO does not compute duals or reduced costs. We have extended the tests, so that duals or RCs are not computed for MAiNGO. Maybe there is a nicer way to do this?
  • MAiNGO has rather loose tolerances by default. To pass the tests we needed to raise them to a level which we do not want to set as default. For now, we create a new solverclass that inherits from our base solver class that uses tighter tolerances (MAiNGOTest). Again, is there a nicer way to do this?
  • MAiNGO does not support unbounded variables. To deal with unbounded variables we bound them to [-1e8,1e8]. As a consequence, we cannot recognice a problem to be unbounded.
  • We had to modify two tests (make variables > 0) as MAiNGO cannot handle log of negative values or division by 0.

Thank you!

@mrmundt
Copy link
Contributor

mrmundt commented Apr 17, 2024

@MAiNGO-github - I will reply to your other comments soon, but FYI on the two failures:

  1. conda is not your fault; something just didn't download correctly
  2. singletest is looking to make sure that you have registered the SolverFactory in the plugins system. See here: https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/appsi/plugins.py <- you'll need to add your new solver to the list.

Copy link
Contributor

@mrmundt mrmundt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed your questions!

@mrmundt
Copy link
Contributor

mrmundt commented Apr 18, 2024

@MAiNGO-github - This is insidious, and you would never have known it happened. maingopy isn't installing correctly:

Collecting maingopy
  Downloading maingopy-0.7.3.tar.gz (17.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.9/17.9 MB 75.6 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [13 lines of output]
      Traceback (most recent call last):
        File "/tmp/pip-install-du9lfhn7/maingopy_85dd9705743e442785b6d05edb86f03d/setup.py", line 7, in <module>
          from skbuild import setup
      ModuleNotFoundError: No module named 'skbuild'
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-du9lfhn7/maingopy_85dd9705743e442785b6d05edb86f03d/setup.py", line 9, in <module>
Error:           raise ImportError('Error during setup of maingopy: maingopy requires scikit-build, which is not available.')
      ImportError: Error during setup of maingopy: maingopy requires scikit-build, which is not available.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
WARNING: MAiNGO is not available

Copy link
Member

@blnicho blnicho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great. I have one minor change request, could you add maingo to the list of appsi solvers in this documentation page: https://github.com/Pyomo/pyomo/blob/main/doc/OnlineDocs/library_reference/appsi/appsi.solvers.rst

@mrmundt
Copy link
Contributor

mrmundt commented May 8, 2024

I think this looks great. I have one minor change request, could you add maingo to the list of appsi solvers in this documentation page: https://github.com/Pyomo/pyomo/blob/main/doc/OnlineDocs/library_reference/appsi/appsi.solvers.rst

Added in last two commits.

@mrmundt mrmundt merged commit 34b15d8 into Pyomo:main May 8, 2024
3 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants