• No se han encontrado resultados

CAPÍTULO II. PROYECTO DE INNOVACIÓN EN LA DOCENCIA UNIVERSITARIA

6. DESCRIPCIÓN DE LA PROPUESTA DE INNOVACIÓN

6.3 MATERIALES DE ENSEÑANZA-APRENDIZAJE DE LA SECUENCIA INNOVADORA TR3

For knowledge compilation to sd-DNNF the compacted AND-OR graph needs to be translated into a Boolean formula in CNF. There are some complications that relate to this translation. Another issue relates to the number of edges of the compacted AND-OR graph as compared to the unprocessed graph: our patterns ensure a decrease of the number of nodes of the AND-OR graph (see Table 3.1) but they may, in some cases, introduce more edges. In this section we discuss these limitations and how to overcome them.

Translation between AND-OR graphs and Boolean formulae in CNF: Each edge in an AND-OR graph states the dependency between a parent

and a child node. I.e., an OR node A with children B1 to Bn corresponds

to A ⇔ Wn

i=1Bi7; an AND node A with children B1 to Bn corresponds to

A ⇔Vn

i=1Bi

Such subformulae are easy to rewrite in CNF as shown in Figure 3.6

7If the AND-OR graph represents a ground logic program correctness of the equivalence is

Exploiting this form of the CNF subformulae allows the translation between an AND-OR graph and a Boolean formula and vice versa without increasing the size of either of them. If a CNF does not contain subformulae that belong to the aforementioned type the translation of a CNF to AND-OR graph is as follows: for each disjunction (i) a new OR node is created in the AND-OR graph and the disjuncts are added as child nodes; and (ii) an AND node is created in the AND-OR graph and all OR nodes associated with a disjunction are added as child nodes to the AND node. This transformation is similar to the translation of CNF to BDD definitions, discussed in Chapter 2. It may increase the size of the AND-OR graph substantially. If our algorithm does not detect enough clusters to compact then the translation of the graph back to CNF may result in a larger CNF than the initial one. This issue is illustrated in Example 3.3. Example 3.3. Recall the CNF from Example 2.13 in Chapter 2:

CNF: (¬p(b, d) ∨ e(b, d) ∨ a0) ∧ (p(b, d) ∨ ¬e(b, d)) ∧ (p(b, d) ∨ ¬a0)∧

(a0 ∨ ¬e(b, c) ∨ ¬p(c, d)) ∧ (¬a0 ∨ ebc) ∧ (¬a0 ∨ pcd)∧

(pcd∨ ¬ecd) ∧ (¬pcd∨ ecd)

using the transformations in Figure 3.6 we can build the following AND-OR graph: AND p(b,d) p(c,d) AND e(b,c) e(b,d) e(c,d)

If we decide to ignore the structure of the CNF and not use the transformations in Figure 3.6 then the corresponding AND-OR graph is:

AND

OR1

OR2 OR3 OR5 OR4 OR6 OR7 OR8

(dashed edges denote negation). 4

Rule-based conversion: Chapter 2 presents two approaches for Boolean

formula conversion. Namely, the proof-based approach which is used in our compaction experiments and the rule-based. The rule-based approach generates CNF formulae which (i) do not always comply with the aforementioned subformulae type and (ii) contain a lot of negation. Given (i), the AND-OR graph for post or both compaction may be substantially large. Our compaction doesn’t handle AND or OR clusters over negated literals – they are excluded from the literals which form the cluster. Given (ii), our compaction then cannot ensure that all possible AND or OR clusters are compacted. That is why we do

not employ compaction for pipelines using the rule-based conversion8.

The effect of Branch I patterns compaction on compilation with

Dsharp: Branch I pattern involves a node A depending on an OR node

B such that B depends only on an AND node C. That is, B is an intermediate

node connecting A and C. Removing B and connecting directly C to A is how this pattern is compacted. If A is an AND node then C is also removed and the children nodes of C are connected to A. Assume that there are multiple AND

nodes A1to An that are parents to the node B. The compaction of this pattern

will contain edges to connect each node Ai, for i ∈ {1, .., n}, with the children

of C. Let C has m children, then the graph will contain two nodes less, namely

B and C and (n − 1) × m − 1 edges more. We illustrate this in Example 3.4.

Example 3.4. A fragment of the AND-OR graph associated with the relevant

ground program of benchmark from the “Balls” set contains a Branch I pattern:

{ ad1_1_green(0,1,0) ; 0.429 } { ad1_0_red(0,1,0) ; 0.3 } { ad3_0_red(1,0,0) ; 0.3 } { ad3_1_green(1,0,0) ; 0.429 } ... AND AND green(0,1,0) ... AND ... AND

Applying the compaction transformation results in:

8We implemented and ran preliminary tests on pipelines with the rule-based Boolean

{ ad1_1_green(0,1,0) ; 0.429 } { ad1_0_red(0,1,0) ; 0.3 } { ad3_0_red(1,0,0) ; 0.3 } { ad3_1_green(1,0,0) ; 0.429 } ... AND ... AND ... AND

We see that now the number of incoming connections to each AND node has

increased. 4

CNFs generated from such AND-OR graphs contain more clauses and some clauses may contain more literals, compared to a CNF generated from an AND-OR graph without the Branch I pattern compaction; a BDD script generated from such a graph will contain less BDD definitions, some of which may have more literals in their bodies and we do not notice negative effects on knowledge compilation to ROBDDs. The search approach employed by the Dsharp compiler often can benefit from additional information in the CNF, e.g., constraints. Since applying compaction for Branch I patterns removes such information, pipelines that use knowledge compilation with Dsharp and employ compaction do not perform well for problems that produce such patterns. Although removing some clauses by applying Branch I pattern compaction decreases the performance of Dsharp it does not have such an effect on the c2d compiler. c2d implements different optimizations aiming at more efficient sd- DNNFs while Dsharp aims at efficient knowledge compilation but the resulting sd-DNNFs cannot be evaluated efficiently.

We detected Branch I patterns in 5 out of the 7 benchmark sets running ProbLog2-based pipelines and in all 7 benchmark sets for MetaProbLog-based pipelines (see Appendix C). Figure 3.7 shows the number of programs for which knowledge compilation performs better when compaction ({prior, post, both}) is enabled than when no compaction is used for the “Balls” benchmark set. This benchmark set includes a lot of Branch I patterns. The results are drawn according to the measurement presented in Figure 3.4.

To show that compaction without the Branch I pattern improves Dsharp compilation we experimented on the “Balls” benchmark set after disabling detecting and compacting this pattern. The results are presented in Figure 3.8. Figure 3.8 shows that using compaction without Branch I pattern improves inference for up to 99% of the programs.

a. MetaProbLog-based b. ProbLog2-based c. Average for

pipelines pipelines all pipelines

Figure 3.7: Relative number of programs for which knowledge compilation performs best with the different compaction settings for the “Balls” benchmark set. Detecting and compacting Branch I pattern is enabled.

a. MetaProbLog-based b. ProbLog2-based c. Average for

pipelines pipelines all pipelines

Figure 3.8: Relative number of programs for which knowledge compilation performs best with the different compaction settings for the “Balls” benchmark set. Detecting and compacting Branch I pattern is disabled.