Download Mosel User Guide - Personal Homepages
Transcript
psum,prsum,ct,iflow: integer
end-declarations
! Counters
! Print heading and the first line of the table
writeln("\nProduct Distribution\n--------------------")
writeln(strfmt("Sales Region",44))
write(strfmt("",14))
forall(r in REGION) write(strfmt(r,9))
writeln(strfmt("TOTAL",9), " Capacity")
! Print the solution values of the flow variables and
! calculate totals per region and per plant
ct:=0
forall(p in PLANT) do
ct += 1
if ct=2 then
write("Plant ",strfmt(p,-8))
else
write("
",strfmt(p,-8))
end-if
psum:=0
forall(r in REGION) do
iflow:=integer(getsol(flow(p,r)))
psum += iflow
rsum(r) += iflow
if iflow<>0 then
write(strfmt(iflow,9))
else
write("
")
end-if
end-do
writeln(strfmt(psum,9), strfmt(integer(PLANTCAP(p)),9))
end-do
! Print the column totals
write("\n", strfmt("TOTAL",-14))
prsum:=0
forall(r in REGION) do
prsum += rsum(r);
write(strfmt(rsum(r),9))
end-do
writeln(strfmt(prsum,9))
! Print demand of every region
write(strfmt("Demand",-14))
forall(r in REGION) write(strfmt(integer(DEMAND(r)),9))
! Print objective function value
writeln("\n\nTotal cost of distribution = ", strfmt(getobjval/1e6,0,3),
" million.")
end-procedure
With the data from Chapter 3 the procedure print_table produces the following output:
Product Distribution
-------------------Scotland
Corby
Plant Deeside
Glasgow
Oxford
TOTAL
Demand
2840
2840
2840
Sales Region
SWest
SEast Midlands
180
820
2000
1530
920
250
1270
1500
2000
500
North
2800
2800
2600
2600
2820
2820
2750
2750
TOTAL Capacity
3000
3000
2700
2700
4110
4500
4000
4000
13810
Total cost of distribution = 81.018 million.
Output
65
Mosel User Guide