raven
raven copied to clipboard
Alfoa/rom to pyomo
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
andraven/docs/workshop
) have been changed, the associated documentation must be reviewed and assured the text matches the example.
@joshua-cogliati-inl added description.
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 Is there a specific pull request or issue in Pyomo this is waiting on? Thanks.
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.
FYI: This is currently waiting on https://github.com/idaholab/raven/pull/1608
Job Test qsubs on feb0bca : invalidated by @joshua-cogliati-inl
AssertionError: /home/moosetest/.conda/pkgs/yarl-1.6.3-py37h27cfd23_0/info/index.json
FYI: https://github.com/idaholab/raven/pull/1608 has been merged, so the major need of this pull is a test.
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
andpyomo build-extensions
) - Add documentation
- Figure out a good way to have steps export different types of things (See XXX comment in IOStep.py)
Job Test qsubs on f80c989 : invalidated by @joshua-cogliati-inl
Conda definitions not found at /home/moosetest/miniconda2/etc/profile.d/conda.sh
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 ../../../..
Job Test qsubs on 0a15a53 : invalidated by @milljm
Relaunching with correct /ibmstore path (/scratch causes strange linking issues with symlinks)
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
Job Test Ubuntu 18-2 Python 3 on 5b4891a : invalidated by @joshua-cogliati-inl
killed temp directory accidently
Job Test qsubs falcon on b734c1c : invalidated by @wangcj05
This is partially blocked by: https://github.com/Pyomo/pyomo/issues/2345
Github is being slow, 125f4a5f146b61cf04ec49b2584b537e279301ba has not shown up yet.
https://www.githubstatus.com/incidents/sksd097hm0y5
Job Test qsubs sawtooth on 8747611 : invalidated by @yoshiurr-INL
Need to restart checking process due to possible sawtooth cluster issues.
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.)