Implementation of limits on the optimization results

Hi guys, I've want to optimize my problem using "fmincon". I want to put limits on the answers, let's say I want x1 > x2 and x2 > x3 in here:
x = fmincon(fun,x0,A,b,[],[],nonlincon)
how should I implement this kinda constraints?
I've set "A" to [-1 1 0;0 -1 1] and "b" to zeros(size(A,1),1) but I get infeasible results! Shouldn't it work?! Please help me out.
Best regards,

 채택된 답변

Oleg Komarov
Oleg Komarov 2012년 9월 11일
편집: Oleg Komarov 2012년 9월 11일
Should it be
b = zeros(size(A,1),1);
An example problem (without nonlinear constraints):
f = @(x) x(1)^2 + x(2)^2 + x(3)^2;
A = [-1 1 0
0 -1 1];
b = zeros(size(A,1),1);
X = fmincon(f,3:-1:1,A,b);

댓글 수: 5

Thanks, so setting "A" to [-1 1 0;0 -1 1] and "b" to zeros(size(A,1),1) should work correct. right?
Well, I am not sure about the nonlinear constraints, but I can't guess them.
Well, I'm saying in any problem if we want to reach this goal we should apply similar methodes like above, right?
Oleg Komarov
Oleg Komarov 2012년 9월 11일
편집: Oleg Komarov 2012년 9월 11일
I showed you some syntax, not methods.
If you're alluding to the choice of X0 (the starting values for the x) then I just picked up something that did not satisfy the constraints to check afterwards that they were satisfied.
Also, you were talking about x1, x2, x3 and f is an example of a function in 3 variables. Basically, that's how you should write it.
Thanks.

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

제품

질문:

2012년 9월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by