improvements on benchmarkings
This commit is contained in:
parent
03013960d3
commit
564958ef8d
@ -71,7 +71,13 @@ CFactorGraph::setInitialColors (void)
|
||||
}
|
||||
|
||||
const FacNodes& facNodes = groundFg_->facNodes();
|
||||
if (checkForIdenticalFactors) {
|
||||
for (unsigned i = 0; i < facNodes.size(); i++) {
|
||||
facNodes[i]->factor().setDistId (Util::maxUnsigned());
|
||||
}
|
||||
Util::printHeader ("Before check for identical factors");
|
||||
groundFg_->print();
|
||||
// FIXME FIXME FIXME : pfl should give correct dist ids.
|
||||
if (checkForIdenticalFactors || false) {
|
||||
unsigned groupCount = 1;
|
||||
for (unsigned i = 0; i < facNodes.size(); i++) {
|
||||
Factor& f1 = facNodes[i]->factor();
|
||||
@ -93,6 +99,8 @@ CFactorGraph::setInitialColors (void)
|
||||
groupCount ++;
|
||||
}
|
||||
}
|
||||
Util::printHeader ("After check for identical factors");
|
||||
groundFg_->print();
|
||||
// create the initial factor colors
|
||||
DistColorMap distColors;
|
||||
for (unsigned i = 0; i < facNodes.size(); i++) {
|
||||
@ -163,7 +171,7 @@ CFactorGraph::createGroups (void)
|
||||
groupsHaveChanged = prevVarGroupsSize != varGroups.size()
|
||||
|| prevFactorGroupsSize != facGroups.size();
|
||||
}
|
||||
//printGroups (varGroups, facGroups);
|
||||
printGroups (varGroups, facGroups);
|
||||
createClusters (varGroups, facGroups);
|
||||
}
|
||||
|
||||
@ -263,7 +271,6 @@ CFactorGraph::getGroundFactorGraph (void) const
|
||||
fg->addEdge (static_cast<VarNode*> (myGroundVars[j]), fn);
|
||||
}
|
||||
}
|
||||
fg->print();
|
||||
return fg;
|
||||
}
|
||||
|
||||
|
@ -237,8 +237,8 @@ class CFactorGraph
|
||||
vector<Color> facColors_;
|
||||
vector<Signature> varSignatures_;
|
||||
vector<Signature> facSignatures_;
|
||||
VarClusters varClusters_;
|
||||
FacClusters facClusters_;
|
||||
VarClusters varClusters_;
|
||||
FacClusters facClusters_;
|
||||
VarId2VarCluster vid2VarCluster_;
|
||||
const FactorGraph* groundFg_;
|
||||
};
|
||||
|
@ -24,10 +24,10 @@ CbpSolver::CbpSolver (const FactorGraph& fg) : BpSolver (fg)
|
||||
Statistics::updateCompressingStatistics (nGroundVars,
|
||||
nGroundFacs, nClusterVars, nClusterFacs, nWithoutNeighs);
|
||||
}
|
||||
// Util::printHeader ("Uncompressed Factor Graph");
|
||||
// fg->print();
|
||||
// Util::printHeader ("Compressed Factor Graph");
|
||||
// fg_->print();
|
||||
Util::printHeader ("Uncompressed Factor Graph");
|
||||
fg.print();
|
||||
Util::printHeader ("Compressed Factor Graph");
|
||||
fg_->print();
|
||||
}
|
||||
|
||||
|
||||
|
@ -243,7 +243,7 @@ Factor::print (void) const
|
||||
}
|
||||
vector<string> jointStrings = Util::getStateLines (vars);
|
||||
for (unsigned i = 0; i < params_.size(); i++) {
|
||||
cout << "f(" << jointStrings[i] << ")" ;
|
||||
cout << "[" << distId_ << "] f(" << jointStrings[i] << ")" ;
|
||||
cout << " = " << params_[i] << endl;
|
||||
}
|
||||
cout << endl;
|
||||
|
28
packages/CLPBN/clpbn/bp/benchmarks/benchs.sh
Normal file
28
packages/CLPBN/clpbn/bp/benchmarks/benchs.sh
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
function run_solver
|
||||
{
|
||||
constraint=$1
|
||||
solver_flag=true
|
||||
if [ -n "$2" ]; then
|
||||
if [ $SOLVER = hve ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(elim_heuristic,$2\)
|
||||
elif [ $SOLVER = bp ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(schedule,$2\)
|
||||
elif [ $SOLVER = cbp ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(schedule,$2\)
|
||||
else
|
||||
echo "unknow flag $2"
|
||||
fi
|
||||
fi
|
||||
/usr/bin/time -o $LOG_FILE -a -f "real:%E\tuser:%U\tsys:%S" \
|
||||
$YAP << EOF >> $LOG_FILE 2>> ignore.$LOG_FILE
|
||||
[$NETWORK].
|
||||
[$constraint].
|
||||
clpbn_horus:set_solver($SOLVER).
|
||||
%clpbn_horus:set_horus_flag(use_logarithms, true).
|
||||
$solver_flag.
|
||||
$QUERY.
|
||||
open("$LOG_FILE", 'append', S), format(S, '$constraint: ~15+ ', []), close(S).
|
||||
EOF
|
||||
}
|
||||
|
@ -1,61 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
cp ~/bin/yap ~/bin/city_bp
|
||||
YAP=~/bin/city_bp
|
||||
source city.sh
|
||||
source ../benchs.sh
|
||||
|
||||
LOG_FILE=bp.log
|
||||
#LOG_FILE=results`date "+ %H:%M:%S %d-%m-%Y"`.log
|
||||
SOLVER="bp"
|
||||
|
||||
CITY_LOCATION="'../../examples/city'"
|
||||
YAP=~/bin/$SHORTNAME-$SOLVER
|
||||
|
||||
LOG_FILE=$SOLVER.log
|
||||
#LOG_FILE=results`date "+ %H:%M:%S %d-%m-%Y"`.
|
||||
|
||||
rm -f $LOG_FILE
|
||||
rm -f ignore.$LOG_FILE
|
||||
|
||||
|
||||
function run_solver
|
||||
{
|
||||
solver=$1
|
||||
network=$2
|
||||
solver_flag=true
|
||||
if [ -n "$3" ]; then
|
||||
if [ $solver = hve ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(elim_heuristic,$3\)
|
||||
elif [ $solver = bp ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(schedule,$3\)
|
||||
elif [ $solver = cbp ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(schedule,$3\)
|
||||
else
|
||||
echo "unknow flag $3"
|
||||
fi
|
||||
fi
|
||||
/usr/bin/time -o $LOG_FILE -a -f "real:%E\tuser:%U\tsys:%S" \
|
||||
$YAP << EOF >> $LOG_FILE 2>> ignore.$LOG_FILE
|
||||
[$CITY_LOCATION].
|
||||
[$network].
|
||||
clpbn_horus:set_solver($solver).
|
||||
clpbn_horus:set_horus_flag(use_logarithms, true).
|
||||
$solver_flag.
|
||||
is_joe_guilty(X).
|
||||
open("$LOG_FILE", 'append', S), format(S, '$network: ~15+ ', []), close(S).
|
||||
EOF
|
||||
}
|
||||
|
||||
function run_all_graphs
|
||||
{
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
echo "results for solver $2" >> $LOG_FILE
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
run_solver $1 city_5 $3
|
||||
#run_solver $1 city_1000 $3
|
||||
#run_solver $1 city_5000 $3
|
||||
#run_solver $1 city_10000 $3
|
||||
#run_solver $1 city_50000 $3
|
||||
#run_solver $1 city_100000 $3
|
||||
#run_solver $1 city_500000 $3
|
||||
#run_solver $1 city_1000000 $3
|
||||
}
|
||||
|
||||
run_all_graphs bp "bp(shedule=seq_fixed) " seq_fixed
|
||||
run_all_graphs "bp(shedule=seq_fixed) " seq_fixed
|
||||
|
||||
|
@ -1,62 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
cp ~/bin/yap ~/bin/city_cbp
|
||||
YAP=~/bin/city_cbp
|
||||
source city.sh
|
||||
source ../benchs.sh
|
||||
|
||||
LOG_FILE=cbp.log
|
||||
#LOG_FILE=results`date "+ %H:%M:%S %d-%m-%Y"`.log
|
||||
SOLVER="cbp"
|
||||
|
||||
CITY_LOCATION="'../../examples/city'"
|
||||
YAP=~/bin/$SHORTNAME-$SOLVER
|
||||
|
||||
LOG_FILE=$SOLVER.log
|
||||
#LOG_FILE=results`date "+ %H:%M:%S %d-%m-%Y"`.
|
||||
|
||||
rm -f $LOG_FILE
|
||||
rm -f ignore.$LOG_FILE
|
||||
|
||||
|
||||
function run_solver
|
||||
{
|
||||
solver=$1
|
||||
network=$2
|
||||
solver_flag=true
|
||||
if [ -n "$3" ]; then
|
||||
if [ $solver = hve ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(elim_heuristic,$3\)
|
||||
elif [ $solver = bp ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(schedule,$3\)
|
||||
elif [ $solver = cbp ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(schedule,$3\)
|
||||
else
|
||||
echo "unknow flag $3"
|
||||
fi
|
||||
fi
|
||||
/usr/bin/time -o $LOG_FILE -a -f "real:%E\tuser:%U\tsys:%S" \
|
||||
$YAP << EOF >> $LOG_FILE 2>> ignore.$LOG_FILE
|
||||
[$CITY_LOCATION].
|
||||
[$network].
|
||||
clpbn_horus:set_solver($solver).
|
||||
clpbn_horus:set_horus_flag(use_logarithms, true).
|
||||
$solver_flag.
|
||||
is_joe_guilty(X).
|
||||
open("$LOG_FILE", 'append', S), format(S, '$network: ~15+ ', []), close(S).
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
function run_all_graphs
|
||||
{
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
echo "results for solver $2" >> $LOG_FILE
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
run_solver $1 city_5 $3
|
||||
#run_solver $1 city_1000 $3
|
||||
#run_solver $1 city_5000 $3
|
||||
#run_solver $1 city_10000 $3
|
||||
#run_solver $1 city_50000 $3
|
||||
#run_solver $1 city_100000 $3
|
||||
#run_solver $1 city_500000 $3
|
||||
#run_solver $1 city_1000000 $3
|
||||
}
|
||||
|
||||
run_all_graphs cbp "cbp(shedule=seq_fixed) " seq_fixed
|
||||
run_all_graphs "cbp(shedule=seq_fixed) " seq_fixed
|
||||
|
||||
|
25
packages/CLPBN/clpbn/bp/benchmarks/city/city.sh
Executable file
25
packages/CLPBN/clpbn/bp/benchmarks/city/city.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
NETWORK="'../../examples/city'"
|
||||
SHORTNAME="city"
|
||||
QUERY="is_joe_guilty(X)"
|
||||
|
||||
|
||||
function run_all_graphs
|
||||
{
|
||||
cp ~/bin/yap $YAP
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
echo "results for solver $1" >> $LOG_FILE
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
run_solver city_5 $2
|
||||
#run_solver city_1000 $2
|
||||
#run_solver city_5000 $2
|
||||
#run_solver city_10000 $2
|
||||
#run_solver city_50000 $2
|
||||
#run_solver city_100000 $2
|
||||
#run_solver city_500000 $2
|
||||
#run_solver city_1000000 $2
|
||||
}
|
||||
|
@ -1,62 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
cp ~/bin/yap ~/bin/city_fove
|
||||
YAP=~/bin/city_fove
|
||||
source city.sh
|
||||
source ../benchs.sh
|
||||
|
||||
LOG_FILE=fove.log
|
||||
#LOG_FILE=results`date "+ %H:%M:%S %d-%m-%Y"`.log
|
||||
SOLVER="fove"
|
||||
|
||||
CITY_LOCATION="'../../examples/city'"
|
||||
YAP=~/bin/$SHORTNAME-$SOLVER
|
||||
|
||||
LOG_FILE=$SOLVER.log
|
||||
#LOG_FILE=results`date "+ %H:%M:%S %d-%m-%Y"`.
|
||||
|
||||
rm -f $LOG_FILE
|
||||
rm -f ignore.$LOG_FILE
|
||||
rm -f ignore.$LOG_FILEE
|
||||
|
||||
|
||||
function run_solver
|
||||
{
|
||||
solver=$1
|
||||
network=$2
|
||||
solver_flag=true
|
||||
if [ -n "$3" ]; then
|
||||
if [ $solver = hve ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(elim_heuristic,$3\)
|
||||
elif [ $solver = bp ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(schedule,$3\)
|
||||
elif [ $solver = cbp ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(schedule,$3\)
|
||||
else
|
||||
echo "unknow flag $3"
|
||||
fi
|
||||
fi
|
||||
/usr/bin/time -o $LOG_FILE -a -f "real:%E\tuser:%U\tsys:%S" \
|
||||
$YAP << EOF >> $LOG_FILE 2>> ignore.$LOG_FILE
|
||||
[$CITY_LOCATION].
|
||||
[$network].
|
||||
clpbn_horus:set_solver($solver).
|
||||
clpbn_horus:set_horus_flag(use_logarithms, true).
|
||||
$solver_flag.
|
||||
is_joe_guilty(X).
|
||||
open("$LOG_FILE", 'append', S), format(S, '$network: ~15+ ', []), close(S).
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
function run_all_graphs
|
||||
{
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
echo "results for solver $2" >> $LOG_FILE
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
run_solver $1 city_5 $3
|
||||
#run_solver $1 city_1000 $3
|
||||
#run_solver $1 city_5000 $3
|
||||
#run_solver $1 city_10000 $3
|
||||
#run_solver $1 city_50000 $3
|
||||
#run_solver $1 city_100000 $3
|
||||
#run_solver $1 city_500000 $3
|
||||
#run_solver $1 city_1000000 $3
|
||||
}
|
||||
|
||||
run_all_graphs fove "fove "
|
||||
run_all_graphs "fove "
|
||||
|
||||
|
@ -1,62 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
cp ~/bin/yap ~/bin/city_hve
|
||||
YAP=~/bin/city_hve
|
||||
source city.sh
|
||||
source ../benchs.sh
|
||||
|
||||
LOG_FILE=hve.log
|
||||
#LOG_FILE=results`date "+ %H:%M:%S %d-%m-%Y"`.log
|
||||
SOLVER="hve"
|
||||
|
||||
CITY_LOCATION="'../../examples/city'"
|
||||
YAP=~/bin/$SHORTNAME-$SOLVER
|
||||
|
||||
LOG_FILE=$SOLVER.log
|
||||
#LOG_FILE=results`date "+ %H:%M:%S %d-%m-%Y"`.
|
||||
|
||||
rm -f $LOG_FILE
|
||||
rm -f ignore.$LOG_FILE
|
||||
|
||||
|
||||
function run_solver
|
||||
{
|
||||
solver=$1
|
||||
network=$2
|
||||
solver_flag=true
|
||||
if [ -n "$3" ]; then
|
||||
if [ $solver = hve ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(elim_heuristic,$3\)
|
||||
elif [ $solver = bp ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(schedule,$3\)
|
||||
elif [ $solver = cbp ]; then
|
||||
extra_flag=clpbn_horus:set_horus_flag\(schedule,$3\)
|
||||
else
|
||||
echo "unknow flag $3"
|
||||
fi
|
||||
fi
|
||||
/usr/bin/time -o $LOG_FILE -a -f "real:%E\tuser:%U\tsys:%S" \
|
||||
$YAP << EOF >> $LOG_FILE 2>> ignore.$LOG_FILE
|
||||
[$CITY_LOCATION].
|
||||
[$network].
|
||||
clpbn_horus:set_solver($solver).
|
||||
clpbn_horus:set_horus_flag(use_logarithms, true).
|
||||
$solver_flag.
|
||||
is_joe_guilty(X).
|
||||
open("$LOG_FILE", 'append', S), format(S, '$network: ~15+ ', []), close(S).
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
function run_all_graphs
|
||||
{
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
echo "results for solver $2" >> $LOG_FILE
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
run_solver $1 city_5 $3
|
||||
#run_solver $1 city_1000 $3
|
||||
#run_solver $1 city_5000 $3
|
||||
#run_solver $1 city_10000 $3
|
||||
#run_solver $1 city_50000 $3
|
||||
#run_solver $1 city_100000 $3
|
||||
#run_solver $1 city_500000 $3
|
||||
#run_solver $1 city_1000000 $3
|
||||
}
|
||||
|
||||
run_all_graphs hve "hve(elim_heuristic=min_neighbors) " min_neighbors
|
||||
run_all_graphs "hve(elim_heuristic=min_neighbors) " min_neighbors
|
||||
|
||||
|
11
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/bp_tests.sh
Executable file
11
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/bp_tests.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
source wa.sh
|
||||
source ../benchs.sh
|
||||
|
||||
SOLVER="bp"
|
||||
|
||||
YAP=~/bin/$SHORTNAME-$SOLVER
|
||||
|
||||
run_all_graphs "bp(shedule=seq_fixed) " seq_fixed
|
||||
|
11
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/cbp_tests.sh
Executable file
11
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/cbp_tests.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
source wa.sh
|
||||
source ../benchs.sh
|
||||
|
||||
SOLVER="cbp"
|
||||
|
||||
YAP=~/bin/$SHORTNAME-$SOLVER
|
||||
|
||||
run_all_graphs "cbp(shedule=seq_fixed) " seq_fixed
|
||||
|
12
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/fove_tests.sh
Executable file
12
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/fove_tests.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
source wa.sh
|
||||
source ../benchs.sh
|
||||
|
||||
SOLVER="fove"
|
||||
|
||||
YAP=~/bin/$SHORTNAME-$SOLVER
|
||||
|
||||
run_all_graphs "fove "
|
||||
|
||||
|
11
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/hve_tests.sh
Executable file
11
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/hve_tests.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
source wa.sh
|
||||
source ../benchs.sh
|
||||
|
||||
SOLVER="hve"
|
||||
|
||||
YAP=~/bin/$SHORTNAME-$SOLVER
|
||||
|
||||
run_all_graphs "hve(elim_heuristic=min_neighbors) " min_neighbors
|
||||
|
27
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/people_generator.sh
Executable file
27
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/people_generator.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/home/tiago/bin/yap -L --
|
||||
|
||||
|
||||
:- initialization(main).
|
||||
|
||||
|
||||
main :-
|
||||
unix(argv([H])),
|
||||
generate_town(H).
|
||||
|
||||
|
||||
generate_town(N) :-
|
||||
atomic_concat(['pop_', N, '.yap'], FileName),
|
||||
open(FileName, 'write', S),
|
||||
atom_number(N, N2),
|
||||
generate_people(S, N2, 4),
|
||||
write(S, '\n'),
|
||||
close(S).
|
||||
|
||||
|
||||
generate_people(S, N, Counting) :-
|
||||
Counting > N, !.
|
||||
generate_people(S, N, Counting) :-
|
||||
format(S, 'people(p~w).~n', [Counting]),
|
||||
Counting1 is Counting + 1,
|
||||
generate_people(S, N, Counting1).
|
||||
|
35
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/wa.sh
Executable file
35
packages/CLPBN/clpbn/bp/benchmarks/workshop_attrs/wa.sh
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
NETWORK="'../../examples/workshop_attrs'"
|
||||
SHORTNAME="wa"
|
||||
QUERY="series(X)"
|
||||
|
||||
|
||||
function run_all_graphs
|
||||
{
|
||||
LOG_FILE=$SOLVER.log
|
||||
#LOG_FILE=results`date "+ %H:%M:%S %d-%m-%Y"`.
|
||||
|
||||
rm -f $LOG_FILE
|
||||
rm -f ignore.$LOG_FILE
|
||||
|
||||
cp ~/bin/yap $YAP
|
||||
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
echo "results for solver $1" >> $LOG_FILE
|
||||
echo -n "**********************************" >> $LOG_FILE
|
||||
echo "**********************************" >> $LOG_FILE
|
||||
|
||||
run_solver "nn" $2
|
||||
#run_solver pop_10 $2
|
||||
#run_solver pop_1000 $2
|
||||
#run_solver pop_5000 $2
|
||||
#run_solver pop_10000 $2
|
||||
#run_solver pop_50000 $2
|
||||
#run_solver pop_100000 $2
|
||||
#run_solver pop_500000 $2
|
||||
#run_solver pop_1000000 $2
|
||||
}
|
||||
|
||||
|
@ -20,19 +20,19 @@ bayes city_conservativeness(C)::[y,n] ; cons_table(C) ; [people(_,C)].
|
||||
|
||||
bayes gender(P)::[m,f] ; gender_table(P) ; [people(P,_)].
|
||||
|
||||
bayes hair_color(P)::[t,f] , city_conservativeness(C) ; hair_color_table(P) ; [people(P,C)].
|
||||
bayes hair_color(P)::[t,f], city_conservativeness(C) ; hair_color_table(P) ; [people(P,C)].
|
||||
|
||||
bayes car_color(P)::[t,f] , hair_color(P) ; car_color_table(P); [people(P,_)].
|
||||
bayes car_color(P)::[t,f], hair_color(P) ; car_color_table(P); [people(P,_)].
|
||||
|
||||
bayes height(P)::[t,f] , gender(P) ; height_table(P) ; [people(P,_)].
|
||||
bayes height(P)::[t,f], gender(P) ; height_table(P) ; [people(P,_)].
|
||||
|
||||
bayes shoe_size(P):[t,f] , height(P) ; shoe_size_table(P); [people(P,_)].
|
||||
bayes shoe_size(P):[t,f], height(P) ; shoe_size_table(P); [people(P,_)].
|
||||
|
||||
bayes guilty(P)::[y,n] ; guilty_table(P) ; [people(P,_)].
|
||||
|
||||
bayes descn(P)::[t,f] , car_color(P), hair_color(P), height(P), guilty(P) ; descn_table(P) ; [people(P,_)].
|
||||
bayes descn(P)::[t,f], car_color(P), hair_color(P), height(P), guilty(P) ; descn_table(P) ; [people(P,_)].
|
||||
|
||||
bayes witness(C)::[t,f] , descn(Joe) , descn(P2) ; wit_table ; [people(_,C), Joe=joe, P2=p2].
|
||||
bayes witness(C)::[t,f], descn(Joe), descn(P2) ; wit_table ; [people(_,C), Joe=joe, P2=p2].
|
||||
|
||||
|
||||
cons_table(amsterdam, [0.2, 0.8]) :- !.
|
||||
|
@ -5,6 +5,8 @@
|
||||
%:- clpbn_horus:set_solver(bp).
|
||||
%:- clpbn_horus:set_solver(cbp).
|
||||
|
||||
:- yap_flag(write_strings, off).
|
||||
|
||||
c(p1,w1).
|
||||
c(p1,w2).
|
||||
c(p1,w3).
|
||||
|
@ -9,15 +9,16 @@
|
||||
|
||||
|
||||
friends(P1, P2) :-
|
||||
person(P1),
|
||||
person(P2),
|
||||
people(P1),
|
||||
people(P2),
|
||||
P1 \= P2.
|
||||
|
||||
person @ 3.
|
||||
people @ 3.
|
||||
|
||||
markov smokes(P)::[t,f] , cancer(P)::[t,f] ; [0.1, 0.2, 0.3, 0.4] ; [person(P)].
|
||||
markov smokes(P)::[t,f], cancer(P)::[t,f] ; [0.1, 0.2, 0.3, 0.4] ; [people(P)].
|
||||
|
||||
markov friend(P1,P2)::[t,f], smokes(P1)::[t,f], smokes(P2)::[t,f] ; [0.5, 0.6, 0.7, 0.8, 0.5, 0.6, 0.7, 0.8] ; [friends(P1, P2)].
|
||||
markov friend(P1,P2)::[t,f], smokes(P1)::[t,f], smokes(P2)::[t,f] ;
|
||||
[0.5, 0.6, 0.7, 0.8, 0.5, 0.6, 0.7, 0.8] ; [friends(P1, P2)].
|
||||
|
||||
% ?- smokes(person_1, t), smokes(person_2, f), friend(person_1, person_2, X).
|
||||
% ?- smokes(p1, t), smokes(p2, f), friend(p1, p2, X).
|
||||
|
||||
|
@ -1,30 +1,27 @@
|
||||
:- use_module(library(pfl)).
|
||||
|
||||
:- clpbn_horus:set_solver(fove).
|
||||
%:- clpbn_horus:set_solver(fove).
|
||||
%:- clpbn_horus:set_solver(hve).
|
||||
%:- clpbn_horus:set_solver(bp).
|
||||
:- clpbn_horus:set_solver(bp).
|
||||
%:- clpbn_horus:set_solver(cbp).
|
||||
|
||||
c(p1).
|
||||
c(p2).
|
||||
c(p3).
|
||||
c(p4).
|
||||
c(p5).
|
||||
:- yap_flag(write_strings, off).
|
||||
|
||||
people @ 3.
|
||||
|
||||
markov attends(P)::[t,f] , attr1::[t,f] ; [0.1, 0.2, 0.3, 0.4] ; [c(P)].
|
||||
markov attends(P)::[t,f], attr1::[t,f] ; [0.11, 0.2, 0.3, 0.4] ; [people(P)].
|
||||
|
||||
markov attends(P)::[t,f] , attr2::[t,f] ; [0.1, 0.2, 0.3, 0.4] ; [c(P)].
|
||||
markov attends(P)::[t,f], attr2::[t,f] ; [0.1, 0.22, 0.3, 0.4] ; [people(P)].
|
||||
|
||||
markov attends(P)::[t,f] , attr3::[t,f] ; [0.1, 0.2, 0.3, 0.4] ; [c(P)].
|
||||
markov attends(P)::[t,f], attr3::[t,f] ; [0.1, 0.2, 0.33, 0.4] ; [people(P)].
|
||||
|
||||
markov attends(P)::[t,f] , attr4::[t,f] ; [0.1, 0.2, 0.3, 0.4] ; [c(P)].
|
||||
markov attends(P)::[t,f], attr4::[t,f] ; [0.1, 0.2, 0.3, 0.44] ; [people(P)].
|
||||
|
||||
markov attends(P)::[t,f] , attr5::[t,f] ; [0.1, 0.2, 0.3, 0.4] ; [c(P)].
|
||||
markov attends(P)::[t,f], attr5::[t,f] ; [0.1, 0.2, 0.3, 0.45] ; [people(P)].
|
||||
|
||||
markov attends(P)::[t,f] , attr6::[t,f] ; [0.1, 0.2, 0.3, 0.4] ; [c(P)].
|
||||
markov attends(P)::[t,f], attr6::[t,f] ; [0.1, 0.2, 0.3, 0.46] ; [people(P)].
|
||||
|
||||
markov attends(P)::[t,f], series::[t,f] ; [0.5, 0.6, 0.7, 0.8] ; [c(P)].
|
||||
markov attends(P)::[t,f], series::[t,f] ; [0.5, 0.6, 0.7, 0.87] ; [people(P)].
|
||||
|
||||
?- series(X).
|
||||
|
||||
|
@ -41,18 +41,19 @@
|
||||
user:term_expansion( bayes((Formula ; Phi ; Constraints)), pfl:factor(bayes,Id,FList,FV,Phi,Constraints)) :-
|
||||
!,
|
||||
term_variables(Formula, FreeVars),
|
||||
FV =.. [fv|FreeVars],
|
||||
FV =.. [''|FreeVars],
|
||||
new_id(Id),
|
||||
process_args(Formula, Id, 0, _, FList, []).
|
||||
user:term_expansion( markov((Formula ; Phi ; Constraints)), pfl:factor(markov,Id,FList,FV,Phi,Constraints)) :-
|
||||
!,
|
||||
term_variables(Formula, FreeVars),
|
||||
FV =.. [fv|FreeVars],
|
||||
FV =.. [''|FreeVars],
|
||||
new_id(Id),
|
||||
process_args(Formula, Id, 0, _, FList, []).
|
||||
user:term_expansion( Id@N, L ) :-
|
||||
atom(Id), number(N), !,
|
||||
findall(G,generate_entity(0, N, Id, G), L).
|
||||
N1 is N + 1,
|
||||
findall(G,generate_entity(1, N1, Id, G), L).
|
||||
user:term_expansion( Goal, [] ) :-
|
||||
preprocess(Goal, Sk,Var), !,
|
||||
(ground(Goal) -> true ; throw(error('non ground evidence',Goal))),
|
||||
@ -78,7 +79,7 @@ defined_in_factor(Key, Factor) :-
|
||||
|
||||
generate_entity(N, N, _, _) :- !.
|
||||
generate_entity(I0, _N, Id, T) :-
|
||||
atomic_concat(person_, I0, P),
|
||||
atomic_concat(p, I0, P),
|
||||
T =.. [Id, P].
|
||||
generate_entity(I0, N, Id, T) :-
|
||||
I is I0+1,
|
||||
|
Reference in New Issue
Block a user