Refactor the benchmarks

This commit is contained in:
tacgomes 2013-01-09 15:25:14 +00:00
parent 7fabfcf4c9
commit 7f452d2397
36 changed files with 125 additions and 152 deletions

View File

@ -1,5 +1,4 @@
function prepare_new_run
{
YAP=~/bin/$SHORTNAME-$SOLVER
@ -17,32 +16,33 @@ function prepare_new_run
function run_solver
{
constraint=$1
echo $LOG_FILE
CONSTRAINT=$1
solver_flag=true
if [ -n "$2" ]; then
if [ $SOLVER = hve ]; then
solver_flag=clpbn_horus:set_horus_flag\(elim_heuristic,$2\)
SOLVER_FLAG=set_horus_flag\(hve_elim_heuristic,$2\)
elif [ $SOLVER = bp ]; then
solver_flag=clpbn_horus:set_horus_flag\(schedule,$2\)
SOLVER_FLAG=set_horus_flag\(bp_msg_schedule,$2\)
elif [ $SOLVER = cbp ]; then
solver_flag=clpbn_horus:set_horus_flag\(schedule,$2\)
SOLVER_FLAG=set_horus_flag\(bp_msg_schedule,$2\)
elif [ $SOLVER = lbp ]; then
solver_flag=clpbn_horus:set_horus_flag\(schedule,$2\)
SOLVER_FLAG=set_horus_flag\(bp_msg_schedule,$2\)
else
echo "unknow flag $2"
fi
fi
/usr/bin/time -o $LOG_FILE -a -f "%U\t%S\t%e\t%M" \
$YAP << EOF >> $LOG_FILE &>> ignore.$LOG_FILE
$YAP << EOF >> ignore.$LOG_FILE 2>> ignore.$LOG_FILE
nogc.
[$NETWORK].
[$constraint].
clpbn_horus:set_solver($SOLVER).
clpbn_horus:set_horus_flag(use_logarithms, true).
clpbn_horus:set_horus_flag(verbosity, 1).
$solver_flag.
[$CONSTRAINT].
set_solver($SOLVER).
set_horus_flag(verbosity, 1).
set_horus_flag(use_logarithms, true).
$SOLVER_FLAG.
$QUERY.
open("$LOG_FILE", 'append', S), format(S, '$constraint ~15+ ', []), close(S).
open("$LOG_FILE", 'append', S), format(S, "$CONSTRAINT ~15+ ", []), close(S).
EOF
}
@ -52,12 +52,16 @@ function clear_log_files
{
rm -f *~
rm -f ../*~
rm -f school/*.log school/*~
rm -f ../school/*.log ../school/*~
rm -f city/*.log city/*~
rm -f ../city/*.log ../city/*~
rm -f workshop_attrs/*.log workshop_attrs/*~
rm -f ../workshop_attrs/*.log ../workshop_attrs/*~
rm -f comp_workshops/*.log comp_workshops/*~
rm -f ../comp_workshops/*.log ../comp_workshops/*~
rm -f city/*.log city/*~
rm -f ../city/*.log ../city/*~
rm -f social_network2/*.log social_network2/*~
rm -f ../social_network2/*.log ../social_network2/*~
rm -f social_network2_evidence/*.log social_network2_evidence/*~
rm -f ../social_network2_evidence/*.log ../social_network2_evidence/*~
echo all done!
}

View File

@ -33,5 +33,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "bp(shedule=seq_fixed) " seq_fixed
run_all_graphs "bp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -32,5 +32,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "cbp(shedule=seq_fixed) " seq_fixed
run_all_graphs "cbp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -1,6 +1,6 @@
#!/bin/bash
NETWORK="'../../examples/city'"
NETWORK="'../../examples/city.pfl'"
SHORTNAME="city"
QUERY="is_joe_guilty(X)"

View File

@ -19,7 +19,7 @@ main :-
generate_people(S, N, Counting) :-
Counting > N, !.
generate_people(S, N, Counting) :-
format(S, 'people(p~w, nyc).~n', [Counting]),
format(S, 'person(p~w, nyc).~n', [Counting]),
Counting1 is Counting + 1,
generate_people(S, N, Counting1).

View File

@ -33,5 +33,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "hve(elim_heuristic=min_neighbors) " min_neighbors
run_all_graphs "hve(hve_elim_heuristic=min_neighbors) " min_neighbors

View File

@ -32,5 +32,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "lbp(shedule=seq_fixed) " seq_fixed
run_all_graphs "lbp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -27,5 +27,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "bp(shedule=seq_fixed) " seq_fixed
run_all_graphs "bp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -26,5 +26,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "cbp(shedule=seq_fixed) " seq_fixed
run_all_graphs "cbp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -1,6 +1,6 @@
#!/bin/bash
NETWORK="'../../examples/comp_workshops'"
NETWORK="'../../examples/comp_workshops.pfl'"
SHORTNAME="cw"
QUERY="series(X)"

View File

@ -29,7 +29,7 @@ gen(S, NP, NW, Count) :-
gen_workshops(_, _, NW, Count) :-
Count > NW, !.
gen_workshops(S, P, NW, Count) :-
format(S, 'c(p~w,w~w).~n', [P,Count]),
format(S, 'reg(p~w,w~w).~n', [P,Count]),
Count1 is Count + 1,
gen_workshops(S, P, NW, Count1).

View File

@ -26,5 +26,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "hve(elim_heuristic=min_neighbors) " min_neighbors
run_all_graphs "hve(hve_elim_heuristic=min_neighbors) " min_neighbors

View File

@ -26,5 +26,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "lbp(shedule=seq_fixed) " seq_fixed
run_all_graphs "lbp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -24,7 +24,7 @@ source lbp_tests.sh
source cbp_tests.sh
cd ..
cd smokers
cd social_network2
source hve_tests.sh
source bp_tests.sh
source lve_tests.sh

View File

@ -1,95 +1,64 @@
#!/bin/bash
#cp ~/bin/yap ~/bin/school_all
#YAP=~/bin/school_all
YAP=~/bin/yap
source ../benchs.sh
#OUT_FILE_NAME=results`date "+ %H:%M:%S %d-%m-%Y"`.log
OUT_FILE_NAME=results.log
rm -f $OUT_FILE_NAME
rm -f ignore.$OUT_FILE_NAME
SHORTNAME="school"
SOLVER="school"
# yap -g "['../../../../examples/School/sch32'], [missing5], use_module(library(clpbn/learning/em)), graph(L), clpbn:set_clpbn_flag(em_solver,bp), clpbn_horus:set_horus_flag(inf_alg, bp), statistics(runtime, _), em(L,0.01,10,_,Lik), statistics(runtime, [T,_])."
function run_solver
function learn_params
{
if [ $2 = bp ]
then
if [ $4 = ve ]
then
extra_flag1=clpbn_horus:set_horus_flag\(inf_alg,$4\)
extra_flag2=clpbn_horus:set_horus_flag\(elim_heuristic,$5\)
else
extra_flag1=clpbn_horus:set_horus_flag\(inf_alg,$4\)
extra_flag2=clpbn_horus:set_horus_flag\(schedule,$5\)
fi
else
extra_flag1=true
extra_flag2=true
fi
/usr/bin/time -o "$OUT_FILE_NAME" -a -f "real:%E\tuser:%U\tsys:%S" $YAP << EOF &>> "ignore.$OUT_FILE_NAME"
:- [pos:train].
:- ['../../../../examples/School/sch32'].
:- use_module(library(clpbn/learning/em)).
:- use_module(library(clpbn/bp)).
[$1].
NETWORK="'./../../examples/School/school_32'"
CONSTRAINT=$2
SOLVER=$1
echo $NETWORK
/usr/bin/time -o $LOG_FILE -a -f "%U\t%S\t%e\t%M" \
$YAP << EOF >> ignore.$LOG_FILE 2>> ignore.$LOG_FILE
use_module(library(pfl)).
use_module(library(clpbn/learning/em)).
[$NETWORK].
[$CONSTRAINT].
set_em_solver($SOLVER).
graph(L),
clpbn:set_clpbn_flag(em_solver,$2),
$extra_flag1, $extra_flag2,
em(L,0.01,10,_,Lik),
open("$OUT_FILE_NAME", 'append',S),
format(S, '$3: ~11+ Lik = ~3f, ',[Lik]),
close(S).
% em(L, 0.01, 10, _, Lik),
open("$LOG_FILE", 'append', S),
format(S, "$CONSTRAINT: ~15+ Lik = ~3f\t", [Lik]),
close(S).
EOF
}
function run_all_graphs
{
echo "************************************************************************" >> "$OUT_FILE_NAME"
echo "results for solver $2" >> "$OUT_FILE_NAME"
echo "************************************************************************" >> "$OUT_FILE_NAME"
run_solver missing5 $1 missing5 $3 $4 $5
run_solver missing10 $1 missing10 $3 $4 $5
#run_solver missing20 $1 missing20 $3 $4 $5
#run_solver missing30 $1 missing30 $3 $4 $5
#run_solver missing40 $1 missing40 $3 $4 $5
#run_solver missing50 $1 missing50 $3 $4 $5
}
prepare_new_run
#run_all_graphs bp "hve(min_neighbors) " ve min_neighbors
#run_all_graphs bp "bp(seq_fixed) " bp seq_fixed
#run_all_graphs bp "cbp(seq_fixed) " cbp seq_fixed
exit
write_header hve
learn_params hve missing5
learn_params hve missing10
learn_params hve missing20
#learn_params hve missing30
#learn_params hve missing40
#learn_params hve missing50
write_header ve
learn_params ve missing5
learn_params ve missing10
learn_params ve missing20
#learn_params ve missing30
#learn_params ve missing40
#learn_params hve missing50
run_all_graphs bp "hve(min_neighbors) " ve min_neighbors
run_all_graphs bp "hve(min_weight) " ve min_weight
run_all_graphs bp "hve(min_fill) " ve min_fill
run_all_graphs bp "hve(w_min_fill) " ve weighted_min_fill
run_all_graphs bp "bp(seq_fixed) " bp seq_fixed
run_all_graphs bp "bp(max_residual) " bp max_residual
run_all_graphs bp "cbp(seq_fixed) " cbp seq_fixed
run_all_graphs bp "cbp(max_residual) " cbp max_residual
run_all_graphs gibbs "gibbs "
echo "************************************************************************" >> "$OUT_FILE_NAME"
echo "results for solver ve" >> "$OUT_FILE_NAME"
echo "************************************************************************" >> "$OUT_FILE_NAME"
run_solver missing5 ve missing5 $3 $4 $5
run_solver missing10 ve missing10 $3 $4 $5
run_solver missing20 ve missing20 $3 $4 $5
run_solver missing30 ve missing30 $3 $4 $5
run_solver missing40 ve missing40 $3 $4 $5
#run_solver missing50 ve missing50 $3 $4 $5 #+24h!
echo "************************************************************************" >> "$OUT_FILE_NAME"
echo "results for solver jt" >> "$OUT_FILE_NAME"
echo "************************************************************************" >> "$OUT_FILE_NAME"
run_solver missing5 jt missing5 $3 $4 $5
run_solver missing10 jt missing10 $3 $4 $5
run_solver missing20 jt missing20 $3 $4 $5
#run_solver missing30 jt missing30 $3 $4 $5 #+24h!
#run_solver missing40 jt missing40 $3 $4 $5 #+24h!
#run_solver missing50 jt missing50 $3 $4 $5 #+24h!
exit
write_header bp
learn_params bp missing5
learn_params bp missing10
learn_params bp missing20
#learn_params bp missing30
#learn_params bp missing40
#learn_params bp missing50
write_header cbp
learn_params cbp missing5
learn_params cbp missing10
learn_params cbp missing20
#learn_params cbp missing30
#learn_params cbp missing40
#learn_params cbp missing50

View File

@ -1,8 +0,0 @@
#!/bin/bash
NETWORK="'../../examples/social_domain2'"
SHORTNAME="sm"
QUERY="query(X)"
POP=500

View File

@ -1,6 +1,6 @@
#!/bin/bash
source sm.sh
source sn2.sh
source ../benchs.sh
SOLVER="bp"
@ -26,5 +26,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "bp(shedule=seq_fixed) " seq_fixed
run_all_graphs "bp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -1,6 +1,6 @@
#!/bin/bash
source sm.sh
source sn2.sh
source ../benchs.sh
SOLVER="cbp"
@ -26,5 +26,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "cbp(shedule=seq_fixed) " seq_fixed
run_all_graphs "cbp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -17,7 +17,7 @@ main :-
generate_people(S, N, Counting) :-
Counting > N, !.
generate_people(S, N, Counting) :-
format(S, 'people(p~w).~n', [Counting]),
format(S, 'person(p~w).~n', [Counting]),
Counting1 is Counting + 1,
generate_people(S, N, Counting1).

View File

@ -1,6 +1,6 @@
#!/bin/bash
source sm.sh
source sn2.sh
source ../benchs.sh
SOLVER="hve"
@ -26,8 +26,8 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "hve(elim_heuristic=min_neighbors) " min_neighbors
#run_all_graphs "hve(elim_heuristic=min_weight) " min_weight
#run_all_graphs "hve(elim_heuristic=min_fill) " min_fill
#run_all_graphs "hve(elim_heuristic=weighted_min_fill) " weighted_min_fill
run_all_graphs "hve(hve_elim_heuristic=min_neighbors) " min_neighbors
#run_all_graphs "hve(hve_elim_heuristic=min_weight) " min_weight
#run_all_graphs "hve(hve_elim_heuristic=min_fill) " min_fill
#run_all_graphs "hve(hve_elim_heuristic=weighted_min_fill) " weighted_min_fill

View File

@ -1,6 +1,6 @@
#!/bin/bash
source sm.sh
source sn2.sh
source ../benchs.sh
SOLVER="lbp"
@ -26,5 +26,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "lbp(shedule=seq_fixed) " seq_fixed
run_all_graphs "lbp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -1,6 +1,6 @@
#!/bin/bash
source sm.sh
source sn2.sh
source ../benchs.sh
SOLVER="lve"

View File

@ -1,7 +1,7 @@
#!/bin/bash
NETWORK="'../../examples/social_domain2'"
SHORTNAME="sm"
NETWORK="'../../examples/social_network2.pfl'"
SHORTNAME="sn2"
#QUERY="smokes(p1,t), smokes(p2,t), friends(p1,p2,X)"
QUERY="friends(p1,p2,X)"

View File

@ -1,6 +1,6 @@
#!/bin/bash
source sm.sh
source sn2ev.sh
source ../benchs.sh
SOLVER="bp"
@ -30,5 +30,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "bp(shedule=seq_fixed) " seq_fixed
run_all_graphs "bp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -1,6 +1,6 @@
#!/bin/bash
source sm.sh
source sn2ev.sh
source ../benchs.sh
SOLVER="cbp"
@ -30,5 +30,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "cbp(shedule=seq_fixed) " seq_fixed
run_all_graphs "cbp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -26,7 +26,7 @@ main :-
generate_people(S, N, Counting) :-
Counting > N, !.
generate_people(S, N, Counting) :-
format(S, 'people(p~w).~n', [Counting]),
format(S, 'person(p~w).~n', [Counting]),
Counting1 is Counting + 1,
generate_people(S, N, Counting1).

View File

@ -1,6 +1,6 @@
#!/bin/bash
source sm.sh
source sn2ev.sh
source ../benchs.sh
SOLVER="hve"
@ -30,8 +30,8 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "hve(elim_heuristic=min_neighbors) " min_neighbors
#run_all_graphs "hve(elim_heuristic=min_weight) " min_weight
#run_all_graphs "hve(elim_heuristic=min_fill) " min_fill
#run_all_graphs "hve(elim_heuristic=weighted_min_fill) " weighted_min_fill
run_all_graphs "hve(hve_elim_heuristic=min_neighbors) " min_neighbors
#run_all_graphs "hve(hve_elim_heuristic=min_weight) " min_weight
#run_all_graphs "hve(hve_elim_heuristic=min_fill) " min_fill
#run_all_graphs "hve(hve_elim_heuristic=weighted_min_fill) " weighted_min_fill

View File

@ -1,6 +1,6 @@
#!/bin/bash
source sm.sh
source sn2ev.sh
source ../benchs.sh
SOLVER="lve"

View File

@ -0,0 +1,8 @@
#!/bin/bash
NETWORK="'../../examples/social_network2.pfl'"
SHORTNAME="sn2ev"
QUERY="query(X)"
POP=500

View File

@ -33,5 +33,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "bp(shedule=seq_fixed) " seq_fixed
run_all_graphs "bp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -32,5 +32,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "cbp(shedule=seq_fixed) " seq_fixed
run_all_graphs "cbp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -23,7 +23,7 @@ main :-
generate_people(S, N, Counting) :-
Counting > N, !.
generate_people(S, N, Counting) :-
format(S, 'people(p~w).~n', [Counting]),
format(S, 'person(p~w).~n', [Counting]),
Counting1 is Counting + 1,
generate_people(S, N, Counting1).
@ -31,9 +31,9 @@ generate_people(S, N, Counting) :-
generate_attrs(S, N, Counting) :-
Counting > N, !.
generate_attrs(S, N, Counting) :-
%format(S, 'people(p~w).~n', [Counting]),
%format(S, 'person(p~w).~n', [Counting]),
format(S, 'markov attends(P)::[t,f], attr~w::[t,f]', [Counting]),
format(S, '; [0.7, 0.3, 0.3, 0.3] ; [people(P)].~n',[]),
format(S, '; [0.7, 0.3, 0.3, 0.3] ; [person(P)].~n',[]),
Counting1 is Counting + 1,
generate_attrs(S, N, Counting1).

View File

@ -32,5 +32,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "hve(elim_heuristic=min_neighbors) " min_neighbors
run_all_graphs "hve(hve_elim_heuristic=min_neighbors) " min_neighbors

View File

@ -32,5 +32,5 @@ function run_all_graphs
}
prepare_new_run
run_all_graphs "lbp(shedule=seq_fixed) " seq_fixed
run_all_graphs "lbp(bp_msg_shedule=seq_fixed) " seq_fixed

View File

@ -1,6 +1,6 @@
#!/bin/bash
NETWORK="'../../examples/workshop_attrs'"
NETWORK="'../../examples/workshop_attrs.pfl'"
SHORTNAME="wa"
QUERY="series(X)"