Commit 395bbdc6 authored by Vladislav Perepelkin's avatar Vladislav Perepelkin
Browse files

added series scripts

parent 6e7c727a
#!/bin/sh
export WIDTH=500
export HEIGHT=600
export ITERS=101
export INIT1=0.7 INIT2=0.7 INIT4=0.7 INIT8=0.7
export INIT16=0.25 INIT32=0 INIT64=0 INIT128=0
export SOURCE_WIDTH=20
export SRC1=1 SRC2=1 SRC4=1 SRC8=1
export SRC16=0.75 SRC32=0 SRC64=0 SRC128=0
export SAVE_PERIOD=50
export AVERAGING_RADIUS=1
export ENSEMBLE_SIZE=2
export PROB_MAIN="0.1"
export PROB_SEC="0.1" ; system/conduct.sh
export PROB_SEC="0.2" ; system/conduct.sh
export PROB_SEC="0.3" ; system/conduct.sh
export PROB_SEC="0.4" ; system/conduct.sh
export PROB_SEC="0.5" ; system/conduct.sh
export PROB_SEC="0.6" ; system/conduct.sh
export PROB_SEC="0.7" ; system/conduct.sh
export PROB_SEC="0.8" ; system/conduct.sh
export PROB_MAIN="0.5"
export PROB_SEC="0.1" ; system/conduct.sh
export PROB_SEC="0.2" ; system/conduct.sh
export PROB_SEC="0.3" ; system/conduct.sh
export PROB_SEC="0.4" ; system/conduct.sh
export PROB_MAIN="0.9"
export PROB_SEC="0.05" ; system/conduct.sh
sh system/curves_gen.sh exp
......@@ -16,4 +16,4 @@ for f in sys.argv[1:]:
val=float(val)
if top is None or val>top:
top=val
print top,
print top
#!/bin/sh
# conducts whole experiment putting density max-curve to stdout
# all experiment settings must be in environment variables (see errors
# for details)
# Rules: 5<->5 and 10<->16 with prob in PROB_MAIN
# TODO: check env args
# environment variables:
# PROB_MAIN
make purge
python system/gen_rules.py \
5-5=$PROB_MAIN 10-16=$PROB_MAIN 16-10=$PROB_MAIN \
5-10=$PROB_SEC 10-5=$PROB_SEC 16-5=$PROB_SEC \
> rules.txt || exit 1
python system/gen_config_flatwave.py > config.c || exit 1
echo "EXPERIMENT: PROB_MAIN=$PROB_MAIN PROB_SEC=$PROB_SEC"
make run
cwd=$PWD
mkdir exp
cd density
python ../system/build_max.py *.xls > $cwd/exp/exp_${PROB_MAIN}_${PROB_SEC}.xls
#!/bin/sh
zmin=3.2
zmax=5.1
tmp_script=`tempfile`
echo 'set term png
set yrange['$zmin':'$zmax']
set output '\"$1/curves.png\"'
set grid ytics lw 1 lt 0
set grid xtics lw 1 lt 0
unset key' > $tmp_script
first=true
for x in `ls $1/*.xls`; do
$first && echo "plot '$x' with lines lw 4\\" >> $tmp_script
$first || echo ", '$x' with lines lw 4\\" >> $tmp_script
first=false
done
gnuplot $tmp_script 2>/dev/null
rm $tmp_script
......@@ -112,7 +112,7 @@ for s0 in range(256):
if len(rules[s0])>0:
sum_prob=reduce(lambda x, y: x+y,
[rules[s0][s1] for s1 in rules[s0]])
if sum_prob!=1:
if abs(sum_prob-1)>0.0000001:
error("Normalization fails for state (" + str(s0) +\
"), sum prob is " + str(sum_prob))
......
......@@ -9,7 +9,7 @@ failed=False
for key in KEYS:
if key not in os.environ:
failed=True
print "ERROR: undefined environment variable:", key
sys.stderr.write("ERROR: undefined environment variable:" + str(key) + '\n')
assert not failed
......
......@@ -33,14 +33,18 @@ for rule in sys.argv[1:]:
s1, s2=map(int, pair.split('-'))
if s1 not in matrix:
matrix[s1]=dict()
matrix[s1][s2]=float(prob)
try:
matrix[s1][s2]=float(prob)
except ValueError:
raise Exception('Illegal rule format', rule)
assert 0<=float(prob)<=1
for cls in CLASSES:
for s1 in cls:
if s1 not in matrix:
matrix[s1]=dict()
matrix[s1][s1]=1
for s in cls[:-1]:
matrix[s1][s]=1.0/len(cls)
sum=0
for s2 in cls:
if s2 in matrix[s1]:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment