Help with fmincon function
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Noemi Ambrosio
am 27 Mär. 2019
Bearbeitet: Catalytic
am 27 Mär. 2019
Hello everyone!
I need help with my matlab code. I have this objective function: g = @(u) 30*u(1) + (20/2)*(u(2))^2 + (20/2)*(u(3))^2 + (10/2)*(u(4))^2 + (40/2)*(u(5))^2; and this conditions:
%initial guesses
u0 = [1 1 1 1 100000]; %
A = [];
b = [];
Aeq = [];
beq = [];
lb = 0.0 * ones(1,2,3,4);
ub = 1.0 * ones(1,2,3,4);
[x,fval,output,lambda] = fmincon(g, u0, A, b, Aeq, beq, lb, ub);
I need to find the values for different instant of times, because g is a function of time.
In this way I find only one value for each u. How can I do that and find the different values for each instant of time? I hope it is clear, thank you so much!!
0 Kommentare
Akzeptierte Antwort
Catalytic
am 27 Mär. 2019
Bearbeitet: Catalytic
am 27 Mär. 2019
First of all, let's fix your code.
g = @(u) 30*u(1) + (20/2)*(u(2))^2 + (20/2)*(u(3))^2 + (10/2)*(u(4))^2 + (40/2)*(u(5))^2;
u0 = [1 1 1 1 100000]; %
lb = zeros(1,5);
ub = ones(1,5);
[u,fval,output,lambda] = fmincon(g, u0, [],[],[],[], lb, ub);
In this way I find only one value for each u. How can I do that and find the different values for each instant of time?
By writing a loop over time.
for t=1:T
g = ----- something t-dependent --------
[u(t,:),fval,output,lambda] = fmincon(g, u0, [],[],[],[], lb, ub);
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surrogate Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!