idaes-pse icon indicating copy to clipboard operation
idaes-pse copied to clipboard

Add additional methods to `MultiPeriodModel` class

Open radhakrishnatg opened this issue 2 years ago • 9 comments

Fixes

https://github.com/gmlc-dispatches/dispatches/issues/112

Summary/Motivation:

  • The nuclear case study in the DISPATCHES project needs additional methods for the formulation of the multiperiod problem.

Changes proposed in this PR:

  • Inherited MultiPeriodModel from ConcreteModel. So, an instance of MultiPeriodModel is now a pyomo model. This way, the user does not need to use instance.pyomo_model to get access to the actual multiperiod model.
  • Added build_stochastic_model method that can construct regular multiperiod model, a multiperiod model with representative days and/or multiple years, and a stochastic version of the multiperiod model
  • Uses from_json and to_json to initialize the multiperiod model, so the initialization step is faster.
  • Added plot_lmp_signals method to generate plots of LMP signals.
  • Added plot_lmp_and_schedule method to generate for plotting optimal schedule results.

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  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.

radhakrishnatg avatar Jul 11 '22 14:07 radhakrishnatg

Codecov Report

Merging #908 (102a69b) into main (087ec96) will increase coverage by 0.12%. The diff coverage is 96.78%.

@@            Coverage Diff             @@
##             main     #908      +/-   ##
==========================================
+ Coverage   70.07%   70.19%   +0.12%     
==========================================
  Files         573      573              
  Lines       64007    64217     +210     
  Branches    12053    12121      +68     
==========================================
+ Hits        44850    45075     +225     
+ Misses      16868    16847      -21     
- Partials     2289     2295       +6     
Impacted Files Coverage Δ
...s/apps/grid_integration/multiperiod/multiperiod.py 88.84% <96.77%> (+68.84%) :arrow_up:
idaes/apps/grid_integration/__init__.py 100.00% <100.00%> (ø)
idaes/ver.py 61.53% <0.00%> (-4.62%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Jul 12 '22 16:07 codecov[bot]

@lbianchi-lbl It appears to me that the test failures are not because of this PR. Could you please confirm?

radhakrishnatg avatar Jul 25 '22 12:07 radhakrishnatg

@radhakrishnatg Which test failures are you referring too? All the tests appear to be passing here (so far).

andrewlee94 avatar Jul 25 '22 13:07 andrewlee94

Sorry, @andrewlee94 ! Until an hour ago, tests were failing on 3.8 and 3.9 (it said, did not find idaes, or something like that). I don't know what changed, the tests are passing now.

radhakrishnatg avatar Jul 25 '22 13:07 radhakrishnatg

@radhakrishnatg I have re-run the failed jobs, and it looks like the cause of the failure was just a network error. For reference, you should be able to do the same by clicking on the "Re-run jobs" > "Re-run failed jobs" menu in the Actions page:

image

lbianchi-lbl avatar Jul 25 '22 14:07 lbianchi-lbl

@radhakrishnatg I didn't scan through the changed files too thoroughly and haven't tried using multiperiod models just yet, but will the previous formulation still work? That is, will this be backwards compatible? We want to start using multiperiod models in WaterTAP to begin incorporating quasi-steady-state desalination models.

adam-a-a avatar Jul 28 '22 17:07 adam-a-a

@adam-a-a Yes, I made sure that the changes are backwards compatible. The changes I made to the existing code are (i) inherit MultiPeriodModel class from pyomo's ConcreteModel. This way, an instance of the class will be a pyomo model (Previously, the pyomo model was contained in instance.pyomo_model. Note that instance.pyomo_model still works with the changes), (ii) I added a method that makes the initialization of the entire model faster (This is optional though). Other than these two changes, the existing code remains intact. Having said that, I didn't do extensive testing. All the existing tests which use the multiperiod model are passing, so I'm assuming that there is no issue with backwards compatibility. Please let me know if you find any.

radhakrishnatg avatar Jul 28 '22 18:07 radhakrishnatg

@xiangao1, @jghouse88, @dguittet, @nareshsusarla, @esrawli Can we get some reviews on this?

ksbeattie avatar Aug 04 '22 18:08 ksbeattie

Thanks @adam-a-a for reviewing the PR and for the suggestion! I changed all the methods to multi_period to keep it consistent and backwards compatible.

radhakrishnatg avatar Aug 09 '22 13:08 radhakrishnatg

@xiangao1, @dguittet, @nareshsusarla, @esrawli

We really need another review on this. We are planning on cutting the Aug release candidate this week and DISPATCHES needs this for it's Sept release.

ksbeattie avatar Aug 18 '22 18:08 ksbeattie

Looks good. Seems to be working.

nareshsusarla avatar Aug 19 '22 10:08 nareshsusarla