Merge branch 'master' of ssh://git.dcc.fc.up.pt/yap-6.3

This commit is contained in:
Vitor Santos Costa 2013-07-16 10:00:51 -05:00
commit 4245a04ed0
15 changed files with 266080 additions and 1837 deletions

View File

@ -2004,6 +2004,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
#endif /* TABLING */
op = rtp->opc;
opnum = Yap_op_from_opcode(op);
// fprintf(stderr, "%s\n", Yap_op_names[opnum]);
#ifdef TABLING
}
if (aux_sg_fr && gc_B == SgFr_gen_cp(aux_sg_fr)) {
@ -2166,13 +2167,39 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
case _table_answer_resolution:
{
CELL *vars_ptr, vars;
init_substitution_pointer(gc_B, vars_ptr, CONS_CP(gc_B)->cp_dep_fr);
dep_fr_ptr dep_fr = CONS_CP(gc_B)->cp_dep_fr;
ans_node_ptr ans_node = DepFr_last_answer(dep_fr);
if (TrNode_child(ans_node)) {
/* unconsumed answers */
#ifdef MODE_DIRECTED_TABLING
if (IS_ANSWER_INVALID_NODE(TrNode_child(ans_node))) {
ans_node_ptr old_ans_node;
old_ans_node = ans_node;
ans_node = TrNode_child(ans_node);
do {
ans_node = TrNode_child(ans_node);
} while (IS_ANSWER_INVALID_NODE(ans_node));
TrNode_child(old_ans_node) = ans_node;
} else
#endif /* MODE_DIRECTED_TABLING */
ans_node = TrNode_child(ans_node);
if (gc_B == DepFr_leader_cp(dep_fr)) { \
/* gc_B is a generator-consumer node */ \
/* never here if batched scheduling */ \
TABLING_ERROR_CHECKING(generator_consumer, IS_BATCHED_GEN_CP(gc_B)); \
vars_ptr = (CELL *) (GEN_CP(gc_B) + 1); \
vars_ptr += SgFr_arity(GEN_CP(gc_B)->cp_sg_fr); \
} else { \
vars_ptr = (CELL *) (CONS_CP(gc_B) + 1); \
} \
vars = *vars_ptr++;
while (vars--) {
mark_external_reference(vars_ptr PASS_REGS);
vars_ptr++;
}
}
}
nargs = 0;
break;
case _trie_trust_var:
@ -3113,8 +3140,32 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
case _table_answer_resolution:
{
CELL *vars_ptr, vars;
dep_fr_ptr dep_fr = CONS_CP(gc_B)->cp_dep_fr;
ans_node_ptr ans_node = DepFr_last_answer(dep_fr);
if (TrNode_child(ans_node)) {
/* unconsumed answers */
#ifdef MODE_DIRECTED_TABLING
if (IS_ANSWER_INVALID_NODE(TrNode_child(ans_node))) {
ans_node_ptr old_ans_node;
old_ans_node = ans_node;
ans_node = TrNode_child(ans_node);
do {
ans_node = TrNode_child(ans_node);
} while (IS_ANSWER_INVALID_NODE(ans_node));
TrNode_child(old_ans_node) = ans_node;
} else
#endif /* MODE_DIRECTED_TABLING */
ans_node = TrNode_child(ans_node);
if (gc_B == DepFr_leader_cp(dep_fr)) { \
/* gc_B is a generator-consumer node */
/* never here if batched scheduling */
TABLING_ERROR_CHECKING(generator_consumer, IS_BATCHED_GEN_CP(gc_B));
vars_ptr = (CELL *) (GEN_CP(gc_B) + 1);
vars_ptr += SgFr_arity(GEN_CP(gc_B)->cp_sg_fr);
} else {
vars_ptr = (CELL *) (CONS_CP(gc_B) + 1); \
}
sweep_environments(gc_B->cp_env, EnvSize(gc_B->cp_cp), EnvBMap(gc_B->cp_cp) PASS_REGS);
init_substitution_pointer(gc_B, vars_ptr, CONS_CP(gc_B)->cp_dep_fr);
vars = *vars_ptr++;
while (vars--) {
CELL cp_cell = *vars_ptr;
@ -3127,6 +3178,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
vars_ptr++;
}
}
}
break;
case _trie_trust_var:
case _trie_retry_var:

View File

@ -7,7 +7,7 @@
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<!-- html -->
<meta name="src" content="manual.tex">
<meta name="date" content="2011-10-10 19:58:00">
<meta name="date" content="2013-07-16 15:51:00">
<link rel="stylesheet" type="text/css" href="manual.css">
</head><body
>
@ -21,7 +21,7 @@ class="cmr-12">Fabrizio Riguzzi</span>
<br /><span
class="cmr-12">fabrizio.riguzzi@unife.it</span></div><br />
<div class="date" ><span
class="cmr-12">October 10, 2011</span></div>
class="cmr-12">July 16, 2013</span></div>
</div>
<h3 class="sectionHead"><span class="titlemark">1 </span> <a
id="x1-10001"></a>Introduction</h3>
@ -40,13 +40,13 @@ learning.
<!--l. 34--><p class="noindent" ><span
class="cmtt-10">cplint </span>is distributed in source code in the source code development tree of Yap. It
includes Prolog and C files. Download it by following the instruction in <a
href="http://www.ncc.up.pt/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}vsc/Yap/downloads.html" >
http://www.ncc.up.pt/&#x00A0;vsc/Yap/downloads.html </a>.
href="http://www.dcc.fc.up.pt/~vsc/Yap/downloads.html" >
http://www.dcc.fc.up.pt/&#x02DC;vsc/Yap/downloads.html </a>.
<!--l. 36--><p class="indent" > <span
class="cmtt-10">cplint </span>requires <a
href="http://vlsi.colorado.edu/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}fabio/CUDD/" > CUDD </a>. You can download CUDD from <a
href="ftp://vlsi.colorado.edu/pub/cudd-2.4.2.tar.gz" >
ftp://vlsi.colorado.edu/pub/cudd-2.4.2.tar.gz </a>.
href="http://vlsi.colorado.edu/~fabio/CUDD/" > CUDD </a>. You can download CUDD from <a
href="ftp://vlsi.colorado.edu/pub/cudd-2.5.0.tar.gz" >
ftp://vlsi.colorado.edu/pub/cudd-2.5.0.tar.gz </a>.
<!--l. 39--><p class="indent" > Compile CUDD:
<ol class="enumerate1" >
<li
@ -70,7 +70,7 @@ configure&#x00A0;--enable-cplint=DIR
<!--l. 50--><p class="nopar" > where <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">DIR</span></span></span> is the directory where CUDD is, i.e., the directory ending with
<span
class="cmtt-10">cudd-2.4.2</span>. Under Windows, you have to use Cygwin (CUDD does not compile
class="cmtt-10">cudd-2.5.0</span>. Under Windows, you have to use Cygwin (CUDD does not compile
under MinGW), so<br
class="newline" />
@ -160,7 +160,7 @@ average/2
</div>
<!--l. 114--><p class="nopar" > that, given a list of numbers, computes its arithmetic mean.
<!--l. 117--><p class="indent" > The syntax of ICL program is the one used by the <a
href="http://www.cs.ubc.ca/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}poole/aibook/code/ailog/ailog2.html" > AILog 2 </a> system.
href="http://www.cs.ubc.ca/~poole/aibook/code/ailog/ailog2.html" > AILog 2 </a> system.
<h3 class="sectionHead"><span class="titlemark">4 </span> <a
id="x1-40004"></a>Inference</h3>
<!--l. 119--><p class="noindent" ><span
@ -244,7 +244,7 @@ href="#XRig11-CILC11-NC">17</a>]</span></li></ul>
class="cmtt-10">approx/exact.pl </span>as <span
class="cmtt-10">lpadsld.pl </span>but uses SimplecuddLPADs, a modification
of the <a
href="www.cs.kuleuven.be/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}theo/tools/simplecudd.html" > Simplecudd </a> instead of the <span
href="http://dtai.cs.kuleuven.be/problog/download.html" > Simplecudd </a> instead of the <span
class="cmtt-10">cplint </span>library for building BDDs and
computing the probability.</li></ul>
<!--l. 149--><p class="indent" > These modules answer queries using the definition of the semantics of LPADs and
@ -505,7 +505,7 @@ class="cmtt-10">X=1,X1=0 </span>and variable <span
class="cmtt-10">X2 </span>corresponds to clause <span
class="cmtt-10">1 </span>with the
empty substitution. You can view the graph with <a
href="www.graphviz.org" > <span
href="http://www.graphviz.org" > <span
class="cmtt-10">graphviz </span></a> using the
command
@ -1039,7 +1039,7 @@ unseen(&#x003C;predicate&#x003E;/&#x003C;arity&#x003E;).
<!--l. 504--><p class="nopar" >
<!--l. 506--><p class="indent" > For SLIPCASE, you have to specify the language bias by means of mode
declarations in the style of <a
href="http://www.doc.ic.ac.uk/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}shm/progol.html" > Progol </a>.
href="http://www.doc.ic.ac.uk/~shm/progol.html" > Progol </a>.
<div class="verbatim" id="verbatim-42">
modeh(&#x003C;recall&#x003E;,&#x003C;predicate&#x003E;(&#x003C;arg1&#x003E;,...).
@ -1071,17 +1071,37 @@ class="cmtt-10">&#x003C;type&#x003E;</span>. or
&#x003C;constant&#x003E;
</div>
<!--l. 529--><p class="nopar" > for specifying a constant.
<!--l. 532--><p class="noindent" >
<!--l. 532--><p class="indent" > An example of language bias for the UWCSE domain is
<div class="verbatim" id="verbatim-47">
output(advisedby/2).
&#x00A0;<br />
&#x00A0;<br />input(student/1).
&#x00A0;<br />input(professor/1).
&#x00A0;<br />....
&#x00A0;<br />
&#x00A0;<br />modeh(*,advisedby(+person,+person)).
&#x00A0;<br />
&#x00A0;<br />modeb(*,professor(+person)).
&#x00A0;<br />modeb(*,student(+person)).
&#x00A0;<br />modeb(*,sameperson(+person,&#x00A0;-person)).
&#x00A0;<br />modeb(*,sameperson(-person,&#x00A0;+person)).
&#x00A0;<br />modeb(*,samecourse(+course,&#x00A0;-course)).
&#x00A0;<br />modeb(*,samecourse(-course,&#x00A0;+course)).
&#x00A0;<br />....
</div>
<!--l. 549--><p class="nopar" >
<!--l. 551--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">5.2 </span> <a
id="x1-120005.2"></a>Parameters</h4>
<!--l. 533--><p class="noindent" >In order to set the algorithms&#8217; parameters, you have to insert in <span
<!--l. 552--><p class="noindent" >In order to set the algorithms&#8217; parameters, you have to insert in <span
class="cmtt-10">&#x003C;stem&#x003E;.l </span>commands
of the form
<div class="verbatim" id="verbatim-47">
<div class="verbatim" id="verbatim-48">
:-&#x00A0;set(&#x003C;parameter&#x003E;,&#x003C;value&#x003E;).
</div>
<!--l. 536--><p class="nopar" > The available parameters are:
<!--l. 555--><p class="nopar" > The available parameters are:
<ul class="itemize1">
<li class="itemize"><span class="obeylines-h"><span class="verb"><span
class="cmtt-10">depth</span></span></span> (values: integer or <span class="obeylines-h"><span class="verb"><span
@ -1228,70 +1248,79 @@ class="cmtt-10">verbosity</span></span></span> (values: integer in [1,3], defaul
class="cmtt-10">beamsize</span></span></span> (values: integer, default value: 20, valid for SLIPCASE): size of
the beam in SLIPCASE
</li></ul>
<!--l. 571--><p class="noindent" >
<!--l. 590--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">5.3 </span> <a
id="x1-130005.3"></a>Commands</h4>
<!--l. 572--><p class="noindent" >To execute CEM, load <span
<!--l. 591--><p class="noindent" >To execute CEM, load <span
class="cmtt-10">em.pl </span>with
<div class="verbatim" id="verbatim-48">
<div class="verbatim" id="verbatim-49">
?:-&#x00A0;use_module(library(&#8217;cplint/em&#8217;)).
</div>
<!--l. 575--><p class="nopar" > and call:
<div class="verbatim" id="verbatim-49">
?:-&#x00A0;em(stem).
</div>
<!--l. 579--><p class="nopar" > To execute RIB, load <span
class="cmtt-10">rib.pl </span>with
<!--l. 594--><p class="nopar" > and call:
<div class="verbatim" id="verbatim-50">
?:-&#x00A0;use_module(library(&#8217;cplint/rib&#8217;)).
</div>
<!--l. 583--><p class="nopar" > and call:
<div class="verbatim" id="verbatim-51">
?:-&#x00A0;ib_par(stem).
</div>
<!--l. 587--><p class="nopar" > To execute EMBLEM, load <span
class="cmtt-10">slipcase.pl </span>with
<div class="verbatim" id="verbatim-52">
?:-&#x00A0;use_module(library(&#8217;cplint/slipcase&#8217;)).
</div>
<!--l. 591--><p class="nopar" > and call
<div class="verbatim" id="verbatim-53">
?:-&#x00A0;em(stem).
</div>
<!--l. 595--><p class="nopar" > To execute SLIPCASE, load <span
<!--l. 598--><p class="nopar" > To execute RIB, load <span
class="cmtt-10">rib.pl </span>with
<div class="verbatim" id="verbatim-51">
?:-&#x00A0;use_module(library(&#8217;cplint/rib&#8217;)).
</div>
<!--l. 602--><p class="nopar" > and call:
<div class="verbatim" id="verbatim-52">
?:-&#x00A0;ib_par(stem).
</div>
<!--l. 606--><p class="nopar" > To execute EMBLEM, load <span
class="cmtt-10">slipcase.pl </span>with
<div class="verbatim" id="verbatim-54">
<div class="verbatim" id="verbatim-53">
?:-&#x00A0;use_module(library(&#8217;cplint/slipcase&#8217;)).
</div>
<!--l. 599--><p class="nopar" > and call
<!--l. 610--><p class="nopar" > and call
<div class="verbatim" id="verbatim-54">
?:-&#x00A0;em(stem).
</div>
<!--l. 614--><p class="nopar" > To execute SLIPCASE, load <span
class="cmtt-10">slipcase.pl </span>with
<div class="verbatim" id="verbatim-55">
?:-&#x00A0;use_module(library(&#8217;cplint/slipcase&#8217;)).
</div>
<!--l. 618--><p class="nopar" > and call
<div class="verbatim" id="verbatim-56">
?:-&#x00A0;sl(stem).
</div>
<!--l. 603--><p class="nopar" >
<!--l. 605--><p class="noindent" >
<!--l. 622--><p class="nopar" >
<h4 class="subsectionHead"><span class="titlemark">5.4 </span> <a
id="x1-140005.4"></a>Learning Examples</h4>
<!--l. 624--><p class="noindent" >The subfolders <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">em</span></span></span>, <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">rib</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">slipcase</span></span></span> of the <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">packages/cplint</span></span></span> folder in Yap
git distribution contain examples of input and output files for the learning
algorithms.
<!--l. 627--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">6 </span> <a
id="x1-140006"></a>License</h3>
<!--l. 610--><p class="noindent" ><span
id="x1-150006"></a>License</h3>
<!--l. 632--><p class="noindent" ><span
class="cmtt-10">cplint</span>, as Yap, follows the Artistic License 2.0 that you can find in Yap CVS root
dir. The copyright is by Fabrizio Riguzzi.
<!--l. 613--><p class="indent" > The modules in the approx subdirectory use SimplecuddLPADs, a modification of
<!--l. 635--><p class="indent" > The modules in the approx subdirectory use SimplecuddLPADs, a modification of
the <a
href="www.cs.kuleuven.be/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}theo/tools/simplecudd.html" > Simplecudd </a> library whose copyright is by Katholieke Universiteit Leuven and
href="http://dtai.cs.kuleuven.be/problog/download.html" > Simplecudd </a> library whose copyright is by Katholieke Universiteit Leuven and
that follows the Artistic License 2.0.
<!--l. 616--><p class="indent" > Some modules use the library <a
href="http://vlsi.colorado.edu/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}fabio/" > CUDD </a> for manipulating BDDs that is included in
<!--l. 638--><p class="indent" > Some modules use the library <a
href="http://vlsi.colorado.edu/~fabio/" > CUDD </a> for manipulating BDDs that is included in
glu. For the use of CUDD, the following license must be accepted:
<!--l. 621--><p class="indent" > Copyright (c) 1995-2004, Regents of the University of Colorado
<!--l. 623--><p class="indent" > All rights reserved.
<!--l. 625--><p class="indent" > Redistribution and use in source and binary forms, with or without modification,
<!--l. 643--><p class="indent" > Copyright (c) 1995-2004, Regents of the University of Colorado
<!--l. 645--><p class="indent" > All rights reserved.
<!--l. 647--><p class="indent" > Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
<ul class="itemize1">
<li class="itemize">Redistributions of source code must retain the above copyright notice, this
@ -1304,14 +1333,14 @@ are permitted provided that the following conditions are met:
<li class="itemize">Neither the name of the University of Colorado nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.</li></ul>
<!--l. 642--><p class="noindent" >THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS <br
<!--l. 664--><p class="noindent" >THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS <br
class="newline" />AND CONTRIBUTORS &#8221;AS IS&#8221; AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAU-SED <br
@ -1319,18 +1348,17 @@ class="newline" />AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!--l. 656--><p class="indent" > <span
<!--l. 678--><p class="indent" > <span
class="cmtt-10">lpad.pl</span>, <span
class="cmtt-10">semlpad.pl </span>and <span
class="cmtt-10">cpl.pl </span>are based on the SLG system by <a
href="http://engr.smu.edu/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}wchen/" > Weidong
Chen </a> and <a
href="http://www.cs.sunysb.edu/\protect \unhbox \voidb@x \penalty \@M \relax \unhbox \voidb@x \special {t4ht@+&{35}x00A0{59}}x{}warren/" > David Scott Warren </a>, Copyright (C) 1993 Southern Methodist University,
class="cmtt-10">cpl.pl </span>are based on the SLG system by Weidong
Chen and <a
href="http://www.cs.sunysb.edu/~warren/" > David Scott Warren </a>, Copyright (C) 1993 Southern Methodist University,
1993 SUNY at Stony Brook, see the file COYPRIGHT_SLG for detailed information
on this copyright.
<!--l. 1--><p class="noindent" >
<h3 class="likesectionHead"><a
id="x1-150006"></a>References</h3>
id="x1-160006"></a>References</h3>
<!--l. 1--><p class="noindent" >
<div class="thebibliography">
<p class="bibitem" ><span class="biblabel">
@ -1358,6 +1386,7 @@ class="cmti-10">31-2 September, 2011</span>, 2011.
<p class="bibitem" ><span class="biblabel">
[4]<span class="bibsp">&#x00A0;&#x00A0;&#x00A0;</span></span><a
id="XBelRig11-ILP11-IC"></a>Elena Bellodi and Fabrizio Riguzzi. Learning the structure of
probabilistic logic programs. In <span
class="cmti-10">Inductive Logic Programming, 21th</span>
<span
@ -1367,7 +1396,6 @@ class="cmti-10">International Conference, ILP 2011, London, UK, 31 July-3 August
<p class="bibitem" ><span class="biblabel">
[5]<span class="bibsp">&#x00A0;&#x00A0;&#x00A0;</span></span><a
id="XBelRig11-IDA"></a>Elena Bellodi and Fabrizio Riguzzi. Expectation Maximization over
binary decision diagrams for probabilistic logic programs. <span
class="cmti-10">Intel. Data Anal.</span>,
16(6), 2012.
@ -1418,6 +1446,7 @@ class="cmti-10">Journal of Machine Learning Research</span>,
probabilistic relational models. In Saso Dzeroski and Nada Lavrac, editors,
<span
class="cmti-10">Relational Data Mining</span>. Springer-Verlag, Berlin, 2001.
</p>
<p class="bibitem" ><span class="biblabel">
[12]<span class="bibsp">&#x00A0;&#x00A0;&#x00A0;</span></span><a
@ -1426,7 +1455,6 @@ class="cmti-10">Relational Data Mining</span>. Springer-Verlag, Berlin, 2001.
class="cmti-10">Journal of Machine Learning</span>
<span
class="cmti-10">Research</span>, 3:679&#8211;707, December 2002.
</p>
<p class="bibitem" ><span class="biblabel">
[13]<span class="bibsp">&#x00A0;&#x00A0;&#x00A0;</span></span><a
@ -1483,6 +1511,7 @@ src="cmsy10-4e.png" alt="N" class="10x-x-4e" /></span>):
class="cmti-10">Uncertainty</span>
<span
class="cmti-10">in Artificial Intelligence</span>. Morgan Kaufmann, 2003.
</p>
<p class="bibitem" ><span class="biblabel">
[20]<span class="bibsp">&#x00A0;&#x00A0;&#x00A0;</span></span><a
@ -1492,7 +1521,6 @@ class="cmti-10">Proceedings of the 10th</span>
<span
class="cmti-10">European Conference on Logics in Artificial Intelligence</span>, LNAI. Springer,
September 2006.
</p>
<p class="bibitem" ><span class="biblabel">
[21]<span class="bibsp">&#x00A0;&#x00A0;&#x00A0;</span></span><a

Binary file not shown.

View File

@ -31,10 +31,10 @@ fabrizio.riguzzi@unife.it}
\texttt{cplint} is a suite of programs for reasoning with ICL \cite{DBLP:journals/ai/Poole97}, LPADs \cite{VenVer03-TR,VenVer04-ICLP04-IC} and CP-logic programs \cite{VenDenBru-JELIA06,DBLP:journals/tplp/VennekensDB09}. It contains programs both for inference and learning.
\section{Installation}
\texttt{cplint} is distributed in source code in the source code development tree of Yap. It includes Prolog and C files. Download it by following the instruction in \url{http://www.ncc.up.pt/~vsc/Yap/downloads.html}.
\texttt{cplint} is distributed in source code in the source code development tree of Yap. It includes Prolog and C files. Download it by following the instruction in \url{http://www.dcc.fc.up.pt/\string ~vsc/Yap/downloads.html}.
\texttt{cplint} requires \href{http://vlsi.colorado.edu/~fabio/CUDD/}{CUDD}.
You can download CUDD from \url{ftp://vlsi.colorado.edu/pub/cudd-2.4.2.tar.gz}.
\texttt{cplint} requires \href{http://vlsi.colorado.edu/\string ~fabio/CUDD/}{CUDD}.
You can download CUDD from \url{ftp://vlsi.colorado.edu/pub/cudd-2.5.0.tar.gz}.
Compile CUDD:
\begin{enumerate}
@ -48,7 +48,7 @@ when compiling Yap following the instruction of the \texttt{INSTALL} file in the
\begin{verbatim}
configure --enable-cplint=DIR
\end{verbatim}
where \verb|DIR| is the directory where CUDD is, i.e., the directory ending with \texttt{cudd-2.4.2}.
where \verb|DIR| is the directory where CUDD is, i.e., the directory ending with \texttt{cudd-2.5.0}.
Under Windows, you have to use Cygwin (CUDD does not compile under MinGW), so\\
\begin{verbatim}
configure --enable-cplint=DIR --enable-cygwin
@ -114,7 +114,7 @@ average/2
\end{verbatim}
that, given a list of numbers, computes its arithmetic mean.
The syntax of ICL program is the one used by the \href{http://www.cs.ubc.ca/~poole/aibook/code/ailog/ailog2.html}{AILog 2} system.
The syntax of ICL program is the one used by the \href{http://www.cs.ubc.ca/\string ~poole/aibook/code/ailog/ailog2.html}{AILog 2} system.
\section{Inference}
\texttt{cplint} contains various modules for answering queries.
@ -143,7 +143,7 @@ It is also able to deal with extensions of LPADs and CP-logic: the clause bodies
\item \texttt{montecarlo.pl} performs Monte Carlo \cite{BraRig10-ILP10-IC}
\item \texttt{mcintyre.pl}: implements the algorithm MCINTYRE (Monte Carlo INference wiTh Yap REcord) \cite{Rig11-CILC11-NC}
\end{itemize}
\item \texttt{approx/exact.pl} as \texttt{lpadsld.pl} but uses SimplecuddLPADs, a modification of the \href{www.cs.kuleuven.be/~theo/tools/simplecudd.html}{Simplecudd} instead of the \texttt{cplint} library for building BDDs and computing the probability.
\item \texttt{approx/exact.pl} as \texttt{lpadsld.pl} but uses SimplecuddLPADs, a modification of the \href{http://dtai.cs.kuleuven.be/problog/download.html}{Simplecudd} instead of the \texttt{cplint} library for building BDDs and computing the probability.
\end{itemize}
These modules answer queries using the definition of the semantics of LPADs and CP-logic:
@ -268,7 +268,7 @@ Variables: [(2,[X=2,X1=1]),(2,[X=1,X1=0]),(1,[])]
In the example above variable \texttt{X0} corresponds to clause \texttt{2} with the substitutions \texttt{X=2,X1=1},
variable \texttt{X1} corresponds to clause \texttt{2} with the substitutions \texttt{X=1,X1=0} and
variable \texttt{X2} corresponds to clause \texttt{1} with the empty substitution.
You can view the graph with \href{www.graphviz.org}{\texttt{graphviz}} using the
You can view the graph with \href{http://www.graphviz.org}{\texttt{graphviz}} using the
command
\begin{verbatim}
dotty cpl.dot &
@ -504,7 +504,7 @@ unseen(<predicate>/<arity>).
\end{verbatim}
For SLIPCASE, you have to specify the language bias by means of mode declarations in the style of
\href{http://www.doc.ic.ac.uk/~shm/progol.html}{Progol}.
\href{http://www.doc.ic.ac.uk/\string ~shm/progol.html}{Progol}.
\begin{verbatim}
modeh(<recall>,<predicate>(<arg1>,...).
\end{verbatim}
@ -529,6 +529,25 @@ for specifying an output variable of type \texttt{<type>}. or
\end{verbatim}
for specifying a constant.
An example of language bias for the UWCSE domain is
\begin{verbatim}
output(advisedby/2).
input(student/1).
input(professor/1).
....
modeh(*,advisedby(+person,+person)).
modeb(*,professor(+person)).
modeb(*,student(+person)).
modeb(*,sameperson(+person, -person)).
modeb(*,sameperson(-person, +person)).
modeb(*,samecourse(+course, -course)).
modeb(*,samecourse(-course, +course)).
....
\end{verbatim}
\subsection{Parameters}
In order to set the algorithms' parameters, you have to insert in \texttt{<stem>.l} commands of the form
\begin{verbatim}
@ -601,6 +620,9 @@ and call
\begin{verbatim}
?:- sl(stem).
\end{verbatim}
\subsection{Learning Examples}
The subfolders \verb|em|, \verb|rib| and \verb|slipcase| of the \verb|packages/cplint| folder in Yap git distribution
contain examples of input and output files for the learning algorithms.
\section{License}
\label{license}
@ -610,10 +632,10 @@ and call
\texttt{cplint}, as Yap, follows the Artistic License 2.0 that you can find in Yap CVS root dir. The copyright is by Fabrizio Riguzzi.
\vspace{3mm}
The modules in the approx subdirectory use SimplecuddLPADs, a modification of the \href{www.cs.kuleuven.be/~theo/tools/simplecudd.html}{Simplecudd} library whose copyright is by Katholieke Universiteit Leuven and that follows the Artistic License 2.0.
The modules in the approx subdirectory use SimplecuddLPADs, a modification of the \href{http://dtai.cs.kuleuven.be/problog/download.html}{Simplecudd} library whose copyright is by Katholieke Universiteit Leuven and that follows the Artistic License 2.0.
\vspace{3mm}
Some modules use the library \href{http://vlsi.colorado.edu/~fabio/}{CUDD} for manipulating BDDs that is included in glu.
Some modules use the library \href{http://vlsi.colorado.edu/\string ~fabio/}{CUDD} for manipulating BDDs that is included in glu.
For the use of CUDD, the following license must be accepted:
\vspace{3mm}
@ -654,7 +676,7 @@ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
\texttt{lpad.pl}, \texttt{semlpad.pl} and \texttt{cpl.pl} are based on the SLG system
by \href{http://engr.smu.edu/~wchen/}{Weidong Chen} and \href{http://www.cs.sunysb.edu/~warren/}{David Scott Warren},
by Weidong Chen and \href{http://www.cs.sunysb.edu/\string ~warren/}{David Scott Warren},
Copyright (C) 1993 Southern Methodist University, 1993 SUNY at Stony Brook, see the file COYPRIGHT\_SLG for detailed information on this copyright.
\bibliographystyle{plain}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -0,0 +1,2 @@
advisedby(X,Y):0.5.
advisedby(X,Y):0.5.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,157 @@
output(advisedby/2).
input(student/1).
input(professor/1).
input(inphase/2).
input(hasposition/2).
input(publication/2).
input(yearsinprogram/2).
input(taughtby/3).
input(ta/3).
input(courselevel/2).
input(tempadvisedby/2).
input(projectmember/2).
input(sameperson/2).
input(samecourse/2).
input(sameproject/2).
modeh(*,advisedby(+person,+person)).
modeb(*,professor(+person)).
modeb(*,student(+person)).
modeb(*,sameperson(+person, -person)).
modeb(*,sameperson(-person, +person)).
modeb(*,samecourse(+course, -course)).
modeb(*,samecourse(-course, +course)).
modeb(*,sameproject(-project, +project)).
modeb(*,sameproject(+project, -project)).
modeb(*,publication(+title, -person)).
modeb(*,courselevel(+course, -level)).
modeb(*,hasposition(+person, -position)).
%modeb(*,projectmember(+project, -person)).
modeb(*,projectmember(project119, +person)).
modeb(*,projectmember(project130, +person)).
modeb(*,projectmember(project152, +person)).
modeb(*,projectmember(project62, +person)).
modeb(*,projectmember(project94, +person)).
modeb(*,inphase(+person, -phase)).
modeb(*,tempadvisedby(+person, -person)).
modeb(*,yearsinprogram(+person, -integer)).
modeb(*,publication(-title, +person)).
%modeb(*,courselevel(-course, +level)).
modeb(*,courselevel(+course, level_500)).
modeb(*,courselevel(+course, level_400)).
modeb(*,courselevel(+course, level_300)).
%modeb(*,hasposition(-person, +position)).
modeb(*,hasposition(+person, faculty)).
modeb(*,hasposition(+person, faculty_affiliate)).
modeb(*,hasposition(+person, faculty_adjunct)).
modeb(*,hasposition(+person, faculty_visiting)).
modeb(*,hasposition(+person, faculty_emeritus)).
modeb(*,projectmember(-project, +person)).
%modeb(*,inphase(-person, +phase)).
modeb(*,inphase(+person, post_quals)).
modeb(*,inphase(+person, post_generals)).
modeb(*,inphase(+person, pre_quals)).
modeb(*,tempadvisedby(-person, +person)).
%modeb(*,yearsinprogram(-person, +integer)).
modeb(*,yearsinprogram(+person, year_1)).
modeb(*,yearsinprogram(+person, year_2)).
modeb(*,yearsinprogram(+person, year_3)).
modeb(*,yearsinprogram(+person, year_4)).
modeb(*,yearsinprogram(+person, year_5)).
modeb(*,yearsinprogram(+person, year_6)).
modeb(*,yearsinprogram(+person, year_7)).
modeb(*,yearsinprogram(+person, year_8)).
modeb(*,yearsinprogram(+person, year_9)).
modeb(*,yearsinprogram(+person, year_10)).
modeb(*,yearsinprogram(+person, year_12)).
modeb(*,taughtby(+course, -person, -quarter)).
modeb(*,ta(+course, -person, -quarter)).
modeb(*,taughtby(-course, +person, -quarter)).
modeb(*,ta(-course, +person, -quarter)).
%modeb(*,taughtby(-course, -person, +quarter)).
%modeb(*,ta(-course, -person, +quarter)).
modeb(*,taughtby(+course, +person, -quarter)).
modeb(*,ta(+course, +person, -quarter)).
%modeb(*,taughtby(+course, -person, +quarter)).
%modeb(*,ta(+course, -person, +quarter)).
modeb(*,taughtby(+course, -person, autumn_0001)).
modeb(*,ta(+course, -person, autumn_0001)).
modeb(*,taughtby(+course, -person, autumn_0102)).
modeb(*,ta(+course, -person, autumn_0102)).
modeb(*,taughtby(+course, -person, autumn_0203)).
modeb(*,ta(+course, -person, autumn_0203)).
modeb(*,taughtby(+course, -person, autumn_0304)).
modeb(*,ta(+course, -person, autumn_0304)).
modeb(*,taughtby(+course, -person, spring_0001)).
modeb(*,ta(+course, -person, spring_0001)).
modeb(*,taughtby(+course, -person, spring_0102)).
modeb(*,ta(+course, -person, spring_0102)).
modeb(*,taughtby(+course, -person, spring_0203)).
modeb(*,ta(+course, -person, spring_0203)).
modeb(*,taughtby(+course, -person, spring_0304)).
modeb(*,ta(+course, -person, spring_0304)).
modeb(*,taughtby(+course, -person, summer_0102)).
modeb(*,ta(+course, -person, summer_0102)).
modeb(*,taughtby(+course, -person, summer_0203)).
modeb(*,ta(+course, -person, summer_0203)).
modeb(*,taughtby(+course, -person, winter_0001)).
modeb(*,ta(+course, -person, winter_0001)).
modeb(*,taughtby(+course, -person, winter_0102)).
modeb(*,ta(+course, -person, winter_0102)).
modeb(*,taughtby(+course, -person, winter_0203)).
modeb(*,ta(+course, -person, winter_0203)).
modeb(*,taughtby(+course, -person, winter_0304)).
modeb(*,ta(+course, -person, winter_0304)).
%modeb(*,taughtby(-course, +person, +quarter)).
%modeb(*,ta(-course, +person, +quarter)).
modeb(*,taughtby(-course, +person, autumn_0001)).
modeb(*,ta(-course, +person, autumn_0001)).
modeb(*,taughtby(-course, +person, autumn_0102)).
modeb(*,ta(-course, +person, autumn_0102)).
modeb(*,taughtby(-course, +person, autumn_0203)).
modeb(*,ta(-course, +person, autumn_0203)).
modeb(*,taughtby(-course, +person, autumn_0304)).
modeb(*,ta(-course, +person, autumn_0304)).
modeb(*,taughtby(-course, +person, spring_0001)).
modeb(*,ta(-course, +person, spring_0001)).
modeb(*,taughtby(-course, +person, spring_0102)).
modeb(*,ta(-course, +person, spring_0102)).
modeb(*,taughtby(-course, +person, spring_0203)).
modeb(*,ta(-course, +person, spring_0203)).
modeb(*,taughtby(-course, +person, spring_0304)).
modeb(*,ta(-course, +person, spring_0304)).
modeb(*,taughtby(-course, +person, summer_0102)).
modeb(*,ta(-course, +person, summer_0102)).
modeb(*,taughtby(-course, +person, summer_0203)).
modeb(*,ta(-course, +person, summer_0203)).
modeb(*,taughtby(-course, +person, winter_0001)).
modeb(*,ta(-course, +person, winter_0001)).
modeb(*,taughtby(-course, +person, winter_0102)).
modeb(*,ta(-course, +person, winter_0102)).
modeb(*,taughtby(-course, +person, winter_0203)).
modeb(*,ta(-course, +person, winter_0203)).
modeb(*,taughtby(-course, +person, winter_0304)).
modeb(*,ta(-course, +person, winter_0304)).

View File

@ -0,0 +1,34 @@
/* SLIPCASE Final CLL -0.461865
Execution time 100.887000
setting(epsilon_em,0.0001).
setting(epsilon_em_fraction,1.0e-5).
setting(eps,0.0001).
setting(eps_f,1.0e-5).
setting(epsilon_sem,2).
setting(random_restarts_REFnumber,1).
setting(random_restarts_number,1).
setting(iterREF,-1).
setting(iter,-1).
setting(examples,atoms).
setting(group,1).
setting(d,1).
setting(verbosity,1).
setting(logzero,log(1.0e-6)).
setting(initial_clauses_modeh,1).
setting(max_iter,10).
setting(max_var,5).
setting(max_rules,10).
setting(beamsize,20).
setting(epsilon_parsing,1.0e-10).
setting(tabling,off).
setting(bagof,false).
setting(depth_bound,false).
setting(depth,2).
setting(single_var,false).
setting(compiling,off).
*/
advisedby(A,B):0.264403 :-
professor(B),
student(A).

View File

@ -2,7 +2,7 @@
EMBLEM and SLIPCASE
Copyright (c) 2011, Fabrizio Riguzzi and Elena Bellodi
Copyright (c) 2013, Fabrizio Riguzzi and Elena Bellodi
This package uses the library cudd, see http://vlsi.colorado.edu/~fabio/CUDD/
for the relative license.
@ -41,24 +41,18 @@ typedef struct
tablerow * table;
static variable * vars;
static variable ** vars_ex;
static int * bVar2mVar;
static int ** bVar2mVar_ex;
static double * sigma;
static double ***eta;
static double ***eta_temp;
static double **arrayprob;
static int *rules;
static DdManager *mgr;
static DdManager **mgr_ex;
static int *nVars;
static int *nVars_ex;
static int nRules;
double * probs;
double * nodes_probs_ex;
double ** probs_ex;
static int * boolVars;
static int * boolVars_ex;
tablerow * nodesB;
tablerow * nodesF;
@ -75,13 +69,13 @@ static int init(void);
static int end(void);
static int EM(void);
static int Q(void);
double ProbPath(DdNode *node, int comp_par);
double ProbPath(DdNode *node, int comp_par, int nex);
static int rec_deref(void);
int indexMvar(DdNode *node);
void Forward(DdNode *node);
void Forward(DdNode *node, int nex);
void GetForward(DdNode *node, double ForwProbPath);
void UpdateForward(DdNode * node);
double GetOutsideExpe(DdNode *root,double ex_prob);
void UpdateForward(DdNode * node, int nex);
double GetOutsideExpe(DdNode *root,double ex_prob, int nex);
void Maximization(void);
static double Expectation(DdNode **nodes_ex, int lenNodes);
void init_my_predicates(void);
@ -133,33 +127,27 @@ static int init(void)
static int init_bdd(void)
{
mgr=Cudd_Init(0,0,UNIQUE_SLOTS,CACHE_SLOTS,5120);
Cudd_AutodynEnable(mgr, CUDD_REORDER_GROUP_SIFT);
Cudd_SetMaxCacheHard(mgr, 0);
Cudd_SetLooseUpTo(mgr, 0);
Cudd_SetMinHit(mgr, 15);
mgr_ex=(DdManager **) realloc(mgr_ex, (ex+1)* sizeof(DdManager *));
mgr_ex[ex]=mgr;
mgr_ex[ex]=Cudd_Init(0,0,UNIQUE_SLOTS,CACHE_SLOTS,5120);
Cudd_AutodynEnable(mgr_ex[ex], CUDD_REORDER_GROUP_SIFT);
Cudd_SetMaxCacheHard(mgr_ex[ex], 0);
Cudd_SetLooseUpTo(mgr_ex[ex], 0);
Cudd_SetMinHit(mgr_ex[ex], 15);
bVar2mVar_ex=(int **) realloc(bVar2mVar_ex, (ex+1)* sizeof(int *));
bVar2mVar_ex[ex]=NULL;
bVar2mVar=bVar2mVar_ex[ex];
vars_ex=(variable **) realloc(vars_ex, (ex+1)* sizeof(variable *));
vars_ex[ex]=NULL;
vars=vars_ex[ex];
nVars_ex=(int *) realloc(nVars_ex, (ex+1)* sizeof(int ));
nVars=nVars_ex+ex;
*nVars=0;
nVars_ex[ex]=0;
probs_ex=(double **) realloc(probs_ex, (ex+1)* sizeof(double *));
probs_ex[ex]=NULL;
probs=probs_ex[ex];
boolVars_ex=(int *) realloc(boolVars_ex, (ex+1)* sizeof(int ));
boolVars=boolVars_ex+ex;
*boolVars=0;
boolVars_ex[ex]=0;
return 1;
}
@ -167,9 +155,6 @@ static int init_bdd(void)
static int end_bdd(void)
{
bVar2mVar_ex[ex]=bVar2mVar;
probs_ex[ex]=probs;
vars_ex[ex]=vars;
ex=ex+1;
return 1;
}
@ -184,33 +169,31 @@ static int init_test(void)
nRules=YAP_IntOfTerm(arg1);
mgr=Cudd_Init(0,0,UNIQUE_SLOTS,CACHE_SLOTS,0);
Cudd_AutodynEnable(mgr, CUDD_REORDER_GROUP_SIFT);
Cudd_SetMaxCacheHard(mgr, 1024*1024*1024);
Cudd_SetLooseUpTo(mgr, 1024*1024*512);
mgr_ex[ex]=Cudd_Init(0,0,UNIQUE_SLOTS,CACHE_SLOTS,0);
Cudd_AutodynEnable(mgr_ex[ex], CUDD_REORDER_GROUP_SIFT);
Cudd_SetMaxCacheHard(mgr_ex[ex], 1024*1024*1024);
Cudd_SetLooseUpTo(mgr_ex[ex], 1024*1024*512);
rules= (int *) malloc(nRules * sizeof(int));
bVar2mVar=NULL;
probs=NULL;
vars=NULL;
bVar2mVar_ex[ex]=NULL;
probs_ex[ex]=NULL;
vars_ex[ex]=NULL;
nVars=(int *) malloc(sizeof(int ));
*nVars=0;
nVars_ex[ex]=0;
boolVars=(int *) malloc(sizeof(int ));
*boolVars=0;
boolVars_ex[ex]=0;
return 1;
}
static int end_test(void)
{
free(bVar2mVar);
free(vars);
free(nVars);
free(boolVars);
Cudd_Quit(mgr);
free(probs);
free(bVar2mVar_ex[ex]);
free(vars_ex[ex]);
free(nVars_ex+ex);
free(boolVars_ex+ex);
Cudd_Quit(mgr_ex[ex]);
free(probs_ex[ex]);
free(rules);
return 1;
}
@ -226,16 +209,11 @@ static double Expectation(DdNode **nodes_ex,int lenNodes)
{
if (!Cudd_IsConstant(nodes_ex[i]))
{
mgr=mgr_ex[i];
probs=probs_ex[i];
boolVars=boolVars_ex+i;
nodesB=init_table(*boolVars);
nodesF=init_table(*boolVars);
bVar2mVar=bVar2mVar_ex[i];
vars=vars_ex[i];
nodesB=init_table(boolVars_ex[i]);
nodesF=init_table(boolVars_ex[i]);
Forward(nodes_ex[i]);
rootProb=GetOutsideExpe(nodes_ex[i],example_prob[i]);
Forward(nodes_ex[i],i);
rootProb=GetOutsideExpe(nodes_ex[i],example_prob[i],i);
if (rootProb<=0.0)
CLL = CLL + LOGZERO*example_prob[i];
@ -243,8 +221,8 @@ static double Expectation(DdNode **nodes_ex,int lenNodes)
CLL = CLL + log(rootProb)*example_prob[i];
nodes_probs_ex[i]=rootProb;
destroy_table(nodesB,*boolVars);
destroy_table(nodesF,*boolVars);
destroy_table(nodesB,boolVars_ex[i]);
destroy_table(nodesF,boolVars_ex[i]);
}
else
if (nodes_ex[i]==Cudd_ReadLogicZero(mgr_ex[i]))
@ -307,13 +285,13 @@ static int ret_prob(void)
if (!Cudd_IsConstant(node))
{
table=init_table(*boolVars);
table=init_table(boolVars_ex[ex]);
out=YAP_MkFloatTerm(Prob(node,0));
destroy_table(table,*boolVars);
destroy_table(table,boolVars_ex[ex]);
}
else
{
if (node==Cudd_ReadOne(mgr))
if (node==Cudd_ReadOne(mgr_ex[ex]))
out=YAP_MkFloatTerm(1.0);
else
out=YAP_MkFloatTerm(0.0);
@ -347,10 +325,6 @@ so that it is not recomputed
else
{
nodekey=Cudd_Regular(node);
/* if (comp)
nodekey=Cudd_Complement(nodefw);
else
nodekey=nodefw;*/
value_p=get_value(table,nodekey);
if (value_p!=NULL)
return *value_p;
@ -358,15 +332,15 @@ so that it is not recomputed
{
index=Cudd_NodeReadIndex(node); //Returns the index of the node. The node pointer can be either regular or complemented.
//The index field holds the name of the variable that labels the node. The index of a variable is a permanent attribute that reflects the order of creation.
p=probs[index];
p=probs_ex[ex][index];
T = Cudd_T(node);
F = Cudd_E(node);
pf=Prob(F,comp);
pt=Prob(T,comp);
BChild0=pf*(1-p);
BChild1=pt*p;
mVarIndex=bVar2mVar[index];
v=vars[mVarIndex];
mVarIndex=bVar2mVar_ex[ex][index];
v=vars_ex[ex][mVarIndex];
pos=index-v.firstBoolVar;
res=BChild0+BChild1;
add_node(table,nodekey,res);
@ -390,29 +364,30 @@ static int add_var(void)
arg2=YAP_ARG2;
arg3=YAP_ARG3;
arg4=YAP_ARG4;
*nVars=*nVars+1;
vars=(variable *) realloc(vars,*nVars * sizeof(variable));
v=&vars[*nVars-1];
nVars_ex[ex]=nVars_ex[ex]+1;
vars_ex[ex]=(variable *) realloc(vars_ex[ex],nVars_ex[ex] * sizeof(variable));
v=&vars_ex[ex][nVars_ex[ex]-1];
v->nVal=YAP_IntOfTerm(arg1);
v->nRule=YAP_IntOfTerm(arg3);
v->firstBoolVar=*boolVars;
probs=(double *) realloc(probs,(((*boolVars+v->nVal-1)* sizeof(double))));
bVar2mVar=(int *) realloc(bVar2mVar,((*boolVars+v->nVal-1)* sizeof(int)));
v->firstBoolVar=boolVars_ex[ex];
probs_ex[ex]=(double *) realloc(probs_ex[ex],(((boolVars_ex[ex]+v->nVal-1)* sizeof(double))));
bVar2mVar_ex[ex]=(int *) realloc(bVar2mVar_ex[ex],((boolVars_ex[ex]+v->nVal-1)* sizeof(int)));
probTerm=arg2;
p0=1;
for (i=0;i<v->nVal-1;i++)
{
node=Cudd_bddIthVar(mgr,*boolVars+i);
node=Cudd_bddIthVar(mgr_ex[ex],boolVars_ex[ex]+i);
p=YAP_FloatOfTerm(YAP_HeadOfTerm(probTerm));
bVar2mVar[*boolVars+i]=*nVars-1;
probs[*boolVars+i]=p/p0;
bVar2mVar_ex[ex][boolVars_ex[ex]+i]=nVars_ex[ex]-1;
probs_ex[ex][boolVars_ex[ex]+i]=p/p0;
probTerm_temp=YAP_TailOfTerm(probTerm);
probTerm=probTerm_temp;
p0=p0*(1-p/p0);
}
*boolVars=*boolVars+v->nVal-1;
boolVars_ex[ex]=boolVars_ex[ex]+v->nVal-1;
rules[v->nRule]= v->nVal;
out=YAP_MkIntTerm((YAP_Int)* nVars-1);
out=YAP_MkIntTerm((YAP_Int) nVars_ex[ex]-1);
return YAP_Unify(out,arg4);
}
@ -425,30 +400,30 @@ static int equality(void)
variable v;
DdNode * node, * tmp,*var;
arg1=YAP_ARG1; //var
arg2=YAP_ARG2; //value
arg3=YAP_ARG3; //node
arg1=YAP_ARG1;
arg2=YAP_ARG2;
arg3=YAP_ARG3;
varIndex=YAP_IntOfTerm(arg1);
value=YAP_IntOfTerm(arg2);
v=vars[varIndex];
v=vars_ex[ex][varIndex];
i=v.firstBoolVar;
tmp=Cudd_ReadOne(mgr);
tmp=Cudd_ReadOne(mgr_ex[ex]);
Cudd_Ref(tmp);
node=NULL;
for (i=v.firstBoolVar;i<v.firstBoolVar+value;i++)
{
var=Cudd_bddIthVar(mgr,i);
node=Cudd_bddAnd(mgr,tmp,Cudd_Not(var));
var=Cudd_bddIthVar(mgr_ex[ex],i);
node=Cudd_bddAnd(mgr_ex[ex],tmp,Cudd_Not(var));
Cudd_Ref(node);
Cudd_RecursiveDeref(mgr,tmp);
Cudd_RecursiveDeref(mgr_ex[ex],tmp);
tmp=node;
}
if (!(value==v.nVal-1))
{
var=Cudd_bddIthVar(mgr,v.firstBoolVar+value);
node=Cudd_bddAnd(mgr,tmp,var);
var=Cudd_bddIthVar(mgr_ex[ex],v.firstBoolVar+value);
node=Cudd_bddAnd(mgr_ex[ex],tmp,var);
Cudd_Ref(node);
Cudd_RecursiveDeref(mgr,tmp);
Cudd_RecursiveDeref(mgr_ex[ex],tmp);
}
out=YAP_MkIntTerm((YAP_Int) node);
return(YAP_Unify(out,arg3));
@ -460,7 +435,7 @@ static int one(void)
DdNode * node;
arg=YAP_ARG1;
node = Cudd_ReadOne(mgr);
node = Cudd_ReadOne(mgr_ex[ex]);
Cudd_Ref(node);
out=YAP_MkIntTerm((YAP_Int) node);
return(YAP_Unify(out,arg));
@ -472,7 +447,7 @@ static int zero(void)
DdNode * node;
arg=YAP_ARG1;
node = Cudd_ReadLogicZero(mgr);
node = Cudd_ReadLogicZero(mgr_ex[ex]);
Cudd_Ref(node);
out=YAP_MkIntTerm((YAP_Int) node);
return(YAP_Unify(out,arg));
@ -501,7 +476,7 @@ static int and(void)
arg3=YAP_ARG3;
node1=(DdNode *)YAP_IntOfTerm(arg1);
node2=(DdNode *)YAP_IntOfTerm(arg2);
nodeout=Cudd_bddAnd(mgr,node1,node2);
nodeout=Cudd_bddAnd(mgr_ex[ex],node1,node2);
Cudd_Ref(nodeout);
out=YAP_MkIntTerm((YAP_Int) nodeout);
return(YAP_Unify(out,arg3));
@ -517,7 +492,7 @@ static int or(void)
arg3=YAP_ARG3;
node1=(DdNode *)YAP_IntOfTerm(arg1);
node2=(DdNode *)YAP_IntOfTerm(arg2);
nodeout=Cudd_bddOr(mgr,node1,node2);
nodeout=Cudd_bddOr(mgr_ex[ex],node1,node2);
Cudd_Ref(nodeout);
out=YAP_MkIntTerm((YAP_Int) nodeout);
return(YAP_Unify(out,arg3));
@ -531,7 +506,7 @@ static int garbage_collect(void)
arg1=YAP_ARG1;
arg2=YAP_ARG2;
clearCache=YAP_IntOfTerm(arg1);
nodes=(YAP_Int)cuddGarbageCollect(mgr,clearCache);
nodes=(YAP_Int)cuddGarbageCollect(mgr_ex[ex],clearCache);
out=YAP_MkIntTerm(nodes);
return(YAP_Unify(out,arg2));
}
@ -544,7 +519,7 @@ static int bdd_to_add(void)
arg1=YAP_ARG1;
arg2=YAP_ARG2;
node1=(DdNode *)YAP_IntOfTerm(arg1);
node2= Cudd_BddToAdd(mgr,node1);
node2= Cudd_BddToAdd(mgr_ex[ex],node1);
out=YAP_MkIntTerm((YAP_Int) node2);
return(YAP_Unify(out,arg2));
}
@ -564,11 +539,11 @@ static int create_dot(void)
arg2=YAP_ARG2;
YAP_StringToBuffer(arg2,filename,1000);
inames= (char **) malloc(sizeof(char *)*(*boolVars));
inames= (char **) malloc(sizeof(char *)*(boolVars_ex[ex]));
index=0;
for (i=0;i<*nVars;i++)
for (i=0;i<nVars_ex[ex];i++)
{
v=vars[i];
v=vars_ex[ex][i];
for (b=0;b<v.nVal-1;b++)
{
inames[b+index]=(char *) malloc(sizeof(char)*20);
@ -583,12 +558,12 @@ static int create_dot(void)
}
array[0]=(DdNode *)YAP_IntOfTerm(arg1);
file = open_file(filename, "w");
Cudd_DumpDot(mgr,1,array,inames,onames,file);
Cudd_DumpDot(mgr_ex[ex],1,array,inames,onames,file);
fclose(file);
index=0;
for (i=0;i<*nVars;i++)
for (i=0;i<nVars_ex[ex];i++)
{
v=vars[i];
v=vars_ex[ex][i];
for (b=0;b<v.nVal-1;b++)
{
free(inames[b+index]);
@ -607,13 +582,13 @@ static int rec_deref(void)
arg1=YAP_ARG1;
node=(DdNode *) YAP_IntOfTerm(arg1);
Cudd_RecursiveDeref(mgr, node);
Cudd_RecursiveDeref(mgr_ex[ex], node);
return 1;
}
double ProbPath(DdNode *node,int comp_par)
double ProbPath(DdNode *node,int comp_par, int nex)
{
int index,mVarIndex,comp,pos,position,boolVarIndex;
variable v;
@ -647,42 +622,42 @@ double ProbPath(DdNode *node,int comp_par)
else
{
index=Cudd_NodeReadIndex(node);
p=probs[index];
p=probs_ex[nex][index];
T = Cudd_T(node);
F = Cudd_E(node);
pf=ProbPath(F,comp);
pt=ProbPath(T,comp);
pf=ProbPath(F,comp,nex);
pt=ProbPath(T,comp,nex);
BChild0=pf*(1-p);
BChild1=pt*p;
value_p=get_value(nodesF,nodekey);
e0 = (*value_p)*BChild0;
e1 = (*value_p)*BChild1;
mVarIndex=bVar2mVar[index];
v=vars[mVarIndex];
mVarIndex=bVar2mVar_ex[nex][index];
v=vars_ex[nex][mVarIndex];
pos=index-v.firstBoolVar;
eta_rule=eta_temp[v.nRule];
eta_rule[pos][0]=eta_rule[pos][0]+e0;
eta_rule[pos][1]=eta_rule[pos][1]+e1;
res=BChild0+BChild1;
add_node(nodesB,nodekey,res);
position=Cudd_ReadPerm(mgr,index);
position=Cudd_ReadPerm(mgr_ex[nex],index);
position=position+1;
boolVarIndex=Cudd_ReadInvPerm(mgr,position); //Returns the index of the variable currently in the i-th position of the order.
if (position<*boolVars)
boolVarIndex=Cudd_ReadInvPerm(mgr_ex[nex],position);//Returns the index of the variable currently in the i-th position of the order.
if (position<boolVars_ex[nex])
{
sigma[position]=sigma[position]+e0+e1;
}
if(!Cudd_IsConstant(T))
{
index=Cudd_NodeReadIndex(T);
position=Cudd_ReadPerm(mgr,index);
position=Cudd_ReadPerm(mgr_ex[nex],index);
sigma[position]=sigma[position]-e1;
}
if(!Cudd_IsConstant(F))
{
index=Cudd_NodeReadIndex(F);
position=Cudd_ReadPerm(mgr,index);
position=Cudd_ReadPerm(mgr_ex[nex],index);
sigma[position]=sigma[position]-e0;
}
@ -694,29 +669,29 @@ double ProbPath(DdNode *node,int comp_par)
void Forward(DdNode *root)
void Forward(DdNode *root, int nex)
{
int i,j;
if (*boolVars)
if (boolVars_ex[nex])
{
nodesToVisit= (DdNode ***)malloc(sizeof(DdNode **)* *boolVars);
NnodesToVisit= (int *)malloc(sizeof(int)* *boolVars);
nodesToVisit= (DdNode ***)malloc(sizeof(DdNode **)* boolVars_ex[nex]);
NnodesToVisit= (int *)malloc(sizeof(int)* boolVars_ex[nex]);
nodesToVisit[0]=(DdNode **)malloc(sizeof(DdNode *));
nodesToVisit[0][0]=root;
NnodesToVisit[0]=1;
for(i=1;i<*boolVars;i++)
for(i=1;i<boolVars_ex[nex];i++)
{
nodesToVisit[i]=NULL;
NnodesToVisit[i]=0;
}
add_node(nodesF,Cudd_Regular(root),1);
for(i=0;i<*boolVars;i++)
for(i=0;i<boolVars_ex[nex];i++)
{
for(j=0;j<NnodesToVisit[i];j++)
UpdateForward(nodesToVisit[i][j]);
UpdateForward(nodesToVisit[i][j],nex);
}
for(i=0;i<*boolVars;i++)
for(i=0;i<boolVars_ex[nex];i++)
{
free(nodesToVisit[i]);
}
@ -729,7 +704,7 @@ void Forward(DdNode *root)
}
}
void UpdateForward(DdNode *node)
void UpdateForward(DdNode *node, int nex)
{
int index,position,mVarIndex;
DdNode *T,*E,*nodereg;
@ -743,9 +718,9 @@ void UpdateForward(DdNode *node)
else
{
index=Cudd_NodeReadIndex(node);
mVarIndex=bVar2mVar[index];
v=vars[mVarIndex];
p=probs[index];
mVarIndex=bVar2mVar_ex[nex][index];
v=vars_ex[nex][mVarIndex];
p=probs_ex[nex][index];
nodereg=Cudd_Regular(node);
value_p=get_value(nodesF,nodereg);
if (value_p== NULL)
@ -768,7 +743,7 @@ void UpdateForward(DdNode *node)
{
add_or_replace_node(nodesF,Cudd_Regular(T),*value_p*p);
index=Cudd_NodeReadIndex(T);
position=Cudd_ReadPerm(mgr,index);
position=Cudd_ReadPerm(mgr_ex[nex],index);
nodesToVisit[position]=(DdNode **)realloc(nodesToVisit[position],
(NnodesToVisit[position]+1)* sizeof(DdNode *));
nodesToVisit[position][NnodesToVisit[position]]=T;
@ -787,7 +762,7 @@ void UpdateForward(DdNode *node)
{
add_or_replace_node(nodesF,Cudd_Regular(E),*value_p*(1-p));
index=Cudd_NodeReadIndex(E);
position=Cudd_ReadPerm(mgr,index);
position=Cudd_ReadPerm(mgr_ex[nex],index);
nodesToVisit[position]=(DdNode **)realloc(nodesToVisit[position],
(NnodesToVisit[position]+1)* sizeof(DdNode *));
nodesToVisit[position][NnodesToVisit[position]]=E;
@ -805,22 +780,22 @@ int indexMvar(DdNode * node)
int index,mVarIndex;
index=Cudd_NodeReadIndex(node);
mVarIndex=bVar2mVar[index];
mVarIndex=bVar2mVar_ex[ex][index];
return mVarIndex;
}
double GetOutsideExpe(DdNode *root,double ex_prob)
double GetOutsideExpe(DdNode *root,double ex_prob, int nex)
{
int i,j,mVarIndex,bVarIndex;
double **eta_rule;
double theta,rootProb, T=0;
sigma=(double *)malloc(*boolVars * sizeof(double));
sigma=(double *)malloc(boolVars_ex[nex] * sizeof(double));
for (j=0; j<*boolVars; j++)
for (j=0; j<boolVars_ex[nex]; j++)
{
sigma[j]=0;
}
@ -832,23 +807,23 @@ double GetOutsideExpe(DdNode *root,double ex_prob)
eta_temp[j][i][1]=0;
}
}
rootProb=ProbPath(root,0);
rootProb=ProbPath(root,0,nex);
if (rootProb>0.0)
{
for (j=0; j<*boolVars; j++)
for (j=0; j<boolVars_ex[nex]; j++)
{
T += sigma[j];
bVarIndex=Cudd_ReadInvPerm(mgr,j);
bVarIndex=Cudd_ReadInvPerm(mgr_ex[nex],j);
if (bVarIndex==-1)
{
bVarIndex=j;
}
mVarIndex=bVar2mVar[bVarIndex];
eta_rule=eta_temp[vars[mVarIndex].nRule];
for (i=0; i<vars[mVarIndex].nVal-1;i++)
mVarIndex=bVar2mVar_ex[nex][bVarIndex];
eta_rule=eta_temp[vars_ex[nex][mVarIndex].nRule];
for (i=0; i<vars_ex[nex][mVarIndex].nVal-1;i++)
{
theta=probs[bVarIndex];
theta=probs_ex[nex][bVarIndex];
eta_rule[i][0]=eta_rule[i][0]+T*(1-theta);
eta_rule[i][1]=eta_rule[i][1]+T*theta;
}
@ -891,17 +866,13 @@ void Maximization(void)
for(e=0;e<ex;e++)
{
nVars=nVars_ex+e;
probs=probs_ex[e];
vars=vars_ex[e];
for (j=0;j<*nVars;j++)
for (j=0;j<nVars_ex[e];j++)
{
r=vars[j].nRule;
r=vars_ex[e][j].nRule;
probs_rule=arrayprob[r];
for(i=0;i<rules[r]-1;i++)
{
probs[vars[j].firstBoolVar+i]=probs_rule[i];
probs_ex[e][vars_ex[e][j].firstBoolVar+i]=probs_rule[i];
}
}
}
@ -935,17 +906,14 @@ static int randomize(void)
}
for(e=0;e<ex;e++)
{
nVars=nVars_ex+e;
probs=probs_ex[e];
vars=vars_ex[e];
for (j=0; j<*nVars; j++)
for (j=0; j<nVars_ex[e]; j++)
{
rule=vars[j].nRule;
rule=vars_ex[e][j].nRule;
theta=Theta_rules[rule];
p0=1;
for (i=0; i<vars[j].nVal-1;i++)
for (i=0; i<vars_ex[e][j].nVal-1;i++)
{
probs[vars[j].firstBoolVar+i]=theta[i]/p0;
probs_ex[e][vars_ex[e][j].firstBoolVar+i]=theta[i]/p0;
p0=p0*(1-theta[i]/p0);
}
}
@ -1047,6 +1015,7 @@ static int EM(void)
return (YAP_Unify(out2,arg7));
}
static int Q(void)
{
YAP_Term arg1,arg2,arg3,arg4,out,out1,

View File

@ -0,0 +1,4 @@
type(_A,type_b):0.5.
type(_A,type_c):0.5.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,151 @@
output(type/2).
input(fibros/2).
input(activity/2).
input(sex/2).
input(action/2).
input(age/2).
input(type/2).
input(got/2).
input(gpt/2).
input(tbil/2).
input(dbil/2).
input(che/2).
input(ttt/2).
input(ztt/2).
input(tcho/2).
input(tp/2).
input(dur/2).
input(b_rel11/2).
input(b_rel12/2).
input(b_rel13/2).
modeh(*,type(+m,type_b)).
modeh(*,type(+m,type_c)).
determination(type/2,sex/2).
determination(type/2,age/2).
determination(type/2,b_rel11/2).
determination(type/2,b_rel12/2).
determination(type/2,b_rel13/2).
determination(type/2,fibros/2).
determination(type/2,activity/2).
determination(type/2,got/2).
determination(type/2,gpt/2).
determination(type/2,tbil/2).
determination(type/2,dbil/2).
determination(type/2,che/2).
determination(type/2,ttt/2).
determination(type/2,ztt/2).
determination(type/2,tcho/2).
determination(type/2,tp/2).
determination(type/2,dur/2).
modeb(*,b_rel11(-b,+m)).
modeb(*,b_rel12(-i,+m)).
modeb(*,b_rel13(-a,+m)).
modeb(*,b_rel11(+b,-m)).
modeb(*,b_rel12(+i,-m)).
modeb(*,b_rel13(+a,-m)).
modeb(*,fibros(+b,fibros_0)).
modeb(*,fibros(+b,fibros_1)).
modeb(*,fibros(+b,fibros_2)).
modeb(*,fibros(+b,fibros_3)).
modeb(*,fibros(+b,fibros_4)).
modeb(*,activity(+b,activity_0)).
modeb(*,activity(+b,activity_1)).
modeb(*,activity(+b,activity_2)).
modeb(*,activity(+b,activity_3)).
modeb(*,activity(+b,activity_false)).
modeb(*,sex(+m,sex_f)).
modeb(*,sex(+m,sex_m)).
modeb(*,age(+m,age_0)).
modeb(*,age(+m,age_1)).
modeb(*,age(+m,age_2)).
modeb(*,age(+m,age_3)).
modeb(*,age(+m,age_4)).
modeb(*,age(+m,age_5)).
modeb(*,age(+m,age_6)).
modeb(*,got(+i,got_1)).
modeb(*,got(+i,got_2)).
modeb(*,got(+i,got_3)).
modeb(*,got(+i,got_4)).
modeb(*,got(+i,got_5)).
modeb(*,gpt(+i,gpt_1)).
modeb(*,gpt(+i,gpt_2)).
modeb(*,gpt(+i,gpt_3)).
modeb(*,gpt(+i,gpt_4)).
modeb(*,tbil(+i,tbil_1)).
modeb(*,tbil(+i,tbil_2)).
modeb(*,dbil(+i,dbil_1)).
modeb(*,dbil(+i,dbil_2)).
modeb(*,che(+i,che_1)).
modeb(*,che(+i,che_2)).
modeb(*,che(+i,che_3)).
modeb(*,che(+i,che_4)).
modeb(*,che(+i,che_5)).
modeb(*,che(+i,che_6)).
modeb(*,che(+i,che_7)).
modeb(*,che(+i,che_8)).
modeb(*,che(+i,che_9)).
modeb(*,che(+i,che_10)).
modeb(*,ttt(+i,ttt_1)).
modeb(*,ttt(+i,ttt_2)).
modeb(*,ttt(+i,ttt_3)).
modeb(*,ttt(+i,ttt_4)).
modeb(*,ttt(+i,ttt_5)).
modeb(*,ttt(+i,ttt_6)).
modeb(*,ztt(+i,ztt_1)).
modeb(*,ztt(+i,ztt_2)).
modeb(*,ztt(+i,ztt_3)).
modeb(*,ztt(+i,ztt_4)).
modeb(*,ztt(+i,ztt_5)).
modeb(*,ztt(+i,ztt_6)).
modeb(*,tcho(+i,tcho_1)).
modeb(*,tcho(+i,tcho_2)).
modeb(*,tcho(+i,tcho_3)).
modeb(*,tcho(+i,tcho_4)).
modeb(*,tp(+i,tp_1)).
modeb(*,tp(+i,tp_2)).
modeb(*,tp(+i,tp_3)).
modeb(*,tp(+i,tp_4)).
modeb(*,dur(+a,dur_0)).
modeb(*,dur(+a,dur_1)).
modeb(*,dur(+a,dur_2)).
modeb(*,dur(+a,dur_3)).
modeb(*,dur(+a,dur_4)).
modeb(*,fibros(+b,-f)).
modeb(*,activity(+b,-a)).
modeb(*,sex(+m,-sex)).
modeb(*,age(+m,-age)).
modeb(*,got(+i,-got)).
modeb(*,gpt(+i,-gpt)).
modeb(*,tbil(+i,-tbil)).
modeb(*,dbil(+i,-dbil)).
modeb(*,che(+i,-che)).
modeb(*,ttt(+i,-ttt)).
modeb(*,ztt(+i,-ztt)).
modeb(*,tcho(+i,-tcho)).
modeb(*,tp(+i,-tp)).
modeb(*,dur(+a,dur)).
lookahead(b_rel11(A,_),[fibros(A,_)]).
lookahead(b_rel11(A,_),[activity(A,_)]).
lookahead(b_rel12(A,_),[got(A,_)]).
lookahead(b_rel11(A,_B),[gpt(A,_)]).
lookahead(b_rel11(A,_B),[tbil(A,_)]).
lookahead(b_rel11(A,_B),[dbil(A,_)]).
lookahead(b_rel11(A,_B),[che(A,_)]).
lookahead(b_rel11(A,_B),[ttt(A,_)]).
lookahead(b_rel11(A,_B),[ztt(A,_)]).
lookahead(b_rel11(A,_B),[tcho(A,_)]).
lookahead(b_rel11(A,_B),[tp(A,_)]).
lookahead(b_rel13(A,_B),[dur(A,_)]).

View File

@ -0,0 +1,40 @@
/* SLIPCASE Final CLL -2.525186
Execution time 45.693000
setting(epsilon_em,0.0001).
setting(epsilon_em_fraction,1.0e-5).
setting(eps,0.0001).
setting(eps_f,1.0e-5).
setting(epsilon_sem,2).
setting(random_restarts_REFnumber,1).
setting(random_restarts_number,1).
setting(iterREF,-1).
setting(iter,-1).
setting(examples,atoms).
setting(group,1).
setting(d,1).
setting(verbosity,1).
setting(logzero,log(1.0e-6)).
setting(initial_clauses_modeh,1).
setting(max_iter,10).
setting(max_var,5).
setting(max_rules,10).
setting(beamsize,20).
setting(epsilon_parsing,1.0e-10).
setting(tabling,off).
setting(bagof,false).
setting(depth_bound,false).
setting(depth,2).
setting(single_var,false).
setting(compiling,off).
*/
type(A,type_b):0.215232.
type(A,type_c):0.513334 :-
b_rel11(B,A),
fibros(B,C),
b_rel11(D,A),
fibros(B,E).
type(A,type_b):0.257763.