raven icon indicating copy to clipboard operation
raven copied to clipboard

Alfoa/rom to pyomo

Open alfoa opened this issue 3 years ago • 42 comments


Pull Request Description

What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)

Closes #1580

What are the significant changes in functionality due to this change request?

This PR is aimed to address issue #1580. It adds:

  • a new exporting capability of ROMs into a pyomo concrete model, activatable via Outstream system
  • a derivative support for ROMs. This derivative support is based on numdiff library and is used both in the Pyomo model and, in the future, in the FMI/FMU exporter for Model exchange.

This uses PyNumero: https://pyomo.readthedocs.io/en/stable/contributed_packages/pynumero/index.html


For Change Control Board: Change Request Review

The following review must be completed by an authorized member of the Change Control Board.

  • [ ] 1. Review all computer code.
  • [ ] 2. If any changes occur to the input syntax, there must be an accompanying change to the user manual and xsd schema. If the input syntax change deprecates existing input files, a conversion script needs to be added (see Conversion Scripts).
  • [ ] 3. Make sure the Python code and commenting standards are respected (camelBack, etc.) - See on the wiki for details.
  • [ ] 4. Automated Tests should pass, including run_tests, pylint, manual building and xsd tests. If there are changes to Simulation.py or JobHandler.py the qsub tests must pass.
  • [ ] 5. If significant functionality is added, there must be tests added to check this. Tests should cover all possible options. Multiple short tests are preferred over one large test. If new development on the internal JobHandler parallel system is performed, a cluster test must be added setting, in <RunInfo> XML block, the node <internalParallel> to True.
  • [ ] 6. If the change modifies or adds a requirement or a requirement based test case, the Change Control Board's Chair or designee also needs to approve the change. The requirements and the requirements test shall be in sync.
  • [ ] 7. The merge request must reference an issue. If the issue is closed, the issue close checklist shall be done.
  • [ ] 8. If an analytic test is changed/added is the the analytic documentation updated/added?
  • [ ] 9. If any test used as a basis for documentation examples (currently found in raven/tests/framework/user_guide and raven/docs/workshop) have been changed, the associated documentation must be reviewed and assured the text matches the example.

alfoa avatar Mar 16 '21 18:03 alfoa

@joshua-cogliati-inl added description.

aalfonsi avatar Jun 09 '21 02:06 aalfonsi

before merging this, I would wait for the FMI/FMU to be merged, since the serialization in this branch needs to be replaced by the one in that PR

aalfonsi avatar Jun 09 '21 05:06 aalfonsi

@aalfonsi Is there a specific pull request or issue in Pyomo this is waiting on? Thanks.

joshua-cogliati-inl avatar Jun 23 '21 16:06 joshua-cogliati-inl

Based on discussion at the Dispatches meeting, this probably was waiting for Pyomo 6 release which is done. So this is probably ready to check.

joshua-cogliati-inl avatar Jul 07 '21 16:07 joshua-cogliati-inl

FYI: This is currently waiting on https://github.com/idaholab/raven/pull/1608

joshua-cogliati-inl avatar Jul 21 '21 16:07 joshua-cogliati-inl

Job Test qsubs on feb0bca : invalidated by @joshua-cogliati-inl

AssertionError: /home/moosetest/.conda/pkgs/yarl-1.6.3-py37h27cfd23_0/info/index.json

moosebuild avatar Aug 12 '21 14:08 moosebuild

FYI: https://github.com/idaholab/raven/pull/1608 has been merged, so the major need of this pull is a test.

joshua-cogliati-inl avatar Aug 17 '21 15:08 joshua-cogliati-inl

Status and work to be done: The goal is to have a PyNumero ExternalGreyBoxModel that can be loaded by a ExternalGreyBoxBlock. Right now, framework/Models/ROM.py can write python file with a subclass of ExternalGreyBoxModel. This file is designed to be run from the command line taking a -r ROM and -f framework argument to find a RAVEN ROM and the framework.

Things to be done:

  • Make test that exports RAVEN ROM and ExternalGreyBoxModel. (Started doing this in tests/framework/Models/External/serialize_pyomo.xml )
  • Figure out how to test this (Note that installing PyNumero requires extra steps beyond installing pyomo ( pyomo download-extensions and pyomo build-extensions )
  • Add documentation
  • Figure out a good way to have steps export different types of things (See XXX comment in IOStep.py)

joshua-cogliati-inl avatar Aug 19 '21 17:08 joshua-cogliati-inl

Job Test qsubs on f80c989 : invalidated by @joshua-cogliati-inl

Conda definitions not found at /home/moosetest/miniconda2/etc/profile.d/conda.sh

moosebuild avatar Aug 20 '21 19:08 moosebuild

The test now at least runs (but doesn't do anything useful).

./run_tests --re=pyomo_serialization

To make an environment that can run it (starting from the standard RAVEN environment):

conda install -c conda-forge pyomo glpk coincbc cyipopt
pyomo download-extensions
pyomo build-extensions

To run the exported file (after pyomo_serialization test run):

cd tests/framework/Models/External
python3 SerializePyomo/rom_out.py -r SerializePyomo/rom_pickle.pk -f ../../../..

joshua-cogliati-inl avatar Aug 23 '21 21:08 joshua-cogliati-inl

Job Test qsubs on 0a15a53 : invalidated by @joshua-cogliati-inl

civet recipe change

moosebuild avatar Aug 24 '21 13:08 moosebuild

Job Test qsubs on 0a15a53 : invalidated by @milljm

Relaunching with correct /ibmstore path (/scratch causes strange linking issues with symlinks)

moosebuild avatar Aug 24 '21 13:08 moosebuild

Job Test Fedora 31 on 220c502 : invalidated by @joshua-cogliati-inl

test civet

moosebuild avatar Aug 26 '21 19:08 moosebuild

Job Test CentOS 7 on 220c502 : invalidated by @joshua-cogliati-inl

test civet

moosebuild avatar Aug 26 '21 20:08 moosebuild

Job Test Fedora 32 on 220c502 : invalidated by @joshua-cogliati-inl

test civet

moosebuild avatar Aug 26 '21 20:08 moosebuild

Job Test mac on 220c502 : invalidated by @joshua-cogliati-inl

test civet

moosebuild avatar Aug 26 '21 21:08 moosebuild

Job Mingw Test on 220c502 : invalidated by @joshua-cogliati-inl

test civet

moosebuild avatar Aug 26 '21 21:08 moosebuild

Job Test CentOS 8 on 220c502 : invalidated by @joshua-cogliati-inl

test civet

moosebuild avatar Aug 26 '21 21:08 moosebuild

The test now has:

  solver = pyo.SolverFactory('cyipopt')
  solver.config.options['hessian_approximation'] = 'limited-memory'
  results = solver.solve(concreteModel)
  print(results)

and can be run by hand and gets the results:

Problem: 
- Name: unknown
  Lower bound: -inf
  Upper bound: 0.3587964554159516
  Number of objectives: 1
  Number of constraints: 1
  Number of variables: 3
  Number of binary variables: 0
  Number of integer variables: 0
  Number of continuous variables: 3
  Sense: minimize
Solver: 
- Name: cyipopt
  Status: ok
  Return code: 0
  Message: b'Algorithm terminated successfully at a locally optimal point, satisfying the convergence tolerances (can be specified by options).'
  Wallclock time: 0.16565379899999755
  Termination condition: optimal

joshua-cogliati-inl avatar Aug 26 '21 21:08 joshua-cogliati-inl

Job Test Ubuntu 18-2 Python 3 on 5b4891a : invalidated by @joshua-cogliati-inl

killed temp directory accidently

moosebuild avatar Aug 31 '21 16:08 moosebuild

Job Test mac on 2d54d05 : invalidated by @joshua-cogliati-inl

test civet

moosebuild avatar Sep 08 '21 19:09 moosebuild

Job Test mac on 2d54d05 : invalidated by @joshua-cogliati-inl

restarted civet

moosebuild avatar Sep 09 '21 17:09 moosebuild

Job Mingw Test on 2d54d05 : invalidated by @joshua-cogliati-inl

restarted civet

moosebuild avatar Sep 09 '21 17:09 moosebuild

Job Test qsubs on b8c61c8 : invalidated by @joshua-cogliati-inl

strange version.tex error.

moosebuild avatar Oct 25 '21 16:10 moosebuild

Job Test qsubs falcon on 54cf3ff : invalidated by @joshua-cogliati-inl

changes in master.

moosebuild avatar Nov 18 '21 22:11 moosebuild

Job Test qsubs falcon on b734c1c : invalidated by @wangcj05

moosebuild avatar Dec 01 '21 04:12 moosebuild

This is partially blocked by: https://github.com/Pyomo/pyomo/issues/2345

joshua-cogliati-inl avatar Mar 16 '22 15:03 joshua-cogliati-inl

Github is being slow, 125f4a5f146b61cf04ec49b2584b537e279301ba has not shown up yet.

https://www.githubstatus.com/incidents/sksd097hm0y5

joshua-cogliati-inl avatar Mar 17 '22 16:03 joshua-cogliati-inl

Job Test qsubs sawtooth on 8747611 : invalidated by @yoshiurr-INL

Need to restart checking process due to possible sawtooth cluster issues.

moosebuild avatar Mar 23 '22 17:03 moosebuild

This sorta depends on both: https://github.com/idaholab/LOGOS/issues/35 and https://github.com/idaholab/HERON/pull/124 (at least if we want to be able to test since those need to be fixed since LOGOS and HERON currently depend on a pyomo < 6, but this depends on pyomo 6 so the optional test will fail because those requirements conflict.)

joshua-cogliati-inl avatar Mar 23 '22 17:03 joshua-cogliati-inl