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
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 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