Optimisation using fmincon (constraints)

조회 수: 1 (최근 30일)
R Hebi
R Hebi 2020년 3월 7일
댓글: Ameer Hamza 2020년 3월 8일
Hi,
I have a function I would like to optimize it but this function has multi varabiles (T & c2 )
The objectives is to identify the minimum V
I did the following
q = 30;
c1i = 5;
x0 = 0;
lb = 300;
[T,V] = fmincon(V,x0,A,b,Aeq,beq,lb,ub);
how can I insert the (c1o) constraint & work out the c2

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 3월 7일
You can solve for multiple variables, but all of them need to be elements of x. See how in the following example. the objective function V is changed
q = 30;
c1i = 5;
c1o = 1; % HERE IS MY PROBLEM
c2 = 4; % HERE IS MY PROBLEM
A = [];
b = [];
Aeq = [];
beq = [];
x0 = [1 500 1];
lb = [-inf -inf -inf];
ub = [1.143 inf inf];
k1 = @(x) 7.0*(10^15)*exp(-15075/x);
k2= @(x) 2.86*(10^4)*exp(-5025/x);
V = @(x) q*(c1i-x(1))./(x(1)*k1(x(2))-x(3)*k2(x(2))); % c1o => x(1), T => x(2), c2 => x(3)
[T,V] = fmincon(V,x0,A,b,Aeq,beq,lb,ub);
  댓글 수: 2
R Hebi
R Hebi 2020년 3월 8일
Thinks
What if I want to add a linear equlaity constraint, such as
x(2)+x(3)=5
Is it like this ?
A = [0 1 1];
b = [5]
Ameer Hamza
Ameer Hamza 2020년 3월 8일
R Hebi, yes, that's correct.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by