Linear optimization with sums in the objective function
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (2)
Torsten
el 4 de Dic. de 2018
Editada: Torsten
el 4 de Dic. de 2018
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.
Ver también
Categorías
Más información sobre Linear Least Squares en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!