Use the word option instead of key. Key reminds me of hashes

This commit is contained in:
Tiago Gomes 2013-01-10 22:59:12 +00:00
parent f7fcfec8ce
commit f3bd8ad414
6 changed files with 47 additions and 47 deletions

View File

@ -204,8 +204,8 @@ clpbn_flag(output,Before,After) :-
retract(output(Before)),
assert(output(After)).
clpbn_flag(HorusKey,_Before,After) :-
set_horus_flag(HorusKey,After).
clpbn_flag(HorusOption,_Before,After) :-
set_horus_flag(HorusOption,After).
set_solver(Solver) :-
set_clpbn_flag(solver,Solver).

View File

@ -17,7 +17,7 @@ VarIds readQueryAndEvidence (FactorGraph&, int, const char* [], int);
void runSolver (const FactorGraph&, const VarIds&);
const string USAGE = "usage: ./hcli [solver=hve|bp|cbp] \
[<HORUS>=<VALUE>]... <FILE> [<VAR>|<VAR>=<EVIDENCE>]... " ;
[<OPTION>=<VALUE>]... <FILE> [<VAR>|<VAR>=<EVIDENCE>]... " ;
int

View File

@ -325,24 +325,24 @@ setVarsInformation (void)
int
setHorusFlag (void)
{
string key ((char*) YAP_AtomName (YAP_AtomOfTerm (YAP_ARG1)));
string option ((char*) YAP_AtomName (YAP_AtomOfTerm (YAP_ARG1)));
string value;
if (key == "verbosity") {
if (option == "verbosity") {
stringstream ss;
ss << (int) YAP_IntOfTerm (YAP_ARG2);
ss >> value;
} else if (key == "bp_accuracy") {
} else if (option == "bp_accuracy") {
stringstream ss;
ss << (float) YAP_FloatOfTerm (YAP_ARG2);
ss >> value;
} else if (key == "bp_max_iter") {
} else if (option == "bp_max_iter") {
stringstream ss;
ss << (int) YAP_IntOfTerm (YAP_ARG2);
ss >> value;
} else {
value = ((char*) YAP_AtomName (YAP_AtomOfTerm (YAP_ARG2)));
}
return Util::setHorusFlag (key, value);
return Util::setHorusFlag (option, value);
}

View File

@ -188,10 +188,10 @@ getStateLines (const Vars& vars)
bool invalidValue (string key, string value)
bool invalidValue (string option, string value)
{
cerr << "Warning: invalid value `" << value << "' " ;
cerr << "for `" << key << "'" ;
cerr << "for `" << option << "'." ;
cerr << endl;
return false;
}
@ -199,32 +199,32 @@ bool invalidValue (string key, string value)
bool
setHorusFlag (string key, string value)
setHorusFlag (string option, string value)
{
bool returnVal = true;
if (key == "lifted_solver") {
if (option == "lifted_solver") {
if (value == "lve") Globals::liftedSolver = LiftedSolverType::LVE;
else if (value == "lbp") Globals::liftedSolver = LiftedSolverType::LBP;
else if (value == "lkc") Globals::liftedSolver = LiftedSolverType::LKC;
else returnVal = invalidValue (key, value);
else returnVal = invalidValue (option, value);
} else if (key == "ground_solver" || key == "solver") {
} else if (option == "ground_solver" || option == "solver") {
if (value == "hve") Globals::groundSolver = GroundSolverType::VE;
else if (value == "bp") Globals::groundSolver = GroundSolverType::BP;
else if (value == "cbp") Globals::groundSolver = GroundSolverType::CBP;
else returnVal = invalidValue (key, value);
else returnVal = invalidValue (option, value);
} else if (key == "verbosity") {
} else if (option == "verbosity") {
stringstream ss;
ss << value;
ss >> Globals::verbosity;
} else if (key == "use_logarithms") {
} else if (option == "use_logarithms") {
if (value == "true") Globals::logDomain = true;
else if (value == "false") Globals::logDomain = false;
else returnVal = invalidValue (key, value);
else returnVal = invalidValue (option, value);
} else if (key == "hve_elim_heuristic") {
} else if (option == "hve_elim_heuristic") {
if (value == "sequential")
ElimGraph::setElimHeuristic (ElimHeuristic::SEQUENTIAL);
else if (value == "min_neighbors")
@ -236,9 +236,9 @@ setHorusFlag (string key, string value)
else if (value == "weighted_min_fill")
ElimGraph::setElimHeuristic (ElimHeuristic::WEIGHTED_MIN_FILL);
else
returnVal = invalidValue (key, value);
returnVal = invalidValue (option, value);
} else if (key == "bp_msg_schedule") {
} else if (option == "bp_msg_schedule") {
if (value == "seq_fixed")
BeliefProp::setMsgSchedule (MsgSchedule::SEQ_FIXED);
else if (value == "seq_random")
@ -248,44 +248,44 @@ setHorusFlag (string key, string value)
else if (value == "max_residual")
BeliefProp::setMsgSchedule (MsgSchedule::MAX_RESIDUAL);
else
returnVal = invalidValue (key, value);
returnVal = invalidValue (option, value);
} else if (key == "bp_accuracy") {
} else if (option == "bp_accuracy") {
stringstream ss;
double acc;
ss << value;
ss >> acc;
BeliefProp::setAccuracy (acc);
} else if (key == "bp_max_iter") {
} else if (option == "bp_max_iter") {
stringstream ss;
unsigned mi;
ss << value;
ss >> mi;
BeliefProp::setMaxIterations (mi);
} else if (key == "export_libdai") {
} else if (option == "export_libdai") {
if (value == "true") FactorGraph::enableExportToLibDai();
else if (value == "false") FactorGraph::disableExportToLibDai();
else returnVal = invalidValue (key, value);
else returnVal = invalidValue (option, value);
} else if (key == "export_uai") {
} else if (option == "export_uai") {
if (value == "true") FactorGraph::enableExportToUai();
else if (value == "false") FactorGraph::disableExportToUai();
else returnVal = invalidValue (key, value);
else returnVal = invalidValue (option, value);
} else if (key == "export_graphviz") {
} else if (option == "export_graphviz") {
if (value == "true") FactorGraph::enableExportToGraphViz();
else if (value == "false") FactorGraph::disableExportToGraphViz();
else returnVal = invalidValue (key, value);
else returnVal = invalidValue (option, value);
} else if (key == "print_fg") {
} else if (option == "print_fg") {
if (value == "true") FactorGraph::enablePrintFactorGraph();
else if (value == "false") FactorGraph::disablePrintFactorGraph();
else returnVal = invalidValue (key, value);
else returnVal = invalidValue (option, value);
} else {
cerr << "Warning: invalid key `" << key << "'" << endl;
cerr << "Warning: invalid option `" << option << "'" << endl;
returnVal = false;
}
return returnVal;

View File

@ -81,7 +81,7 @@ string parametersToString (const Params&, unsigned = Constants::PRECISION);
vector<string> getStateLines (const Vars&);
bool setHorusFlag (string key, string value);
bool setHorusFlag (string option, string value);
void printHeader (string, std::ostream& os = std::cout);

View File

@ -292,17 +292,17 @@ For instance, if we want to use belief propagation to solve some probabilistic q
\texttt{?- set\_solver(bp).}
It is possible to tweak some parameters of PFL through \texttt{set\_pfl\_flag/2} predicate. The first argument is a key that identifies the parameter that we want to tweak. The second argument is some possible value for this key.
It is possible to tweak some parameters of PFL through \texttt{set\_pfl\_flag/2} predicate. The first argument is a option name that identifies the parameter that we want to tweak. The second argument is some possible value for this option.
The \texttt{verbosity} key controls the level of debugging information that will be printed. Its possible values are positive integers. The higher the number, the more information that will be shown. For instance, we can view some basic debugging information by calling the following goal.
The \texttt{verbosity} option controls the level of debugging information that will be printed. Its possible values are positive integers. The higher the number, the more information that will be shown. For instance, we can view some basic debugging information by calling the following goal.
\texttt{?- set\_pfl\_flag(verbosity, 1).}
This key defaults to 0 (no debugging) and only \texttt{hve}, \texttt{bp}, \texttt{cbp}, \texttt{lve}, \texttt{lkc} and \texttt{lbp} solvers have support for this key.
This option defaults to 0 (no debugging) and only \texttt{hve}, \texttt{bp}, \texttt{cbp}, \texttt{lve}, \texttt{lkc} and \texttt{lbp} solvers have support for this option.
The \texttt{use\_logarithms} key controls whether the calculations performed during inference should be done in a logarithm domain or not. Its values can be \texttt{true} (default) or \texttt{false}. This key only affects \texttt{hve}, \texttt{bp}, \texttt{cbp}, \texttt{lve}, \texttt{lkc} and \texttt{lbp} solvers. The remaining solvers always perform their calculations in a logarithm domain.
The \texttt{use\_logarithms} option controls whether the calculations performed during inference should be done in a logarithm domain or not. Its values can be \texttt{true} (default) or \texttt{false}. This option only affects \texttt{hve}, \texttt{bp}, \texttt{cbp}, \texttt{lve}, \texttt{lkc} and \texttt{lbp} solvers. The remaining solvers always perform their calculations in a logarithm domain.
There are keys specific to some algorithms. The \texttt{hve\_elim\_heuristic} key allows to choose which elimination heuristic will be used by the \texttt{hve} solver (but not \texttt{ve}). The following are supported:
There are options specific to some algorithms. The \texttt{hve\_elim\_heuristic} option allows to choose which elimination heuristic will be used by the \texttt{hve} solver (but not \texttt{ve}). The following are supported:
\begin{itemize}
\item \texttt{sequential}
\item \texttt{min\_neighbors}
@ -313,13 +313,13 @@ There are keys specific to some algorithms. The \texttt{hve\_elim\_heuristic} ke
An explanation for each of these heuristics can be found in Daphne Koller's book \textit{Probabilistic Graphical Models}.
The \texttt{bp\_msg\_schedule}, \texttt{bp\_accuracy} and \texttt{bp\_max\_iter} keys are specific for message passing based algorithms, namely \texttt{bp}, \texttt{cbp} and \texttt{lbp}.
The \texttt{bp\_msg\_schedule}, \texttt{bp\_accuracy} and \texttt{bp\_max\_iter} options are specific for message passing based algorithms, namely \texttt{bp}, \texttt{cbp} and \texttt{lbp}.
The \texttt{bp\_max\_iter} key establishes a maximum number of iterations. One iteration consists in sending all possible messages. It defaults to \texttt{1000}.
The \texttt{bp\_max\_iter} option establishes a maximum number of iterations. One iteration consists in sending all possible messages. It defaults to \texttt{1000}.
The \texttt{bp\_accuracy} key allows to control when the message passing should cease. Be the residual of one message the difference (according some metric) between the one sent in the current iteration and the one sent in the previous. If the highest residual is lesser than the given value, the message passing is stopped and the probabilities are calculated using the last messages that were sent. This key defaults to \texttt{0.0001}.
The \texttt{bp\_accuracy} option allows to control when the message passing should cease. Be the residual of one message the difference (according some metric) between the one sent in the current iteration and the one sent in the previous. If the highest residual is lesser than the given value, the message passing is stopped and the probabilities are calculated using the last messages that were sent. This option defaults to \texttt{0.0001}.
The key \texttt{bp\_msg\_schedule} allows to control the message sending order. Its possible values are:
The option \texttt{bp\_msg\_schedule} allows to control the message sending order. Its possible values are:
\begin{itemize}
\item \texttt{seq\_fixed} (default), at each iteration, all messages are sent with the same order.
@ -330,7 +330,7 @@ The key \texttt{bp\_msg\_schedule} allows to control the message sending order.
\item \texttt{max\_residual}, the next message to be sent is the one with maximum residual (as explained in the paper \textit{Residual Belief Propagation: Informed Scheduling for Asynchronous Message Passing}).
\end{itemize}
The \texttt{export\_libdai} and \texttt{export\_uai} keys can be used to export the current model respectively to \href{http://cs.ru.nl/~jorism/libDAI/doc/fileformats.html}{libDAI}, and \href{http://graphmod.ics.uci.edu/uai08/FileFormat}{UAI08} formats. With the \texttt{export\_graphviz} key it is possible to export the factor graph structure into a format that can be parsed by \href{http://www.graphviz.org/}{Graphviz}. The \texttt{print\_fg} key allows to print a textual representation of the factor graph. All these four keys accept \texttt{true} and \texttt{false} as their values and only have effect in \texttt{hve}, \texttt{bp}, and \texttt{cbp} solvers.
The \texttt{export\_libdai} and \texttt{export\_uai} options allow us to export the current model respectively to \href{http://cs.ru.nl/~jorism/libDAI/doc/fileformats.html}{libDAI}, and \href{http://graphmod.ics.uci.edu/uai08/FileFormat}{UAI08} formats. With the \texttt{export\_graphviz} option it is possible to export the factor graph structure into a format that can be parsed by \href{http://www.graphviz.org/}{Graphviz}. The \texttt{print\_fg} option allows to print a textual representation of the factor graph. All these four options accept \texttt{true} and \texttt{false} as their values and only have effect in \texttt{hve}, \texttt{bp}, and \texttt{cbp} solvers.
@ -358,7 +358,7 @@ This package also includes an external command for perform inference over probab
This command's name is \texttt{hcli} and its usage is as follows.
\begin{verbatim}
$ ./hcli [solver=hve|bp|cbp] [<KEY>=<VALUE>]...
$ ./hcli [solver=hve|bp|cbp] [<OPTION>=<VALUE>]...
<FILE> [<VAR>|<VAR>=<EVIDENCE>]...
\end{verbatim}
@ -376,13 +376,13 @@ Evidence can be given as a pair containing a variable identifier and its observe
\texttt{\$ ./hcli burglary-alarm.uai 0=1}
By default, all probability tasks are resolved using the \texttt{hve} solver. It is possible to choose another solver using the \texttt{solver} key as follows.
By default, all probability tasks are resolved using the \texttt{hve} solver. It is possible to choose another solver using the \texttt{solver} option as follows.
\texttt{\$ ./hcli solver=bp burglary-alarm.uai}
Notice that only the \texttt{hve}, \texttt{bp} and \texttt{cbp} solvers can be used with \texttt{hcli}.
The options that are available with the \texttt{set\_pfl\_flag/2} predicate can be used in \texttt{hcli} too. The syntax is a pair \texttt{<Key>=<Value>} before the model's file name.
The options that are available with the \texttt{set\_pfl\_flag/2} predicate can be used in \texttt{hcli} too. The syntax is a pair \texttt{<Option>=<Value>} before the model's file name.