Linear optimization with sums in the objective function

Hello everybody,
I am trying currently to solve a linear problem in Matlab. For the solution I am taking the cplex solver.
My problem is how to hand sums in the objective function as well as in the constraints. All examples are for straight linear problems like:
obj function: 2x+3y (min)
4x + 2 y >= 10
Therefore I would write in matlab:
f = [2; 3];
A = [4 2];
b=10;
[x,z,exitflag,output,lambda] = linprog(f,A,b,Aeq,beq,lb,ub);
Pls keep in mind, that the example isn´t complete.
How I have to change f for sums.
For example the objective function is: sum(i)(sum(j)(pi*xij))
So this means I am having a double sum where p only changes for the different i and x changes for i and j.
But how can I bring the xij into the objective function f?
p=[ 10 13 14]
f=[p(i) ] is that correct? How does Matlab know that I need for x a consideration for xi and xj?
Any help would be very appreciated

Réponses (2)

Torsten
Torsten le 4 Déc 2018
Modifié(e) : Torsten le 4 Déc 2018

0 votes

Do you know how to define f if the objective is
min: x11*p1 + x12*p1 + x13*p1 + x21*p2 + x22*p2 + x23*p2
?
Define
(y1,y2,y3,y4,y5,y6)=(x11,x12,x13,x21,x22,x23)
and write the objective as
min:[p1 p1 p1 p2 p2 p2]*[y1;y2;y3;y4;y5;y6]
Best wishes
Torsten.

1 commentaire

Hello everybody and Torsten thanks for the reply.
I tried a model but so far it s not working. My model and the instruction is at the attachement.
Maybe somebody can tell me what I made wrong?
I would appreciate it a lot.

Connectez-vous pour commenter.

Martin Polz
Martin Polz le 8 Déc 2018

0 votes

Dear Thorsten,
could you maybe show the conversion of x in y in a small example? I have tried it in matlab, but I still can t solve it.
Coz I don t know how to take the sums with y. So is y also noted in Aieq or not?
(y1,y2,y3,y4,y5,y6)=(x11,x12,x13,x21,x22,x23)
I have to define an x matrix? Or is the solution giving me x11, x12 and so on? As I said a small Matlab example would help me so much.
I can t find any linear optimization where y is used instead of x

Catégories

En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by