Linear constraints in FMINCON Optimization

I'm using fmincon for solving an optimization problem. Mathematical model consists of 12 equations, control vector u contains 4 elements.
State vector:
x =[0 3 0 0 5 0 0 0 12 0 0 0];
I want to put linear constraints on the on the 2nd, 5th and 9th elements, so that x(2)=<5, x(5)=<10 x(9)>=10. I wrote it in the following way:
function [A, b, Aeq, beq, lb, ub] = linearconstraints(t, x, u)
A = [0,1,0,0,0,0,0,0,0,0,0,0;
0,0,0,0,1,0,0,0,0,0,0,0;
0,0,0,0,0,0,0,0,0,1,0,0];
b = [5;10;-10];
Aeq = [];
beq = [];
lb = [];
ub = [];
end
During the simulation Matlab shows the error:
Error using fmincon (line 298). A must have 4 column(s).
I assume fmincon requires the formulation of A, corresponding to the number of control inputs u (4).
Can you recommend how should the A and b look like so fmincon will work correctly?
Thank you in advance for your answer!

댓글 수: 1

Torsten
Torsten 2019년 7월 8일
You have to put all unknown variables in one vector. In your case, this is most probably the state vector + the control vector, thus a vector of length 16. And this will also be the size of your initial vector when calling "fmincon".

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기

질문:

2019년 7월 7일

댓글:

2019년 7월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by