Formulate an objective function with summation terms to solve a linear programming problem
14 views (last 30 days)
Show older comments
Nick Varnas
on 27 May 2022
Commented: Walter Roberson
on 27 May 2022
I am trying to formulate the following problem
where the decision variables are and , are given matrices of length N and M respectively.
All i am interested in, is the formulation of the objective function to solve using linprog. If not possible using linprog,
how should i formulate it to solve using fmincon?
0 Comments
Accepted Answer
John D'Errico
on 27 May 2022
Edited: John D'Errico
on 27 May 2022
Why would you need fmincon on a purely linear problem?
u and v may be different vectors in your eyes, but they can trivially be combined into ONE vector. Call the unknown vector bauv, where you will pack it all into ONE unknown vector. That is, bauv=[b,a,u,v].
Now you just form the sum to minimize as a linear combination of the elements of bauv. So use of linprog will be nothing more complicated than your ability to create the correct matrices, both for the objective, and for the inequality constraint array, but nothing more.
(I know, your next question will be, but how do I do that????)
b is a scalar unknown.
a is an unknown vector, of length that you have not specified. That is, it appears you have said that the vectors xi are of length N. So if a is a vector, then it MUST be of length N.
At the same time, you claim that yi are also vectors, of length M. And therefore a MUST be of length M, itf you will form a dot product there too. So now a must be a vector of length both N and M. I'll assume that N MUST be the same as M for your problem to make any sense at all.
u is an unknown vector of length N.
v is therefore also a vector of length M = N.
So now you just pack it all together. In the linear programming problem, if X is the vector of unknowns, X = [b,a,u,v], then the objective is defined by a dot product with the vector f*X. Here f will be something like:
f = [0,zeros(1,N),ones(1,2*N)];
Remember that based on what you have said, this makes no sense unless N==M. Now just build up the constraints as you need them, and call linprog.
3 Comments
Walter Roberson
on 27 May 2022
Let x = [u; v] for column vectors u v. then sum(u) + sum(v) = ones(1,length(x)) * x
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!