18.2.プログラム:Quantitative System Performance

18.1.導入」の続きです。(目次はこちら

18.2.プログラム


 プログラムは以下の2ページに現れる。2つのステートメント・ラベル(2001と2003)は第20章での参照のために含まれており、プログラムでは使用されない。
 若干のFortran実装はフォーマットされたI/Oについて制約を課すことに注意しよう。プログラムを使用する時は実数の入力に(整数値の入力ではなくて)明示的な小数点を含ませることが最善である。

 program single
c
c 最大25センターまで可能
c
 integer Ncusts,Ncents,n,center
 real demand(25)
 real qlen(25)
 real rtime(25)
 real tput,sysr
c
 write (6,5)
5 format (27h Input number of customers:)
 read (5,10) Ncusts
10 format (i4)
 write (6,15)
15 format (25h Input numer of centers:)
 read (5,10) Ncents
 write (6,20)
20 format (25h Input service demand for)
 do 25 center=1,Ncents
  write (6,30) center
30  format (10h Center ,i2,1h:)
  read (5,35) demand(center)
35  format (f8.4)
25  continue
c
c ここでネットワークが記述されたので、評価を実行する。
c ゼロ・センターの自明な解に初期化することから始める。
c
 do 40 center=1,Ncents
  qlen(center) = 0.0
40  continue
c
c アルゴリズムは個々の個体数について引き続いて解を求める。
 do 45 n=1,Ncusts
c
c 最初に、個々のセンターでの滞在時間を計算する。
  sysr = 0.0
  do 50 center=1,Ncents
2001   rtime(center) = demand(center)*(1.0+qlen(center))
   sysr = sysr + rtime(center)
50   continue
c
c 次に、リトルの法則を使ってシステム・スループットを計算する。
c
  tput = n / sysr
c
c 最後に、リトルの法則を使ってセンターの待ち行列長を計算する。
c
  do 55 center=1,Ncents
2003   qlen(center) = rtime(center) * tput
55   continue
c
45  contiue
c
c 結果をプリントする
c
 write (6,60) tput
60 format (20h System throughput: ,f8.4)
 write (6,65) Ncusts/tput
65 format (23h System response time: ,f8.4)
c
 write (6,70)
70 format (22h Device utilizations: )
 do 75 center=1,Ncents
  write (6,80) center,tput*demand(center)
80  format (i5,2h: ,f5.3)
75  continue
c
 write (6,85)
85 format (23h Device queue lengths: )
 do 90 center=1,Ncents
  write (6,95) center,qlen(center)
95  format (i5,2h: ,f8.4)
90  continue
c
 end


第19章 複数クラス、厳密MVAの実装」に続きます。