Mathematical Modeling with LPL : Explain and run a Model
Problem Statement
Modeling Description
||
Back to MatMod
model exerSum "Exercise in Indexing"; set i:=1..5; set j:=1..4; parameter P{j}:=[4 6 8 7]; parameter A{i}:=[5,2,2,4,1]; parameter X{i,j}:=[3 6 5 4, 6 7 7 1, 7 8 4 2, 3 3 2 6, 5 8 3 8]; parameter Y{i,j}:=[4 1 6 6, 3 3 4 4, 4 8 5 3, 6 7 4 5, 3 5 5 3]; Writep(P,A,X,Y); Write('a) %5.2f\n', sum{i} A); Write('b) %5.2f\n', sum{j} P); Write('c) %5.2f\n', sum{j} X[1,j]); Write('d) %s\n', {i|i<=2} Format('i=%d: %5.2f ',i,sum{j} X)); Write('e) %5.2f\n', sum{i} sum{j} X[i,j]*Y[i,j]); Write('f) %5.2f\n', sum{i} sum{j} P[j]*X[i,j]); Write('g) %s\n', {j} Format('j=%d: %5.2f ',j, sum{i} A[i]*Y[i,j])); end
Problem Statement
Modeling Description
Back to model
The solution is as follows:
The LOG-File output of LPL is as follows: