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

View File

@ -33,5 +33,5 @@ function run_all_graphs
} }
prepare_new_run 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 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 #!/bin/bash
NETWORK="'../../examples/city'" NETWORK="'../../examples/city.pfl'"
SHORTNAME="city" SHORTNAME="city"
QUERY="is_joe_guilty(X)" QUERY="is_joe_guilty(X)"

View File

@ -19,7 +19,7 @@ main :-
generate_people(S, N, Counting) :- generate_people(S, N, Counting) :-
Counting > N, !. Counting > N, !.
generate_people(S, N, Counting) :- 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, Counting1 is Counting + 1,
generate_people(S, N, Counting1). generate_people(S, N, Counting1).

View File

@ -33,5 +33,5 @@ function run_all_graphs
} }
prepare_new_run 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 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 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 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 #!/bin/bash
NETWORK="'../../examples/comp_workshops'" NETWORK="'../../examples/comp_workshops.pfl'"
SHORTNAME="cw" SHORTNAME="cw"
QUERY="series(X)" QUERY="series(X)"

View File

@ -29,7 +29,7 @@ gen(S, NP, NW, Count) :-
gen_workshops(_, _, NW, Count) :- gen_workshops(_, _, NW, Count) :-
Count > NW, !. Count > NW, !.
gen_workshops(S, P, NW, Count) :- 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, Count1 is Count + 1,
gen_workshops(S, P, NW, Count1). gen_workshops(S, P, NW, Count1).

View File

@ -26,5 +26,5 @@ function run_all_graphs
} }
prepare_new_run 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 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 source cbp_tests.sh
cd .. cd ..
cd smokers cd social_network2
source hve_tests.sh source hve_tests.sh
source bp_tests.sh source bp_tests.sh
source lve_tests.sh source lve_tests.sh

View File

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

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 #!/bin/bash
source sm.sh source sn2.sh
source ../benchs.sh source ../benchs.sh
SOLVER="bp" SOLVER="bp"
@ -26,5 +26,5 @@ function run_all_graphs
} }
prepare_new_run 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 #!/bin/bash
source sm.sh source sn2.sh
source ../benchs.sh source ../benchs.sh
SOLVER="cbp" SOLVER="cbp"
@ -26,5 +26,5 @@ function run_all_graphs
} }
prepare_new_run 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) :- generate_people(S, N, Counting) :-
Counting > N, !. Counting > N, !.
generate_people(S, N, Counting) :- generate_people(S, N, Counting) :-
format(S, 'people(p~w).~n', [Counting]), format(S, 'person(p~w).~n', [Counting]),
Counting1 is Counting + 1, Counting1 is Counting + 1,
generate_people(S, N, Counting1). generate_people(S, N, Counting1).

View File

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

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
source sm.sh source sn2.sh
source ../benchs.sh source ../benchs.sh
SOLVER="lbp" SOLVER="lbp"
@ -26,5 +26,5 @@ function run_all_graphs
} }
prepare_new_run 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 #!/bin/bash
source sm.sh source sn2.sh
source ../benchs.sh source ../benchs.sh
SOLVER="lve" SOLVER="lve"

View File

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

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
source sm.sh source sn2ev.sh
source ../benchs.sh source ../benchs.sh
SOLVER="bp" SOLVER="bp"
@ -30,5 +30,5 @@ function run_all_graphs
} }
prepare_new_run 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 #!/bin/bash
source sm.sh source sn2ev.sh
source ../benchs.sh source ../benchs.sh
SOLVER="cbp" SOLVER="cbp"
@ -30,5 +30,5 @@ function run_all_graphs
} }
prepare_new_run 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) :- generate_people(S, N, Counting) :-
Counting > N, !. Counting > N, !.
generate_people(S, N, Counting) :- generate_people(S, N, Counting) :-
format(S, 'people(p~w).~n', [Counting]), format(S, 'person(p~w).~n', [Counting]),
Counting1 is Counting + 1, Counting1 is Counting + 1,
generate_people(S, N, Counting1). generate_people(S, N, Counting1).

View File

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

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
source sm.sh source sn2ev.sh
source ../benchs.sh source ../benchs.sh
SOLVER="lve" 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 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 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) :- generate_people(S, N, Counting) :-
Counting > N, !. Counting > N, !.
generate_people(S, N, Counting) :- generate_people(S, N, Counting) :-
format(S, 'people(p~w).~n', [Counting]), format(S, 'person(p~w).~n', [Counting]),
Counting1 is Counting + 1, Counting1 is Counting + 1,
generate_people(S, N, Counting1). generate_people(S, N, Counting1).
@ -31,9 +31,9 @@ generate_people(S, N, Counting) :-
generate_attrs(S, N, Counting) :- generate_attrs(S, N, Counting) :-
Counting > N, !. Counting > N, !.
generate_attrs(S, N, Counting) :- 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, '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, Counting1 is Counting + 1,
generate_attrs(S, N, Counting1). generate_attrs(S, N, Counting1).

View File

@ -32,5 +32,5 @@ function run_all_graphs
} }
prepare_new_run 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 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 #!/bin/bash
NETWORK="'../../examples/workshop_attrs'" NETWORK="'../../examples/workshop_attrs.pfl'"
SHORTNAME="wa" SHORTNAME="wa"
QUERY="series(X)" QUERY="series(X)"