How to define objective function that is not a direct function of decision variable?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to minimize "Cost" while "a, b, c" are the variables.
F1 = (1/a) + b
F2 = 2/F1
F3 = F2*3/c
Cost = F2 + F3
I was wondering how can I solve for minimum Cost, using a problem-based non-linear optimization approach? Any lead will be greatly appreciated.
2 comentarios
Matt J
el 21 de Abr. de 2020
The best advice will depend on what constraints you have on a,b,c. Without constraints, your objective function is unbounded.
Respuestas (1)
Ameer Hamza
el 21 de Abr. de 2020
Editada: Ameer Hamza
el 21 de Abr. de 2020
See this example to see how define the objective function and bound on the optimization variables.
F1 = @(a,b,c) (1./a) + b;
F2 = @(a,b,c) 2./F1(a,b,c);
F3 = @(a,b,c) F2(a,b,c).*3./c;
Cost = @(a,b,c) F2(a,b,c) + F3(a,b,c);
lb = [0 0 0]; % lower bounds on a, b, and c
ub = [1 1 1]; % lower bounds on a, b, and c
x0 = rand(1,3); % initial guess
x_sol = fmincon(@(x) Cost(x(1), x(2), x(3)), x0, [], [], [], [], lb, ub);
a_sol = x_sol(1);
b_sol = x_sol(2);
c_sol = x_sol(3);
2 comentarios
Ameer Hamza
el 22 de Abr. de 2020
Editada: Ameer Hamza
el 22 de Abr. de 2020
Thaneer, You cannot include as Ax=b, because your constraint is not linear. You can add it like this.
F1 = @(a,b,c) (1./a) + b;
F2 = @(a,b,c) 2./F1(a,b,c);
F3 = @(a,b,c) F2(a,b,c).*3./c;
Cost = @(a,b,c) F2(a,b,c) + F3(a,b,c);
lb = [0 0 0]; % lower bounds on a, b, and c
ub = [1 1 1]; % lower bounds on a, b, and c
x0 = rand(1,3); % initial guess
x_sol = fmincon(@(x) Cost(x(1), x(2), x(3)), x0, [], [], [], [], lb, ub, @(x) cons(x, F2));
a_sol = x_sol(1);
b_sol = x_sol(2);
c_sol = x_sol(3);
function [c, ceq] = cons(x, F2)
ceq = [];
c = F2(x(1), x(2), x(3)) - 10;
end
Solution:
>> x_sol
x_sol =
0.0000 0.7288 0.8549
Verify of constraint is met:
>> F2(x_sol(1), x_sol(2), x_sol(3))
ans =
4.4348e-09
Ver también
Categorías
Más información sobre Get Started with Problem-Based Optimization and Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!