How to define objective function that is not a direct function of decision variable?

3 次查看(过去 30 天)
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 个评论
Matt J
Matt J 2020-4-21
The best advice will depend on what constraints you have on a,b,c. Without constraints, your objective function is unbounded.
Thaneer Malai Narayanan
Thanks, lets assume the variables ae bounded and continuous. My question is how do i express the constaints and obj function of this problem?

请先登录,再进行评论。

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-4-21
编辑:Ameer Hamza 2020-4-21
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 个评论
Thaneer Malai Narayanan
Thank you Ameer. This worked. Now I want to add a constrant on F2. Could you please show how to do it?
For example,
F2 <= 10
I was wondering how to change include that as Ax = b? Really appreciate your help.
Ameer Hamza
Ameer Hamza 2020-4-22
编辑:Ameer Hamza 2020-4-22
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Problem-Based Optimization and Equations 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by