Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyomo TCLab v6: optimization proof of concept #3

Open
wants to merge 94 commits into
base: tclab-notebook-v5
Choose a base branch
from

Conversation

adowling2
Copy link
Owner

@adowling2 adowling2 commented Jun 27, 2024

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
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
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
Copy link
Owner Author

adowling2 commented Jun 27, 2024

@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.)

@jakekrell
Copy link

jakekrell commented Jun 27, 2024

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

@jakekrell
Copy link

@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
Owner Author

@jakekrell What version of Python are you using?

Screenshot 2024-06-28 at 8 25 50 AM

@adowling2
Copy link
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.

jakekrell and others added 30 commits July 30, 2024 16:47
Adding results from validation experiment
Adding new files from Jacob to test
Additional validation experiments
Updated optimization solutions; ready for testing with TCLab hardware
Added two more validation experiments
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