HPO機密日誌

自己をならふといふは、自己をわするるなり。

Concentration Program

例によってActiveBasic4.0。エクセルでやったときのような集中化がいまいち再現できない。なぜ?

をっと、やっぱり初期条件の与え方が問題だったんだ!最初から一様分布じゃだめなのかな?真ん中のセル4つ「3」、周辺が「.1」、従前のセルが「.8」という条件でやってみた。

なんとなく、「正規化」した清水さんの都内の地価図に近いものが作れそうな気がしてきた。<<プログラム>>
' concetration model development sim program
' started 2005/04/08
' by Hideki Hirayama

'#prompt
#console


'初期設定

dim table_original[21,21] as single
dim table_temp[21,21] as single
dim retina_model[3,3] as single
dim i,j,k,l,dummy as integer
dim x,y,z as single

'table_original:一様乱数初期化サブルーチン

sub randam_table()

Randomize()

for i=0 to 21
for j=0 to 21
if i=0 or j=0 then
table_original[i,j] = 0
else
table_original[i,j] = (Rnd()*1)
endif
next
next

endsub

'table_original:特定の値による初期化サブルーチン(メインで選択)

sub specified_table()

for i=0 to 21
for j=0 to 21
if i>10 and i<13 and j>10 and j<13 then
table_original[i,j] = 3
else
table_original[i,j] = 0
endif
next
next

endsub

' フィルター部分の定義:正規格子を過程(タテ、ヨコ)

sub fil_initial()
for i=1 to 3
for j=1 to 3
retina_model[i,j]=.1
next
next

retina_model[2,2]=.75

retina_model[1,1]=0
retina_model[1,3]=0
retina_model[3,1]=0
retina_model[3,3]=0
endsub

'table_original:表示サブルーチン

Sub p_table()

'cls

for i=1 to 20
for j=1 to 20
x = CInt(table_original[i,j])
Locate i*3+5,j+5
print x;
next
next

endsub

'table_original:時間を進める、フィルターを一度かける

sub dev_table()

for i=1 to 20
for j=1 to 20

table_temp[i,j]=table_original[i-1,j-1]*retina_model[1,1]
table_temp[i,j]=table_temp[i,j]+table_original[i-1,j]*retina_model[1,2]
table_temp[i,j]=table_temp[i,j]+table_original[i-1,j+1]*retina_model[1,3]
table_temp[i,j]=table_temp[i,j]+table_original[i,j-1]*retina_model[2,1]
table_temp[i,j]=table_temp[i,j]+table_original[i,j]*retina_model[2,2]
table_temp[i,j]=table_temp[i,j]+table_original[i,j+1]*retina_model[2,3]
table_temp[i,j]=table_temp[i,j]+table_original[i+1,j-1]*retina_model[3,1]
table_temp[i,j]=table_temp[i,j]+table_original[i+1,j]*retina_model[3,2]
table_temp[i,j]=table_temp[i,j]+table_original[i+1,j+1]*retina_model[3,3]

next
next

for i=1 to 20
for j=1 to 20
if table_temp[i,j]>0 then
table_original[i,j]=table_temp[i,j]
else
table_original[i,j]=0
endif
next
next

endsub

'メイン
' 初期化はどちらか選択

'randam_table()
specified_table()

fil_initial()
p_table()

print
print

input "times";k

for l=1 to k
dev_table()
p_table()
print
print
print "loop=";l;" "
Sleep(1000)
next

input dummy

end