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

4 ビュー (過去 30 日間)
Thaneer Malai Narayanan
Thaneer Malai Narayanan 2020 年 4 月 21 日
編集済み: Ameer Hamza 2020 年 4 月 22 日
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
Thaneer Malai Narayanan 2020 年 4 月 21 日
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
Thaneer Malai Narayanan 2020 年 4 月 21 日
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 Center および File ExchangeGet 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