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 Comment

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".

Sign in to comment.

Answers (0)

Categories

Asked:

on 7 Jul 2019

Commented:

on 8 Jul 2019

Community Treasure Hunt

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

Start Hunting!