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

Solver Refactor Part 1: Introducing the new solver interface #3137

Merged
merged 281 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
281 commits
Select commit Hold shift + click to select a range
04d71cf
Fix broken imports
mrmundt Aug 30, 2023
fe9cea4
Trying to fix broken imports again
mrmundt Aug 30, 2023
b41cf00
Update plugins
mrmundt Aug 30, 2023
6a84fcf
Trying again with plugins
mrmundt Aug 30, 2023
2e15298
PPlugins are my bane
mrmundt Aug 30, 2023
94be745
Remove use_extensions attribute
mrmundt Aug 30, 2023
4017abc
Turn on pyomo.solver tests
mrmundt Aug 30, 2023
ee064d2
SAVE POINT: about to mess with persistent base
mrmundt Aug 30, 2023
9bcec5d
Rename PersistentSolver to PersistentSolverBase; PersistentBase to Pe…
mrmundt Aug 30, 2023
54fa01c
Correct broken import
mrmundt Aug 30, 2023
511a54c
Add in util tests; reformat with black
mrmundt Aug 30, 2023
6cf3f82
Add more unit tests
mrmundt Aug 30, 2023
4d3191a
Add more unit tests
mrmundt Aug 30, 2023
9dffd26
Remove APPSI utils -> have been moved to pyomo.solver.util
mrmundt Aug 30, 2023
793fb38
Reverting test_branches file
mrmundt Aug 30, 2023
35e921a
Add __init__ to test directory
mrmundt Aug 30, 2023
3489dfc
Update the results object
mrmundt Aug 30, 2023
146fa0a
Back to only running appsi/solver test
mrmundt Aug 30, 2023
e2d0592
Remove domain specification
mrmundt Aug 30, 2023
b40ff29
Fix domain typo
mrmundt Aug 30, 2023
050ceb6
Allow negative floats
mrmundt Aug 31, 2023
ceb858a
Remove type checking for start_time
mrmundt Aug 31, 2023
9ee8748
Merge branch 'main' of github.com:pyomo/pyomo into solver-refactor
mrmundt Aug 31, 2023
cc0ad9b
Add empty config value to start_time
mrmundt Aug 31, 2023
74a459e
Change result attribute in HiGHS to match new standard
mrmundt Aug 31, 2023
154b438
Replace all other instances of wallclock_time
mrmundt Aug 31, 2023
b6f1e2a
Update unit tests for Results object
mrmundt Aug 31, 2023
072ac65
Update solution status map
mrmundt Aug 31, 2023
eeceb86
Refactor Results to be in its own file
mrmundt Aug 31, 2023
f0a942c
Update key value for solution status
mrmundt Aug 31, 2023
51b97f5
Fix broken import statement
mrmundt Aug 31, 2023
678df6f
Correct one more broken import statement; apply black
mrmundt Aug 31, 2023
f0d843c
Reorder imports for prettiness
mrmundt Aug 31, 2023
46d3c90
Copyright added; init updated
mrmundt Aug 31, 2023
a619aca
Change several names; add type checking
mrmundt Aug 31, 2023
5eb95a4
Fix problematic attribute changes
mrmundt Aug 31, 2023
198d0b1
Change type hinting for several config/results objects
mrmundt Aug 31, 2023
6dbc84d
Change un-init test to assign an empty SolutionLoader
mrmundt Aug 31, 2023
d09c880
SAVE POINT: Starting work on IPOPT solver re-write
mrmundt Aug 31, 2023
f474d49
Change SolverFactory to remove legacy solver references
mrmundt Aug 31, 2023
88aeba6
SAVE POINT: Stopping for end of sprin
mrmundt Aug 31, 2023
b7a446c
Update documentation on solver interfaces results
mrmundt Sep 8, 2023
b3af7ac
Add in TODOs for documentation
mrmundt Sep 8, 2023
5c05c78
SAVE POINT: Start the termination conditions/etc.
mrmundt Sep 12, 2023
472b5df
Save point: working on writer
mrmundt Sep 26, 2023
4061af9
SAVE POINT: Adding Datetime checker
mrmundt Oct 2, 2023
b5af408
Swap FullLicense and LimitedLicense
mrmundt Oct 2, 2023
4b871a6
Resolve merge conflicts
mrmundt Oct 23, 2023
c100bf9
Resolve broken import
mrmundt Oct 23, 2023
332d286
Resolving conflicts again: stream_solver -> tee
mrmundt Oct 23, 2023
0b348a0
Resolve convergence of APPSI and new Results object
mrmundt Oct 23, 2023
457c599
Resolve one more convergence error
mrmundt Oct 23, 2023
65d869c
Merge branch 'main' into solver-refactor
mrmundt Oct 24, 2023
a58dc41
Obvious bug fix
mrmundt Oct 26, 2023
d43765c
SAVE STATE
mrmundt Nov 8, 2023
da39b25
Merge branch 'main' into solver-refactor
mrmundt Nov 13, 2023
60fee49
Push changes from pair-programming
mrmundt Nov 13, 2023
98e8f9c
solver refactor: sol parsing
michaelbynum Nov 15, 2023
0ee1d7b
solver refactor: sol parsing
michaelbynum Nov 15, 2023
97352bd
Merge Michael's changes; apply black
mrmundt Nov 20, 2023
b0152d3
Attempt to merge mlbynum's changes / main
mrmundt Nov 20, 2023
6d945da
Apply black
mrmundt Nov 20, 2023
2562d47
Run black, try to fix errors
mrmundt Nov 20, 2023
7c30a25
Fix IPOPT version reference in test
mrmundt Nov 20, 2023
7bf0f7f
Try to fix recursive config problem
mrmundt Nov 20, 2023
1edc3b5
Correct context manage file opening
mrmundt Nov 20, 2023
f23ed71
More instances to be replaced
mrmundt Nov 20, 2023
dcd7cab
Revert - previous version was fine
mrmundt Nov 20, 2023
883c2ab
Attempt to resolve syntax issue
mrmundt Nov 20, 2023
03d3aab
Apply black to context manager
mrmundt Nov 20, 2023
d750dfb
Fix minor error in exit_code_message; change to safe_dump
mrmundt Nov 21, 2023
4b624f4
Apply black
mrmundt Nov 21, 2023
131a142
Remove custom SolverFactory
mrmundt Nov 21, 2023
52b8b6b
Revert Factory changes; clean up some nonsense
mrmundt Nov 21, 2023
63af991
Push changes: pyomo --help solvers tracks all solvers, v1, v2, and appsi
mrmundt Nov 21, 2023
5e78aa1
Certify backwards compatibility
mrmundt Nov 21, 2023
3472d0d
Commit other changes
mrmundt Nov 27, 2023
7d7c9ab
Merge main
mrmundt Dec 1, 2023
2e6ce49
pyomo.solver.ipopt: account for presolve when loading results
michaelbynum Dec 1, 2023
3f3b3c3
Add timing capture and iteration/log parsing
mrmundt Dec 4, 2023
3f228e4
Merge branch 'solver-refactor' into solver-refactor
mrmundt Dec 4, 2023
e804e4a
Merge pull request #27 from michaelbynum/solver-refactor
mrmundt Dec 4, 2023
5138ae8
Change to lowercase ipopt
mrmundt Dec 4, 2023
5a9e5e5
Blackify
mrmundt Dec 4, 2023
a503d45
Test file needed updated
mrmundt Dec 4, 2023
d04e1f8
Anotther test was incorrect
mrmundt Dec 4, 2023
6588232
Remove cmodel extensions
mrmundt Dec 4, 2023
77f6596
More conversion in Wntr needed
mrmundt Dec 4, 2023
7f76ff4
Update Results test
mrmundt Dec 4, 2023
09e3fe9
Blackify
mrmundt Dec 4, 2023
f26625e
wallclock attribute no longer valid
mrmundt Dec 4, 2023
a2efd8d
Update TerminationCondition and SolutionStatus checks
mrmundt Dec 4, 2023
682c8b8
Blackify... again
mrmundt Dec 4, 2023
39eb268
Apply options files updates
mrmundt Dec 5, 2023
396ebce
Fix tests; add TODO notes
mrmundt Dec 5, 2023
e19d440
Blackify - adding a single empty space
mrmundt Dec 5, 2023
9ad1001
Merge main and resolve divergence
mrmundt Dec 14, 2023
5d7b740
Begin cleaning up documentation; move tests to more logical configura…
mrmundt Dec 19, 2023
2dee6b7
Reinstantiate NotImplementedErrors for PersistentBase; update tests
mrmundt Dec 19, 2023
f0c0a07
Revert config changes
mrmundt Dec 19, 2023
35e5ff0
bug fix
michaelbynum Dec 19, 2023
84896f3
Add descriptions; incorporate missing option into ipopt
mrmundt Dec 19, 2023
c114ee3
Bug fix: Case where there is no active objective
mrmundt Dec 19, 2023
1363144
Bug fix: bcannot convert obj to bool
mrmundt Dec 20, 2023
d5a2fba
Fix f-string warning
mrmundt Dec 20, 2023
bf9e376
Merge branch 'main' into solver-refactor
mrmundt Jan 4, 2024
7187fc2
Backwards compability: Process legacy options.
mrmundt Jan 4, 2024
6fb37ce
Add new option to legacy interface for forwards compability
mrmundt Jan 4, 2024
a79f348
Apply black
mrmundt Jan 4, 2024
8dc2133
Merge origin main
mrmundt Jan 15, 2024
7828311
Typo correction
mrmundt Jan 15, 2024
5c452be
minor updates
michaelbynum Jan 15, 2024
c1b401d
Merge remote-tracking branch 'mrmundt/solver-refactor' into solver-re…
michaelbynum Jan 15, 2024
8e168cf
MOVE: Shift pyomo.solver to pyomo.contrib.solver
mrmundt Jan 15, 2024
aa28193
Missed several imports
mrmundt Jan 15, 2024
f0d9685
Missing init files
mrmundt Jan 15, 2024
7a1a0d5
Black
mrmundt Jan 15, 2024
4087d1a
solver refactor: various updates
michaelbynum Jan 16, 2024
e5c46ed
solver refactor: various updates
michaelbynum Jan 16, 2024
dac6bef
solver refactor: use caching in available and version
michaelbynum Jan 16, 2024
4df0a8d
solver refactor: config updates
michaelbynum Jan 16, 2024
b944779
solver refactor: typo
michaelbynum Jan 16, 2024
fe41e22
solver refactor: various fixes
michaelbynum Jan 16, 2024
3d32f4a
move sol reader to separate file
michaelbynum Jan 16, 2024
6c5d83c
remove symbol map when it is not necessary
michaelbynum Jan 16, 2024
c800776
reorg
michaelbynum Jan 16, 2024
952e8e7
solver refactor: various fixes
michaelbynum Jan 16, 2024
e256ab1
make skip_trivial_constraints True by default
michaelbynum Jan 16, 2024
5b7919e
Apply black; convert doc -> description for ConfigDicts
mrmundt Jan 16, 2024
78c08d0
restore changes to appsi
michaelbynum Jan 16, 2024
83a9355
Merge remote-tracking branch 'mrmundt/solver-refactor' into solver-re…
michaelbynum Jan 16, 2024
c0d3530
Explicitly register contrib.solver
mrmundt Jan 16, 2024
a1be778
Fix linking in online docs
mrmundt Jan 16, 2024
16e874c
Merge remote-tracking branch 'jsiirola/nlv2_eliminated_vars_datatype'…
michaelbynum Jan 16, 2024
c77eb24
rework ipopt solution loader
michaelbynum Jan 16, 2024
a5e3873
fix imports
michaelbynum Jan 16, 2024
0aa40d5
Merge remote-tracking branch 'main_fork/main' into solver-refactor
michaelbynum Jan 16, 2024
f6ad485
Merge remote-tracking branch 'mrmundt/solver-refactor' into solver-re…
michaelbynum Jan 16, 2024
f1bd682
override display()
michaelbynum Jan 16, 2024
a44929c
better handling of solver output
michaelbynum Jan 16, 2024
a3fe003
handle scaling when loading results
michaelbynum Jan 16, 2024
da2e58f
Save state: fixing broken tests
mrmundt Jan 18, 2024
af7d287
Merge branch 'solver-refactor' of github.com:mrmundt/pyomo into solve…
mrmundt Jan 18, 2024
7fa02de
Remove slack referrences; fix broken unit tests
mrmundt Jan 18, 2024
efb1eee
Apply black
mrmundt Jan 18, 2024
142dc30
Convert typing to spre-3.10 supported syntax
mrmundt Jan 18, 2024
7fd0c98
Add in DevError check for number of options
mrmundt Jan 18, 2024
f456f37
Missed pre-3.10 syntax error
mrmundt Jan 18, 2024
b6395ab
new ipopt interface: account for parameters in objective when load_so…
michaelbynum Jan 26, 2024
f126bc4
Apply black
mrmundt Jan 26, 2024
21f5a77
Merge remote-tracking branch 'origin' into solver-refactor
mrmundt Jan 30, 2024
b689a97
Apply new black
mrmundt Jan 30, 2024
56a36e9
Flesh out unit tests for base classes; change to load_solutions for b…
mrmundt Jan 30, 2024
9d7e5c0
Save state: making Legacy wrapper more testable
mrmundt Jan 30, 2024
1dd764f
Merge branch 'main' into solver-refactor
mrmundt Jan 31, 2024
462457b
Fix backwards compatibility
mrmundt Jan 31, 2024
a0ad77e
Add timing information to legacy results wrapper
mrmundt Feb 1, 2024
248ffd5
Add more base unit tets
mrmundt Feb 1, 2024
63920f6
Merge branch 'main' into solver-refactor
mrmundt Feb 1, 2024
a2a5513
Add LegacySolverWrapper tests
mrmundt Feb 1, 2024
2c8a4d8
Backwards compatibility; add tests
mrmundt Feb 1, 2024
3ca70d1
porting appsi_gurobi to contrib/solver
michaelbynum Feb 11, 2024
4471b7c
run black
michaelbynum Feb 11, 2024
cb085e1
Merge branch 'main' into solver-refactor
mrmundt Feb 14, 2024
2a3b573
Unit tests for config, results, and util complete
mrmundt Feb 14, 2024
8a5c8e4
Merge pull request #29 from michaelbynum/solver-refactor-2
mrmundt Feb 14, 2024
d4e56e8
Apply new version of black
mrmundt Feb 14, 2024
51dccea
Add unit tests for solution module
mrmundt Feb 14, 2024
571cc08
Add 'name' to SolverBase
mrmundt Feb 14, 2024
b19c75a
Update documentation (which is still slim but is a reasonable start)
mrmundt Feb 14, 2024
9ed93fe
Update docs to point to new gurobi interface
mrmundt Feb 14, 2024
398493c
solver refactor: update tests
michaelbynum Feb 14, 2024
9fcb236
Set up structure for sol_reader tests
mrmundt Feb 14, 2024
cc61256
Merge branch 'main' into solver-refactor
mrmundt Feb 14, 2024
273fd72
Add init file
mrmundt Feb 14, 2024
ab7d591
Merge branch 'solver-refactor' of github.com:mrmundt/pyomo into solve…
mrmundt Feb 14, 2024
f52db9d
Update base member unit test - better checking logic
mrmundt Feb 15, 2024
b99221c
Address missing coverage for several modules
mrmundt Feb 15, 2024
a45e085
Add copyright statements; clean up unused imports
mrmundt Feb 15, 2024
6d21b71
updating docs
michaelbynum Feb 15, 2024
6c3739e
Update docstrings; fix one test to account for pypy differences
mrmundt Feb 15, 2024
220dd13
Black and its empty lines
mrmundt Feb 15, 2024
b69eb20
Merge branch 'main' of github.com:Pyomo/pyomo into solver-refactor
mrmundt Feb 15, 2024
7edd9db
Update documentation to include examples for usage
mrmundt Feb 15, 2024
4ee6b79
Merge branch 'solver-refactor' into solver-refactor
mrmundt Feb 15, 2024
8da2326
Merge pull request #30 from michaelbynum/solver-refactor
mrmundt Feb 15, 2024
0b78574
Apply black to doc changes
mrmundt Feb 15, 2024
9280180
Switch APPSI/contrib.solver registrations to use "local" (unqualified)
jsiirola Feb 15, 2024
316fb3f
Add __future__ mechanism for switching solver factories
jsiirola Feb 15, 2024
6cfbd21
Add documentation (and fix an import)
jsiirola Feb 15, 2024
d2a3ff1
Update documentation; include package needed for sphinx enum tools
mrmundt Feb 15, 2024
75da70e
Fix init; add more descriptive skip messages
mrmundt Feb 15, 2024
e7eb142
Apply blacl
mrmundt Feb 15, 2024
bf4f270
Small typo; changes enum-tools line
mrmundt Feb 15, 2024
eb9b253
Underscore instead of dash
mrmundt Feb 15, 2024
f313b0a
NFC: apply black
jsiirola Feb 15, 2024
7497172
NFC: update copyright on new file (missed by #3139)
jsiirola Feb 15, 2024
cfbab70
Add in two more deps
mrmundt Feb 15, 2024
0330e09
NFC: fix doc formatting
jsiirola Feb 15, 2024
b3c4b66
Add missing doc file
jsiirola Feb 15, 2024
f45201a
NFC: additional doc formatting
jsiirola Feb 15, 2024
686fecc
Merge pull request #31 from jsiirola/solver-refactor
mrmundt Feb 15, 2024
9157b8c
Update documentation to reflect the new preview page
mrmundt Feb 15, 2024
8e56d4e
Doc formatting fix
mrmundt Feb 15, 2024
a255062
Merge branch 'main' into solver-refactor
mrmundt Feb 16, 2024
7e5022f
Merge branch 'main' into solver-refactor
mrmundt Feb 16, 2024
ae28cee
Update copyright year on all solver files
mrmundt Feb 16, 2024
23bdbf7
Add hidden doctest to reset solver factory
mrmundt Feb 16, 2024
d405bcb
Add missing dep for windows/conda enum_tools
mrmundt Feb 16, 2024
832a789
Add minimal example for presolve and scaling to docs
mrmundt Feb 16, 2024
d8b0ba3
bug
michaelbynum Feb 16, 2024
f20b181
Merge remote-tracking branch 'mrmundt/solver-refactor' into solver-re…
michaelbynum Feb 16, 2024
9c1727b
Save state: config changes
mrmundt Feb 19, 2024
0445056
Merge branch 'main' of github.com:Pyomo/pyomo into solver-refactor
mrmundt Feb 19, 2024
fb6f97e
Address @jsiirola's comments
mrmundt Feb 19, 2024
7d5d7df
Merge branch 'solver-refactor' of github.com:mrmundt/pyomo into solve…
mrmundt Feb 19, 2024
544aa45
Missed one file
mrmundt Feb 19, 2024
9bf1970
Remove because it's not implemented and we have a different idea
mrmundt Feb 19, 2024
95cd64e
Remove from __init__
mrmundt Feb 19, 2024
c17d2b9
Reverting: log_solver_output does do something
mrmundt Feb 19, 2024
10e08f9
Update domain validator for bools
mrmundt Feb 19, 2024
ca0280c
update type hints in configs
michaelbynum Feb 19, 2024
df33968
properly copy the nl writer config
michaelbynum Feb 19, 2024
086d53c
Apply black; change to ccapital I
mrmundt Feb 19, 2024
69fd8d0
Move PersistentUtils into own file
mrmundt Feb 19, 2024
92c0262
Change import statement
mrmundt Feb 19, 2024
3447f07
Update ipopt imports; change available and version
mrmundt Feb 19, 2024
b902a30
If sol file exists, parse it
mrmundt Feb 19, 2024
15eddd3
Update _parse_ipopt_output to address newer versions of IPOPT
mrmundt Feb 19, 2024
afcedb1
Incomplete comment; stronger parsing
mrmundt Feb 19, 2024
c7d3056
Merge branch 'main' of github.com:Pyomo/pyomo into solver-refactor
mrmundt Feb 19, 2024
5ad721c
updating results processing and tests
michaelbynum Feb 19, 2024
b9a6e83
error message
michaelbynum Feb 19, 2024
763fd9c
Merge pull request #32 from michaelbynum/solver-refactor
mrmundt Feb 19, 2024
52391fc
Missed capitalization
mrmundt Feb 19, 2024
f4293a5
Merge branch 'solver-refactor' of github.com:mrmundt/pyomo into solve…
mrmundt Feb 19, 2024
bc1b3e9
Apply black to updates
mrmundt Feb 19, 2024
ac7ce8b
Update error messages
mrmundt Feb 19, 2024
159295e
Merge branch 'main' of github.com:Pyomo/pyomo into solver-refactor
mrmundt Feb 20, 2024
044f847
Apply @blnicho 's csuggestions
mrmundt Feb 20, 2024
423b141
Add skip statement to doctests; start ipopt unit tests
mrmundt Feb 20, 2024
d0cdeaa
Consolidate log_solevr_output into tee
jsiirola Feb 20, 2024
ff92c62
More unit tests for ipopt; fix some bugs as well
mrmundt Feb 20, 2024
e667ad3
Merge pull request #33 from jsiirola/solver-refactor
mrmundt Feb 20, 2024
c2472b3
Remove Datetime validator; replace with IsInstance
mrmundt Feb 20, 2024
074ea78
Generalize the tests
mrmundt Feb 20, 2024
05e0b47
Bug fix: missing imports
mrmundt Feb 20, 2024
40ad333
Merge branch 'main' into solver-refactor
jsiirola Feb 21, 2024
1bccb16
Address comments from @jsiirola, @blnicho
mrmundt Feb 21, 2024
9b21273
Apply black
mrmundt Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
python: 3.9
TARGET: win
PYENV: conda
PACKAGES: glpk pytest-qt
PACKAGES: glpk pytest-qt filelock

- os: ubuntu-latest
python: '3.11'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_pr_and_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- os: windows-latest
TARGET: win
PYENV: conda
PACKAGES: glpk pytest-qt
PACKAGES: glpk pytest-qt filelock

- os: ubuntu-latest
python: '3.11'
Expand Down
1 change: 1 addition & 0 deletions doc/OnlineDocs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
'sphinx.ext.doctest',
'sphinx.ext.todo',
'sphinx_copybutton',
'enum_tools.autoenum',
#'sphinx.ext.githubpages',
]

Expand Down
3 changes: 3 additions & 0 deletions doc/OnlineDocs/developer_reference/future.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

.. automodule:: pyomo.__future__
:noindex:
2 changes: 2 additions & 0 deletions doc/OnlineDocs/developer_reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ scripts using Pyomo.
config.rst
deprecation.rst
expressions/index.rst
future.rst
solvers.rst
254 changes: 254 additions & 0 deletions doc/OnlineDocs/developer_reference/solvers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
Future Solver Interface Changes
===============================

Pyomo offers interfaces into multiple solvers, both commercial and open source.
To support better capabilities for solver interfaces, the Pyomo team is actively
redesigning the existing interfaces to make them more maintainable and intuitive
for use. Redesigned interfaces can be found in ``pyomo.contrib.solver``.

.. currentmodule:: pyomo.contrib.solver


New Interface Usage
-------------------

The new interfaces have two modes: backwards compatible and future capability.
The future capability mode can be accessed directly or by switching the default
``SolverFactory`` version (see :doc:`future`). Currently, the new versions
available are:

.. list-table:: Available Redesigned Solvers
:widths: 25 25 25
:header-rows: 1

* - Solver
- ``SolverFactory`` (v1) Name
- ``SolverFactory`` (v3) Name
* - ipopt
- ``ipopt_v2``
- ``ipopt``
* - Gurobi
- ``gurobi_v2``
- ``gurobi``

Backwards Compatible Mode
^^^^^^^^^^^^^^^^^^^^^^^^^

.. testcode::
:skipif: not ipopt_available

import pyomo.environ as pyo
from pyomo.contrib.solver.util import assert_optimal_termination

model = pyo.ConcreteModel()
model.x = pyo.Var(initialize=1.5)
model.y = pyo.Var(initialize=1.5)

def rosenbrock(model):
return (1.0 - model.x) ** 2 + 100.0 * (model.y - model.x**2) ** 2

model.obj = pyo.Objective(rule=rosenbrock, sense=pyo.minimize)

status = pyo.SolverFactory('ipopt_v2').solve(model)
assert_optimal_termination(status)
model.pprint()

.. testoutput::
:skipif: not ipopt_available
:hide:

2 Var Declarations
...
3 Declarations: x y obj

Future Capability Mode
^^^^^^^^^^^^^^^^^^^^^^

There are multiple ways to utilize the future capability mode: direct import
or changed ``SolverFactory`` version.

.. testcode::
:skipif: not ipopt_available

# Direct import
import pyomo.environ as pyo
from pyomo.contrib.solver.util import assert_optimal_termination
from pyomo.contrib.solver.ipopt import Ipopt

model = pyo.ConcreteModel()
model.x = pyo.Var(initialize=1.5)
model.y = pyo.Var(initialize=1.5)

def rosenbrock(model):
return (1.0 - model.x) ** 2 + 100.0 * (model.y - model.x**2) ** 2

model.obj = pyo.Objective(rule=rosenbrock, sense=pyo.minimize)

opt = Ipopt()
status = opt.solve(model)
assert_optimal_termination(status)
# Displays important results information; only available in future capability mode
status.display()
model.pprint()

.. testoutput::
:skipif: not ipopt_available
:hide:

solution_loader: ...
...
3 Declarations: x y obj

Changing the ``SolverFactory`` version:

.. testcode::
:skipif: not ipopt_available

# Change SolverFactory version
import pyomo.environ as pyo
from pyomo.contrib.solver.util import assert_optimal_termination
from pyomo.__future__ import solver_factory_v3

model = pyo.ConcreteModel()
model.x = pyo.Var(initialize=1.5)
model.y = pyo.Var(initialize=1.5)

def rosenbrock(model):
return (1.0 - model.x) ** 2 + 100.0 * (model.y - model.x**2) ** 2

model.obj = pyo.Objective(rule=rosenbrock, sense=pyo.minimize)

status = pyo.SolverFactory('ipopt').solve(model)
assert_optimal_termination(status)
# Displays important results information; only available in future capability mode
status.display()
model.pprint()

.. testoutput::
:skipif: not ipopt_available
:hide:

solution_loader: ...
...
3 Declarations: x y obj

.. testcode::
:skipif: not ipopt_available
:hide:

from pyomo.__future__ import solver_factory_v1

Linear Presolve and Scaling
^^^^^^^^^^^^^^^^^^^^^^^^^^^

The new interface will allow for direct manipulation of linear presolve and scaling
options for certain solvers. Currently, these options are only available for
``ipopt``.

.. autoclass:: pyomo.contrib.solver.ipopt.Ipopt
mrmundt marked this conversation as resolved.
Show resolved Hide resolved
:members: solve

The ``writer_config`` configuration option can be used to manipulate presolve
and scaling options:

.. testcode::

from pyomo.contrib.solver.ipopt import Ipopt
opt = Ipopt()
opt.config.writer_config.display()

.. testoutput::

show_section_timing: false
skip_trivial_constraints: true
file_determinism: FileDeterminism.ORDERED
symbolic_solver_labels: false
scale_model: true
export_nonlinear_variables: None
row_order: None
column_order: None
export_defined_variables: true
linear_presolve: true

Note that, by default, both ``linear_presolve`` and ``scale_model`` are enabled.
Users can manipulate ``linear_presolve`` and ``scale_model`` to their preferred
states by changing their values.

.. code-block:: python
mrmundt marked this conversation as resolved.
Show resolved Hide resolved

>>> opt.config.writer_config.linear_presolve = False


Interface Implementation
------------------------

All new interfaces should be built upon one of two classes (currently):
:class:`SolverBase<pyomo.contrib.solver.base.SolverBase>` or
:class:`PersistentSolverBase<pyomo.contrib.solver.base.PersistentSolverBase>`.

All solvers should have the following:

.. autoclass:: pyomo.contrib.solver.base.SolverBase
:members:

Persistent solvers include additional members as well as other configuration options:

.. autoclass:: pyomo.contrib.solver.base.PersistentSolverBase
:show-inheritance:
:members:

Results
-------

Every solver, at the end of a
:meth:`solve<pyomo.contrib.solver.base.SolverBase.solve>` call, will
return a :class:`Results<pyomo.contrib.solver.results.Results>`
object. This object is a :py:class:`pyomo.common.config.ConfigDict`,
which can be manipulated similar to a standard ``dict`` in Python.

.. autoclass:: pyomo.contrib.solver.results.Results
:show-inheritance:
:members:
:undoc-members:


Termination Conditions
^^^^^^^^^^^^^^^^^^^^^^

Pyomo offers a standard set of termination conditions to map to solver
returns. The intent of
:class:`TerminationCondition<pyomo.contrib.solver.results.TerminationCondition>`
is to notify the user of why the solver exited. The user is expected
to inspect the :class:`Results<pyomo.contrib.solver.results.Results>`
object or any returned solver messages or logs for more information.

.. autoclass:: pyomo.contrib.solver.results.TerminationCondition
:show-inheritance:


Solution Status
^^^^^^^^^^^^^^^

Pyomo offers a standard set of solution statuses to map to solver
output. The intent of
:class:`SolutionStatus<pyomo.contrib.solver.results.SolutionStatus>`
is to notify the user of what the solver returned at a high level. The
user is expected to inspect the
:class:`Results<pyomo.contrib.solver.results.Results>` object or any
returned solver messages or logs for more information.

.. autoclass:: pyomo.contrib.solver.results.SolutionStatus
:show-inheritance:


Solution
--------

Solutions can be loaded back into a model using a ``SolutionLoader``. A specific
loader should be written for each unique case. Several have already been
implemented. For example, for ``ipopt``:

.. autoclass:: pyomo.contrib.solver.ipopt.IpoptSolutionLoader
:show-inheritance:
:members:
:inherited-members:
Loading