Skip to content

Pyomo TCLab v6: optimization proof of concept - #3

Open
adowling2 wants to merge 94 commits into
tclab-notebook-v5from
pyomo-tlab2
Open

adowling2 wants to merge 94 commits into
tclab-notebook-v5from
pyomo-tlab2

Conversation

@adowling2

@adowling2 adowling2 commented Jun 27, 2024

Copy link
Copy Markdown
Owner

This pull request tracks the development of a proof-of-concept for optimizing the GP model for the TCLab in Pyomo.

Branch tclab-notebook-v5 contains v5 of the modeling notebook developed by @jakekrell. In other words, this branch is a "checkpoint" for the state of the repo when v6 development started.

Branch pyomo-tclab2 contains v6 development. My apologies for the confusing branch names.

@adowling2

Copy link
Copy Markdown
Owner Author

My first step was to copy ...v5.ipynb as ...v6.ipynb and then rerun the notebook on my development computer. I got this error message:

Screenshot 2024-06-27 at 9 04 17 AM

@adowling2

Copy link
Copy Markdown
Owner Author

I confirmed the training for FoKL worked. I am going to not worry about the numeric integration error for now. I am also going to temporarily remove the lag for Q. This will make the first Pyomo implementation much easier.

@adowling2

adowling2 commented Jun 27, 2024

Copy link
Copy Markdown
Owner Author

@jakekrell A few updates:

  • From the perspective of optimizing this model in Pyomo, there are some advantages to using the no-lag version of the GP for the initial proof-of-concept. I tried to get the no-lag version working (see ..._v6_no_lag.ipynb) but was unsuccessful.
  • Next, I tried modeling the step test data, which because it is a constant Q, the lag does not matter. The smoothing did not work. See ..._v6_step_test.ipynb
  • This got me thinking... what if the linear system model is reasonable but the discrepancy we are seeing is due to autocorrelated errors. In other words, the errors are correlated with themselves. We should discuss this during our next meeting.

My next steps:

  • Revert to the optimal lag. I think it is less effort to deal with the complications from the lag model in Pyomo.
  • Prototype optimal control problem in Pyomo. (Note to self: just implement forward Euler manually for now. We can worry about Pyomo.DAE later.)

@jacobpkrell

jacobpkrell commented Jun 27, 2024

Copy link
Copy Markdown

My first step was to copy ...v5.ipynb as ...v6.ipynb and then rerun the notebook on my development computer. I got this error message:

Screenshot 2024-06-27 at 9 04 17 AM

@adowling2 Upgrade FoKL to latest release (v3.3.0) and error should resolve.

pip install FoKL --upgrade

@jacobpkrell

Copy link
Copy Markdown

@jakekrell A few updates:

  • From the perspective of optimizing this model in Pyomo, there are some advantages to using the no-lag version of the GP for the initial proof-of-concept. I tried to get the no-lag version working (see ..._v6_no_lag.ipynb) but was unsuccessful.
  • Next, I tried modeling the step test data, which because it is a constant Q, the lag does not matter. The smoothing did not work. See ..._v6_step_test.ipynb
  • This got me thinking... what if the linear system model is reasonable but the discrepancy we are seeing is due to autocorrelated errors. In other words, the errors are correlated with themselves. We should discuss this during our next meeting.

My next steps:

  • Revert to the optimal lag. I think it is less effort to deal with the complications from the lag model in Pyomo.
  • Prototype optimal control problem in Pyomo. (Note to self: just implement forward Euler manually for now. We can worry about Pyomo.DAE later.)

@adowling2 On second thought the lag was effectively yielding np.cos(Q1). If we remove lag but train the GP (of the derivative) on the cosine (which is expected now looking at the dQ1dt term in the v4.1 chain rule equation) then we should be able to get both advantages --- more accurate GP and easier implementation in Pyomo.

@adowling2

Copy link
Copy Markdown
Owner Author

@jakekrell What version of Python are you using?

Screenshot 2024-06-28 at 8 25 50 AM

@adowling2

Copy link
Copy Markdown
Owner Author

@jakekrell pyomo_tclab_v6_optimize1.ipynb is ready for you to take a look. The last cell has a syntax error because the differential equation needs to be updated with the GP model in the RHS.

jacobpkrell and others added 30 commits July 30, 2024 16:47
Adding results from validation experiment
Adding new files from Jacob to test
Updated optimization solutions; ready for testing with TCLab hardware
Added another test with multiple steps.
Getting most recent TCLab notebooks and results from Jacob
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.

2 participants