Optimizing using fmincon in a "discrete" way
7 次查看(过去 30 天)
显示 更早的评论
I am modelling a battery and interested in finding the best current that maximizes the energy output, using fmincon. I will summarize the idea:
- The battery is a system of differential-algebraic equations, so we employ ode15s.
- The cell potential will be obtained upon solving the DAE's, and this value is a subtraction of the integrated variables. Say it is y(20) - y(19) (the cathode minus the anode).
- We integrate the cell potential across the capacity, the capacity being "time multiplied by the current", so that the energy is trapz(t.*I, y(:, 20) - y(:, 19)).
- One of the restrictions in fmincon is that the time for the discharge doesn't exceed some limit. Thus, we would have something like t(end) = 10 in the ceq vector in nonlcon within fmincon.
The system can be solved only if we give a value to the electric current I. The most direct way is a constant discharge, so we just give ode15s some constant value of I. Another way can be to set up a function of the current, say I(t) = a*cos(t) + b*t. This function doesn't make sense, but anyways, fmincon will vary the parameters a and b in order to maximize the energy given by the said integral.
However, my question is the following. Lets say I don't want to set any time-dependent function for the current I(t). I would like to maximize the energy with a current that is an array of numbers. So, at the times given at tspan, we would have a different value I. Thus, we would have obtained the "optimal values" for the current at every instant of time, that maximizes the integral. In other words, instead of obtaining a set of parameters with fmincon, its output would be a vector of I = [I(t = 0), I(t = t1), ..., I(t = end)].
Is it possible to implement this? Maybe fmincon is not the correct way to do this, and there is other path, which of course I am interested in knowing. Thanks in advance
0 个评论
回答(1 个)
Bruno Luong
2023-9-4
编辑:Bruno Luong
2023-9-4
There is no problem for fmincon to optimize "discrete" variables as long as you can simuate the model with it, meaning you can solve your ode15s by mean of interpolation of I so as it is available at all t.
I put "discrete" in quote because usualy discrete means the variable can only take discrete values. In your case I(t0), ...I(tend) are continuous but you have a finite disretization of the continuous signal (value). So it perfectly fine for fmincon.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!