필터 지우기
필터 지우기

Help !! Problems Using fmincon

조회 수: 1 (최근 30일)
Ahmad Sawwas
Ahmad Sawwas 2019년 11월 21일
댓글: Erivelton Gualter 2019년 11월 21일
Hello Everyone,
i am trying to use fmincon to find an optimal matrix which minimizes a cost function.
Assuming the matrix is called "x", x being an (N x T) matrix, (where N and T are known values) has the following form:
x = [ x11 x12 x13 ........ x1T
x21 x22 x23 ........ x2T
.... .... ....
. ....
. ....
. ....
. ....
xN1 xN2 xN3 .......... XNT ]
The problem that im facing is that i have linear equality constraints and linear inequality constraints, for example:
the sum of x(:,1) = a1;
the sum of x(:,2) = a2;
.
.
the sum of x(:,T) = aT;
and the inequality constraints are:
the sum of x(1,:) <= b1;
the sum of x(2,:) <= b2;
.
.
the sum if x(N,:) <= bN;
how can i formulate such constraints using fmincon ??
Thanks
  댓글 수: 3
Ahmad Sawwas
Ahmad Sawwas 2019년 11월 21일
Sorry but i didnt understand your advice, what do you mean by problem based optimization ?

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

답변 (1개)

Erivelton Gualter
Erivelton Gualter 2019년 11월 21일
I see that you already have choose your solver, which is fmincon. Go over on the Description of the solver and note it contains Linear Inequality and Equality Constraint. There are the A,b, Aeq, and beq variables.
I assume that you may be confused only on formualting the constraints and you know how to code cost function and apply fmincon.
Note, fmincon will minimize x, which is an array. So, you need to reshape the matrix arguments in 1D representation. For example:
% If you have 3x3
x=[x11, x21, x31;
x12, x22, x32;
x13, x23, x33]
% Create your a array
x = [x11, x21, x31, x12, x22, x32, x13, x23, x33]
% Select A, b, Aeq and beq
A = eye(3)
b = [a1 a1 a1 a2 a2 a2 a3 a3 a3];
Aeq = eye(3)
b = [b1 b1 b1 b2 b2 b2 b3 b3 b3];
Hopefully it gave you some insignt.
  댓글 수: 2
Matt J
Matt J 2019년 11월 21일
편집: Matt J 2019년 11월 21일
Note, fmincon will minimize x, which is an array. So, you need to reshape the matrix arguments in 1D representation.
No, fmincon will do the reshaping for you automatically. However, the A, Aeq have to be constructed with the expectation that they will be multiplied with x(:)
A*x(:)<=b(:)
Aeq*x(:)=beq;
Erivelton Gualter
Erivelton Gualter 2019년 11월 21일
Thanks Matt ;)
I have been doing unnecessary work.

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

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by