Skip to content

Conversation

@Robbybp
Copy link
Contributor

@Robbybp Robbybp commented Feb 9, 2022

Summary/Motivation:

There is a significant performance improvement for some problems if we create ProjectedNLPs that we solve repeatedly with CyIpopt, rather than solve Pyomo blocks with Ipopt, for the inner problems in the implicit function formulation.

Changes proposed in this PR:

  • Add the data structures necessary to repeatedly solve a sequence of square problems as PyomoNLPs, where variables are updated before each solve
  • Change the default behavior of ExternalPyomoModel to solve ProjectedNLPs with CyIpopt, and only use Ipopt (or another Pyomo solver) if specified, or if CyIpopt is unavailable.

A comparison comparison on a chemical looping steady state optimization problem:

  • Current main:
    2022-02-08_before_patch
  • This branch
    2022-02-08_after_patch

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.

@codecov
Copy link

codecov bot commented Feb 10, 2022

Codecov Report

Merging #2283 (34670ae) into main (3e6a869) will decrease coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2283      +/-   ##
==========================================
- Coverage   85.29%   85.21%   -0.09%     
==========================================
  Files         611      616       +5     
  Lines       76006    77925    +1919     
==========================================
+ Hits        64833    66407    +1574     
- Misses      11173    11518     +345     
Flag Coverage Δ
linux 82.70% <100.00%> (+<0.01%) ⬆️
osx 72.91% <6.66%> (+<0.01%) ⬆️
other 82.66% <100.00%> (+<0.01%) ⬆️
win 79.79% <100.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
...ontrib/pynumero/interfaces/external_pyomo_model.py 99.27% <100.00%> (+0.13%) ⬆️
...o/contrib/interior_point/linalg/mumps_interface.py 43.95% <0.00%> (-31.05%) ⬇️
pyomo/contrib/pynumero/linalg/mumps_interface.py 74.69% <0.00%> (-14.67%) ⬇️
pyomo/contrib/pynumero/linalg/ma27.py 84.48% <0.00%> (-14.47%) ⬇️
...mo/contrib/interior_point/linalg/ma27_interface.py 72.81% <0.00%> (-5.31%) ⬇️
pyomo/contrib/appsi/solvers/cplex.py 78.83% <0.00%> (-4.51%) ⬇️
...erior_point/linalg/base_linear_solver_interface.py 77.77% <0.00%> (-1.39%) ⬇️
pyomo/core/base/alias.py 0.00% <0.00%> (ø)
pyomo/contrib/mindtpy/MindtPy.py 100.00% <0.00%> (ø)
pyomo/contrib/pynumero/linalg/ma27_interface.py 20.48% <0.00%> (ø)
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e6a869...34670ae. Read the comment docs.

else:
with TemporarySubsystemManager(to_fix=inputs):
solver.solve(block)
if self._use_cyipopt:
Copy link
Member

Choose a reason for hiding this comment

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

elif to avoid the extra indentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comment below. I think I want to have this extra if statement so that the increment of vector_scc_idx happens regardless of whether we're using CyIpopt.

with TemporarySubsystemManager(to_fix=inputs):
solver.solve(block)

vector_scc_idx += 1
Copy link
Member

Choose a reason for hiding this comment

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

I think this is technically correct as written, but it would be clearer if it was done inside the if self._use_cyipopt block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I like having this outside the if self._use_cyipopt tree, as otherwise, in the case where we use a regular Pyomo solver, vector_scc_idx will always be zero, even though we may not be at the zeroth "vector-valued" SCC. Having this information may be useful, e.g. for debugging, even if it's not strictly necessary for the algorithm.

@blnicho blnicho self-requested a review February 15, 2022 19:39
@blnicho blnicho merged commit f2381bd into Pyomo:main Feb 23, 2022
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.

4 participants