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

Interfaces to the SAS solvers #2886

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Interfaces to the SAS solvers #2886

wants to merge 21 commits into from

Conversation

phchri
Copy link

@phchri phchri commented Jun 23, 2023

Fixes

Provides an interface to the SAS LP/MILP optimization solvers.

Summary/Motivation:

Provides an interface to the SAS LP/MILP optimization solvers on both the legacy 9.4 platform (via the saspy package) and on the SAS Viya cloud platform (CAS, via the swat package).

I'm repurposing the solver_io option to choose between the two interfaces, if there is a better way to do this, please advise. The idea is that the interface chooses automatically depending on which package is available.

Changes proposed in this PR:

  • Add the solver interface classes
  • Add 52 SAS specific unit tests for the two interfaces, two are currently skipped because the status between LP and MILP is inconsistent (still investigating what's going on there, probably just a status reporting inconsistency on the solver side).

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.

@phchri phchri changed the title Sassolvers Interfaces to the SAS solvers Jun 23, 2023
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 PR! Overall, it looks good; however, we do not (as far as I am aware) have SAS in our testing environment. I will approve GitHub Actions to run for this PR to confirm.

Please look at the two test_*.yml files in https://github.com/Pyomo/pyomo/tree/main/.github/workflows

pyomo/solvers/tests/checks/test_SAS.py Show resolved Hide resolved
pyomo/solvers/tests/checks/test_SAS.py Show resolved Hide resolved
pyomo/solvers/tests/checks/test_SAS.py Outdated Show resolved Hide resolved
pyomo/solvers/plugins/solvers/SAS.py Show resolved Hide resolved
pyomo/solvers/plugins/solvers/SAS.py Show resolved Hide resolved
pyomo/solvers/plugins/solvers/SAS.py Outdated Show resolved Hide resolved
pyomo/solvers/plugins/solvers/SAS.py Outdated Show resolved Hide resolved
@mrmundt
Copy link
Contributor

mrmundt commented Jun 26, 2023

Confirmed my previous comment: https://github.com/Pyomo/pyomo/actions/runs/5374476640/jobs/9760403183?pr=2886#step:24:8439 <- SAS tests are skipped.

@phchri
Copy link
Author

phchri commented Jun 26, 2023

Confirmed my previous comment: https://github.com/Pyomo/pyomo/actions/runs/5374476640/jobs/9760403183?pr=2886#step:24:8439 <- SAS tests are skipped.

Too bad, I was hoping you might have an academic version of at least SAS 9.4 available somewhere.

I ran the unit tests with various SAS versions in my environment, is this good enough for you?

@mrmundt
Copy link
Contributor

mrmundt commented Jun 26, 2023

Too bad, I was hoping you might have an academic version of at least SAS 9.4 available somewhere.

I ran the unit tests with various SAS versions in my environment, is this good enough for you?

Unfortunately, no. Because this PR proposes adding the solver into the core offering of Pyomo, we need to ensure its capabilities on our various Python and OS versions before it can be merged.

If you have information on how we might go about obtaining an academic license, we are willing to pursue that.

@phchri
Copy link
Author

phchri commented Jun 26, 2023

I will investigate how to most easily give you a license or access to machines that run SAS. I'll get back to you as soon as I hear something.

Which institution would a license be for?

@mrmundt
Copy link
Contributor

mrmundt commented Jun 26, 2023

I will investigate how to most easily give you a license or access to machines that run SAS. I'll get back to you as soon as I hear something.

Which institution would a license be for?

Thank you! The primary developers are at Sandia National Laboratories, so likely there. Please feel free to email wg-pyomo@sandia.gov so we can discuss further.

@codecov
Copy link

codecov bot commented Jun 26, 2023

Codecov Report

Patch coverage: 24.25% and project coverage change: -0.24% ⚠️

Comparison is base (176015b) 87.83% compared to head (ac2dfa3) 87.59%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2886      +/-   ##
==========================================
- Coverage   87.83%   87.59%   -0.24%     
==========================================
  Files         770      771       +1     
  Lines       89642    89976     +334     
==========================================
+ Hits        78733    78814      +81     
- Misses      10909    11162     +253     
Flag Coverage Δ
linux 84.64% <24.25%> (-0.23%) ⬇️
osx 74.40% <24.25%> (-0.19%) ⬇️
other 84.81% <24.25%> (-0.23%) ⬇️
win 81.90% <24.25%> (-0.22%) ⬇️

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

Files Changed Coverage Δ
pyomo/solvers/plugins/solvers/SAS.py 24.02% <24.02%> (ø)
pyomo/solvers/plugins/solvers/__init__.py 100.00% <100.00%> (ø)

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

@mrmundt mrmundt self-requested a review August 15, 2023 18:46
@mrmundt
Copy link
Contributor

mrmundt commented Mar 5, 2024

Good news, @phchri ! We have SAS approval for our test machines.

@phchri
Copy link
Author

phchri commented Mar 6, 2024

This is great @mrmundt ! I will look into resolving your comments by the end of the week so that we can move ahead with this.

@phchri
Copy link
Author

phchri commented Mar 12, 2024

I did the requested changes. It's now possible to add options for saspy.SASsession or swat.CAS when creating the solver factory. All options are just passed through. For example:

SAS94: opt = pyo.SolverFactory('sas', solver_io="_sas94", cfgfile="sasconf.py")
SAS Viya: opt = pyo.SolverFactory('sas', solver_io="_sascas", hostname="HOSTNAME", port="4711", passsword="YOURPASSWORD")

I also fixed a few issues with non-optimal return codes and the version checking.

@phchri
Copy link
Author

phchri commented Mar 12, 2024

For the unit tests, the test classes have session_options that are passed to the SolverFactory. For SASCAS (SAS Viya) the session options are currently set up to come from environment variables, but this could be adjusted. For SAS 9.4, the default is to use sascfg_personal.py, so currently no session_options are set, but that could be added to point to file or to specify the session options explicitly.

The documentation for the two types of sessions are here:
https://sassoftware.github.io/saspy/api.html
and here:
https://developer.sas.com/apis/swat/python/v1.4.0/generated/swat.cas.connection.CAS.html

pyomo/solvers/plugins/solvers/SAS.py Outdated Show resolved Hide resolved
pyomo/solvers/plugins/solvers/SAS.py Outdated Show resolved Hide resolved
pyomo/solvers/plugins/solvers/SAS.py Outdated Show resolved Hide resolved
pyomo/solvers/plugins/solvers/SAS.py Show resolved Hide resolved
pyomo/solvers/plugins/solvers/SAS.py Outdated Show resolved Hide resolved
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

4 participants