• No se han encontrado resultados

Comparación de los precios de venta del kilo de flor en los principales mercados

We tested the effects of our approach on 3 benchmark sets of cProbLog programs. Each of these sets contains two different types of programs corresponding to the best and the worst case scenarios for our algorithm. The benchmarks encode probabilistic graphs similar to the “Grid” benchmark (see Chapter 2).

0.5::edge(n_1_1, n_2_1). 0.5::edge(n_2_1, n_3_1). 0.5::edge(n_2_2, n_3_2). 0.5::edge(n_3_2, n_3_3). 0.5::edge(n_3_1, n_3_2). 0.5::edge(n_2_1, n_2_2). 0.5::edge(n_1_1, n_2_2). 0.5::edge(n_2_2, n_3_3). 0.5::edge(n_1_1, n_2_1). 0.5::edge(n_2_1, n_3_1). 0.5::edge(n_2_2, n_3_2). 0.5::edge(n_3_2, n_3_3). 0.5::edge(n_3_1, n_3_2). 0.5::edge(n_2_1, n_2_2). 0.5::edge(n_1_1, n_2_2). 0.5::edge(n_2_1, n_3_2). 0.5::edge(n_2_2, n_3_3). 0.5::edge(n_1_1, n_2_1). 0.5::edge(n_2_1, n_3_1). 0.5::edge(n_1_2, n_2_2). 0.5::edge(n_2_2, n_3_2). 0.5::edge(n_1_3, n_2_3). 0.5::edge(n_2_3, n_3_3). 0.5::edge(n_1_1, n_1_2). 0.5::edge(n_1_2, n_1_3). 0.5::edge(n_2_1, n_2_2). 0.5::edge(n_2_2, n_2_3). 0.5::edge(n_3_1, n_3_2). 0.5::edge(n_3_2, n_3_3). 0.5::edge(n_1_1, n_2_2). 0.5::edge(n_1_2, n_2_3). 0.5::edge(n_2_1, n_3_2). 0.5::edge(n_2_2, n_3_3). a. b. c.

Figure 4.6: Probabilistic graphs encoded as ProbLog programs to use for experimenting with the optimization for independent atoms; m = 3.

Grid 1 A rooted directed acyclic graph (DAG) with nodes {nx,y : x = 1, .., m, y =

1, .., m, y ≤ x}, with m = 3, .., 25. Edges connect node nx,y to nx+1,y and

to nx,y+1; also node nx,x to nx+1,x+1. Figure 4.6.a shows such a graph

encoded as a ProbLog program. There are 23 programs in a benchmark set – one for each value of m.

Grid 2 A rooted directed acyclic graph (DAG) with nodes {nx,y : x = 1, .., m, y =

1, .., m, y ≤ x}, with m = 3, .., 25. Edges connect node nx,y to nx+1,y, to

nx,y+1 and to nx+1,y+1. Figure 4.6.b shows such a graph encoded as a

ProbLog program. There are 23 programs in a benchmark set – one for each value of m.

Grid 3 A rooted directed acyclic graph (DAG) with nodes {nx,y : x = 1, .., m, y =

1, .., m}, with m = 3, .., 25. Edges connect node nx,y to nx+1,y, to nx,y+1

and to nx+1,y+1. Figure 4.6.c shows such a graph encoded as a ProbLog

program. There are 23 programs in a benchmark set – one for each value of m.

For each benchmark we use the following set of rules, also referred to as background knowledge (BK):

path(A, B):- edge(A, B).

path(A, B):- edge(A, A1), path(A1, B).

and a query which looks for the path between node n1,1 and nk,k, where

The data in our benchmarks form grids, as illustrated in Figure 4.7. 1, 1 1, 2 2, 1 2, 2 1, 3 2, 3 3, 2 3, 3 3, 1

Figure 4.7: A grid representing the data encoded by the benchmark programs used in the experiments. The fine dotted edges represent a “Grid 1” benchmark of 3×3 nodes (see Figure 4.6 a)); the fine dotted edges together with the dashed edge represent a “Grid 2” benchmark of 3 × 3 nodes (see Figure 4.6 b)); and the whole grid represents a “Grid 3” benchmark of 3 × 3 nodes (see Figure 4.6 c)). For each benchmark program we generate two separate cProbLog programs with the following:

Existential:

constraint(exists XY of domain_XY : XY = X/Y and edge(X, Y)). Universal:

constraint(for_all XY of domain_XY : XY = X/Y and edge(X, Y)). We use one variable, namely XY that unifies with a pair X/Y and the predicate

domain_XY to enumerate the values of all such pairs. These are all pairs of

nodes in the given program between which an edge exists. When grounded the first constraint will generate a disjunction of all edges; the second will generate a conjunction which can be simplified according to our method. The first constraint is the worst case for our approach. It requires to search through the subgraph associated with the constraint and will not detect anything. The second constraint is the best case scenario, where we remove all nodes and edge from the graph that do not originate from the ground LP.

We ran cProbLog using the c2d compiler and a timeout of 540.0 seconds on each benchmark program. We ran each program 5 times and like for other experiments, we consider the average of the following measurements: (i) total run time; (ii) number of CNF variables; (iii) number of CNF clauses; (iv) number of sd-DNNF nodes and (v) number of sd-DNNF edges. We managed to run with at least one of the settings (optimized or non-optimized): all 25 benchmark programs with both existentially and universally quantified constraints for Grid 1; 23 of the programs with existentially quantified constraints and the

25 programs with universally quantified constraints for Grid 2; and 19 of the programs with existentially quantified constraints and the 25 programs with universally quantified constraints for Grid 3. Our results are summarized in Figure 4.8 and Figure 4.9. Each line in a diagram presents the ratio between a measurement when the optimization is enabled and when it is disabled. E.g.,

let’s denote with Ttotthe total time when no optimization is used and with Ttot+

the total time when the optimization is used; the value we draw is t = Ttot+

Ttot ;

when t < 1 then cProbLog with our optimization outperform cProbLog with no optimization. The value of these ratios is given on the y−axis in logarithmic scale; on the x−axis we enumerate the cProbLog programs in an incremental order according to the AND-OR graph size.

The diagrams show that: (i) for programs containing constraints with universally quantified variables that are grounded to a conjunction of atoms, our optimization reduces the total run, the CNF variables and clauses and the sd-DNNF nodes and edges; (ii) for existentially quantified constraints that are grounded to disjunctions of atoms and no optimization can be performed, our algorithms do not increase the run time noticeably. Hence, we can state that constraint optimization by removing independent atoms from conjunctions should be performed by default during cProbLog inference.

The benchmarks we used are the two extreme cases – when nothing can be compacted or when the whole subgraph that originates from the constraints (but not from the query) can be compacted. In practice a “standard” benchmark will not comply with this conditions. Since the time for detection in the cases when nothing is compacted is insignificant (see Figure 4.9) we are sure that applying our constraint compaction method for all types of cProbLog programs could only be beneficial.

Documento similar