Linear optimization with sums in the objective function

조회 수: 9 (최근 30일)
Martin Polz
Martin Polz 2018년 12월 4일
답변: Martin Polz 2018년 12월 8일
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

답변 (2개)

Torsten
Torsten 2018년 12월 4일
편집: Torsten 2018년 12월 4일
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
Martin Polz
Martin Polz 2018년 12월 4일
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.

댓글을 달려면 로그인하십시오.


Martin Polz
Martin Polz 2018년 12월 8일
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

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by