How to find a proper algorithm to solve this optimal control problem?
Show older comments
Hi everyone!
I am trying to find a way to solve this optimal control problem in MATLAB. The function is too complex and the using Hamiltonian in MATLAB couldn't help.The problem describes as below:
p = 100;
a = 0;
b = 0.07;
c = 0.04;
r = 0.005;
z = 0.1;
c0 = 70;
x0 = 0.4;
alpha = 0.005;
beta = 0.006;
gamma = 0.003;
delta = 0.007;
Dx = (alpha + beta*u + (gamma + delta*u)*x)*(1-x); % State Equation
f = ((p - c0*((x0/x)^z))*Dx) - (a + (b*u) + (c*u^2)); % Function inside the integral (Cost function)
% x(t0) = 0.4, x(tf) = free, t0 = 0. tf = 31
Note that the aim is to maximize the function f.
I tried to use fmincon and still the function is too complex to get an answer.
Thanks!
3 Comments
Torsten
on 13 Jan 2022
It will cost you quite a lot of effort to program an optimal control problem from scratch.
If you already spent this effort, please show your attempt with "fmincon".
Otherwise you should use one of the control packages which use MATLAB, e.g.
Ehsan Ranjbari
on 13 Jan 2022
Torsten
on 13 Jan 2022
Sorry, but I have no experience with numerical optimal control.
So I can't give you advise in this respect.
Accepted Answer
More Answers (1)
You did not say what you wanted to optimzie with respect to. If you wanted to optimize with respect to u, then see solu below.
If you wanted to optimize with respect to x (in terms of u) then I will need to do more testing.
syms x u
p = 100;
a = 0;
b = 0.07;
c = 0.04;
r = 0.005;
z = 0.1;
c0 = 70;
x0 = 0.4;
alpha = 0.005;
beta = 0.006;
gamma = 0.003;
delta = 0.007;
Dx = (alpha + beta*u + (gamma + delta*u)*x)*(1-x); % State Equation
f = ((p - c0*((x0/x)^z))*Dx) - (a + (b*u) + (c*u^2)); % Function inside the integral (Cost function)
f
Dfu = diff(f,u)
string(Dfu)
solu = simplify(solve(Dfu, u))
Dfx = diff(f,x)
string(Dfx)
3 Comments
Walter Roberson
on 13 Jan 2022
Solving the derivative with respect to x gives you
1 / RootOf((42*u+35)*Z^21+(-63*u+126)*Z^11+(50*5^(1/10)*2^(9/10)*u-100*2^(9/10)
*5^(1/10))*Z^10+(931*u+399)*Z-700*5^(1/10)*2^(9/10)*u-300*2^(9/10)*5^(1/10), Z)^
10
That is, you have to solve the degree 21 polynomial involving u to find the set of values, Z, such that the expression becomes 0; and when you do, the -10'th power of that is the optimal x.
Polynomials of degree 21 do not generally have algebraic solutions, so you would have to solve numerically for each different u value
I think the problem is
Find u(t) such that
integral_{t=0}^{t=tf} ((p - c0*((x0/x(t))^z))*dx/dt) - (a + (b*u(t)) + (c*u(t)^2)) dt
is maximized under the constraint
dx/dt = (alpha + beta*u(t) + (gamma + delta*u(t))*x(t))*(1-x(t))
x(0)=0, x(tf) = free
Ehsan Ranjbari
on 14 Jan 2022
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
