Linear optimization with sums in the objective function
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Torsten
am 4 Dez. 2018
Bearbeitet: Torsten
am 4 Dez. 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.
Siehe auch
Kategorien
Mehr zu Linear Least Squares finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!