for someone watching the programming for engineers playlist, and being new to matlab, it's to hard to follow everything here, still, you are the best professor john, wish you a long happy life, sincerely
There are a couple different ways to do the sensitivity analysis. The easiest is to use finite differences with odeint and autograd: kitchingroup.cheme.cmu.edu/blog/2019/09/13/Sensitivity-analysis-with-odeint-and-autograd/ A more exact way is to integrate the ODEs with the adjoint equations to get exact sensitivities.
Yes, it should work with any number of parameters (1000's) and variables (10,000+). Additional tutorials on ODE solutions are on the dynamic optimization course at apmonitor.com/do There is also a user's group at apmonitor@googlegroups.com if you need help with your application.
Thank you Prof Hedengren for the great tutorial!!! I have a question with the ODE functions. What if the ODE have time varying external inputs? How can I use my measurement data for those external inputs? For example, dxdt = - k*x + par(t) *x, where par(t) are measured at t = 1, 10, 20, .... Looking forward to your answer! Thanks!
+TIAN ZHANG, use an anonymous function to bring in the additional input. This video: ua-cam.com/video/QKhy1JsdiUo/v-deo.html shares how to do this starting at about 4 minutes. The u value is the additional input. You can put the ode integrator in a loop and have it cycle each time the input changes. You'll need to store the results as you cycle through the loop. Let me know if you need more help.
Thanks for your tutorial! Can you help me with a problem. how can I call the ode45 output after solving the ODE in ga optimization toolbox as a fitnessfunction
I haven't used the GA optimization toolbox but I encourage you to either try to make the ode45 output a global variable or else see if there are optional arguments that you can pass with the GA optimization output.
Thanks for your tutorial! Can you help me with a problem. I have an equation like dX/dt = AX+BU. X is a 2 dimensional vector. A and B are 2*2. U is known for all the instances. I have to find the optimum A and B for which cost function Y(real) - [0 1]*X is minimum. I want to use fminsearch for the whole thing. I also have initial guess of cost function and the A and B matrices which gave me the initial cost function
Check out #2 at this page: apmonitor.com/che263/index.php/Main/MatlabDynamicSim for integrating a system with more than 1 state. For fmincon, you'll need to create an objective function and call fminsearch (unconstrained) or fmincon (constrained) to find the solution. If you need something that will solve faster than fmincon, then please have a look at APMonitor (Dynamic optimization course at apmonitor.com/do), a MATLAB toolbox.
please i have a system with 2 delays d1 and d2 which are the optimisation’s variable and needs to be find by optimisation tools. Similar to objective function, I have a constrain function (which is again a function of x and has d1 d2 (reals valors) inside).. a help please??
I don't have a specific example for your case. However, there is excellent literature on the subject of time delay estimation. Here is one example: pubs.acs.org/doi/pdf/10.1021/ie300786g
APMonitor.com please sir can you give me the codes m.file because i didn't know how to download it ...and if you have others links i will be very gratiful
Thank you for this great tutorial. I have one question, if I have the following couple ODE, what is the best way to solve for the unknown parameters? dv/dt = (Yv/(m-Xud))*v + (Yr/(m-Xud))*r dr/dt = (Nv/(Iz-Nrd))*v + (Nr/(Iz-Nrd))*r + (T/(Iz-Nrd))*Tr where the unknown parameters are Yv, Yr, Xud, Nv, Nrd and Nr m and Iz are know constants dv/dt, dr/dt, v, r and Tr are obtained from experiment. Thank you.
You can start with the files that are posted to apmonitor.com/me575/index.php/Main/DynamicOptimization or the course on dynamic optimization apmonitor.com/do (see Estimation section). You can create an objective function such as a sum of squared errors to penalize deviation of the model predictions from your measured values.
Brian, I'll be glad to help you with your question on regression. Please subscribe to the e-mail list at apmonitor@googlegroups.com and post a message or contact me directly at john.hedengren@byu.edu.
Yes, please see the dynamic optimization course for many tutorials and downloadable example problems at apmonitor.com/do I'll also be glad to help if you'd like to post your problem to the APMonitor user's group.
Great lecture and materials! Do you have any example material regarding optimizing multiple parameters in coupled ODE's? For example: dx(t)/dt = - k1*x(t) dy(t)/dt = k1*x(t) - k2*y(t) Where a data set for x(t) and y(t) were obtained experimentally, and k1, k2 are unknown. Thanks!
Hi APMonitor tutor thanks a lot for your videos! I have a question related. Is it possible to run fmincon where my objective matlab function 'myObj' and 'mySim' have multiple parameters (k1, k2 ...)?
Yes, you can just add them as input parameters if you use an anonymous function. Here is a similar example but for an ode integration. ua-cam.com/video/QKhy1JsdiUo/v-deo.htmlm32s Same thing applies to passing in parameters to fmincon. Instead of passing in the objective name 'myObj', pass in an anonymous function @(x)myObj(x,p).
+edisa avdihodzic myNoise.m is a function that corrupts the data artificially for this example so that we don't have perfect data. The numbers are arbitrary. You will see that myNoise.m function is only used in mySim.m (for simulating) and myObj.m (for computing the objective function). You can download the files at apmonitor.com/me575/index.php/Main/DynamicOptimization
What if I have to optimise just one of the multiple ODEs by varying one or two variables? e.g. I have 18 ODEs, each containing the concentration of different reactants and products of an acid hydrolysis reaction. I need to maximize one of the products by varying Temperature and Concentration of acid.
Here is a tutorial on optimizing parameters in an ODE model: ua-cam.com/video/ynm7B0N0_Yw/v-deo.html There is also the dynamic optimization course at apmonitor.com/do
for someone watching the programming for engineers playlist, and being new to matlab, it's to hard to follow everything here, still, you are the best professor john, wish you a long happy life, sincerely
This video helped me a lot. Thank you for sharing this tutorial with us!
This videonwill help me a lot in my research. Sir do you have video on ODE sensitivity analysis?
There are a couple different ways to do the sensitivity analysis. The easiest is to use finite differences with odeint and autograd: kitchingroup.cheme.cmu.edu/blog/2019/09/13/Sensitivity-analysis-with-odeint-and-autograd/ A more exact way is to integrate the ODEs with the adjoint equations to get exact sensitivities.
Thanks for your tutorial! It works perfectly!
I just have a question, can I do the same when I have 3 parameters (and 2 equations) instead of one?
Yes, it should work with any number of parameters (1000's) and variables (10,000+). Additional tutorials on ODE solutions are on the dynamic optimization course at apmonitor.com/do There is also a user's group at apmonitor@googlegroups.com if you need help with your application.
I am getting an error like "Unrecognized function or variable 'k0'." when I run it in MATLAB R2019b...
Can You help me with it,sir?
When you download the source, make sure you are in the correct run directory before you begin.
Thank you Prof Hedengren for the great tutorial!!! I have a question with the ODE functions. What if the ODE have time varying external inputs? How can I use my measurement data for those external inputs? For example, dxdt = - k*x + par(t) *x, where par(t) are measured at t = 1, 10, 20, .... Looking forward to your answer! Thanks!
+TIAN ZHANG, use an anonymous function to bring in the additional input. This video: ua-cam.com/video/QKhy1JsdiUo/v-deo.html shares how to do this starting at about 4 minutes. The u value is the additional input. You can put the ode integrator in a loop and have it cycle each time the input changes. You'll need to store the results as you cycle through the loop. Let me know if you need more help.
Thanks for your tutorial! Can you help me with a problem. how can I call the ode45 output after solving the ODE in ga optimization toolbox as a fitnessfunction
I haven't used the GA optimization toolbox but I encourage you to either try to make the ode45 output a global variable or else see if there are optional arguments that you can pass with the GA optimization output.
Thanks for your tutorial! Can you help me with a problem. I have an equation like dX/dt = AX+BU. X is a 2 dimensional vector. A and B are 2*2. U is known for all the instances. I have to find the optimum A and B for which cost function Y(real) - [0 1]*X is minimum. I want to use fminsearch for the whole thing. I also have initial guess of cost function and the A and B matrices which gave me the initial cost function
Check out #2 at this page: apmonitor.com/che263/index.php/Main/MatlabDynamicSim for integrating a system with more than 1 state. For fmincon, you'll need to create an objective function and call fminsearch (unconstrained) or fmincon (constrained) to find the solution. If you need something that will solve faster than fmincon, then please have a look at APMonitor (Dynamic optimization course at apmonitor.com/do), a MATLAB toolbox.
please i have a system with 2 delays d1 and d2 which are the optimisation’s variable and needs to be find by optimisation tools. Similar to objective function, I have a constrain function (which is again a function of x and has d1 d2 (reals valors) inside).. a help please??
I don't have a specific example for your case. However, there is excellent literature on the subject of time delay estimation. Here is one example: pubs.acs.org/doi/pdf/10.1021/ie300786g
APMonitor.com please sir can you give me the codes m.file because i didn't know how to download it ...and if you have others links i will be very gratiful
Sure, here is the link: apmonitor.com/me575/index.php/Main/DynamicOptimization It is the first zipped archive at the top.
APMonitor.com The page "Main/Dynamicoptimization" doesn't exist :(
Thank you for this great tutorial. I have one question, if I have the following couple ODE, what is the best way to solve for the unknown parameters?
dv/dt = (Yv/(m-Xud))*v + (Yr/(m-Xud))*r
dr/dt = (Nv/(Iz-Nrd))*v + (Nr/(Iz-Nrd))*r + (T/(Iz-Nrd))*Tr
where the unknown parameters are Yv, Yr, Xud, Nv, Nrd and Nr
m and Iz are know constants
dv/dt, dr/dt, v, r and Tr are obtained from experiment.
Thank you.
You can start with the files that are posted to apmonitor.com/me575/index.php/Main/DynamicOptimization or the course on dynamic optimization apmonitor.com/do (see Estimation section). You can create an objective function such as a sum of squared errors to penalize deviation of the model predictions from your measured values.
Thank you for your answer. I got the idea from your course to solve the problem.
Great stuff here.... i however need some help with regards regression. How can i reach you
Brian, I'll be glad to help you with your question on regression. Please subscribe to the e-mail list at apmonitor@googlegroups.com and post a message or contact me directly at john.hedengren@byu.edu.
helo sir
can you help me out to optimize multiple ode by differential evolution technique??
Yes, please see the dynamic optimization course for many tutorials and downloadable example problems at apmonitor.com/do I'll also be glad to help if you'd like to post your problem to the APMonitor user's group.
Great lecture and materials! Do you have any example material regarding optimizing multiple parameters in coupled ODE's?
For example:
dx(t)/dt = - k1*x(t)
dy(t)/dt = k1*x(t) - k2*y(t)
Where a data set for x(t) and y(t) were obtained experimentally, and k1, k2 are unknown. Thanks!
Sure, here is one video... ua-cam.com/video/WIXeySSa1fk/v-deo.html
APMonitor.com HI SIR do you have an example about systems with delays witch we search the delays with this..???
Hi APMonitor tutor thanks a lot for your videos! I have a question related. Is it possible to run fmincon where my objective matlab function 'myObj' and 'mySim' have multiple parameters (k1, k2 ...)?
Yes, you can just add them as input parameters if you use an anonymous function. Here is a similar example but for an ode integration. ua-cam.com/video/QKhy1JsdiUo/v-deo.htmlm32s Same thing applies to passing in parameters to fmincon. Instead of passing in the objective name 'myObj', pass in an anonymous function @(x)myObj(x,p).
Thanks a lot!
What is myNoise function.....pls help!!!!
+edisa avdihodzic myNoise.m is a function that corrupts the data artificially for this example so that we don't have perfect data. The numbers are arbitrary. You will see that myNoise.m function is only used in mySim.m (for simulating) and myObj.m (for computing the objective function). You can download the files at apmonitor.com/me575/index.php/Main/DynamicOptimization
What if I have to optimise just one of the multiple ODEs by varying one or two variables?
e.g. I have 18 ODEs, each containing the concentration of different reactants and products of an acid hydrolysis reaction. I need to maximize one of the products by varying Temperature and Concentration of acid.
Here is a tutorial on optimizing parameters in an ODE model: ua-cam.com/video/ynm7B0N0_Yw/v-deo.html There is also the dynamic optimization course at apmonitor.com/do
Thank very much