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