Double Summation expression in Objective Function

조회 수: 2 (최근 30일)
pradeep kumar
pradeep kumar 2018년 9월 5일
댓글: Mary Fenelon 2018년 9월 5일
Hi Experts, I have a Parameter matrix, C of size 2x2. It looks like this.
C= [2 4; 6 8]
I have a decision variable, X of size 2x2. It looks like this
[ X('S1', 'D1') X('S1', 'D2') ]
[ X('S2', 'D1') X('S2', 'D2') ]
I want to formulate my Objective Function as a series of double expression (Please refer the attachment),
Which shall look like the following after the expansion.
Z = 2*X('S1', 'D1') + 4*X('S1', 'D2') + 6*X('S2', 'D1') + 8*X('S2', 'D2')
I try the following.
Z = sum(C.*X,1);
But it creates An optimizationExpression of size 1x3, which is not desired.
What am I doing wrong? Is there any easier way to do so without using for loop. I have just started learning "Problem-Based Optimization" in MATLAB today. Any help will be greatly appreciated.

채택된 답변

Mary Fenelon
Mary Fenelon 2018년 9월 5일
Was it a 1x3 OptimizationExpression or 1x2?
In any case, you need to sum over both dimensions to get a single OptimizationExpression
Z = sum(sum(C.*X))
  댓글 수: 2
pradeep kumar
pradeep kumar 2018년 9월 5일
@ Mary Fenelon, Thanks for your solution. It should be actually 1x2 OptimizationExpression, Sorry for my typing mistake. Could you please explain me the logic behind this? I have triple summation and more expressions in the future prob lem.Thanks in advance!
Mary Fenelon
Mary Fenelon 2018년 9월 5일
Look here for documentation on the sum function. This example has a 3 dimensional OptimizationVariable.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by