Project

General

Profile

Statistics
| Branch: | Revision:

cool / src / lib / GMLMIP-0.1 / rules / setofconclusions.c @ 7c4d2eb4

History | View | Annotate | Download (1.05 KB)

1
#include "setofconclusions.h"
2

    
3
SetOfConclusions::SetOfConclusions(int n, const vector<vector<bool> >& set){
4
        no_of_literals=n;
5
        
6
        /* To limitate code change the new type given in (vector<unsigned int>) is converted to the old type vector<vector<TruthAssignment>>
7
                 Each unsigned int corresponds to a rule instance (a node of the tree). Each node is a set of truth assignments. */
8
        int limit = 1 << n;
9
        for(unsigned int i=0; i <        set.size(); i++){
10
                vector<bool> node = set[i];
11
                vector<TruthAssignment> rule;
12
                for(int j=0; j < limit; j++){
13
                        if(node[j])
14
                                rule.push_back(TruthAssignment(j,n));
15
                }                
16
                rules.push_back(rule);
17
        }
18
}
19

    
20
bdd SetOfConclusions::get_jth_conclusion(bdd** underlying, int j){
21
        bdd b = bdd_false();
22
        for(unsigned int i=0; i < rules[j].size(); i++){
23
                bdd clause = bdd_true();
24
                for(int k=0; k < no_of_literals; k++){
25
                        if(rules[j][i].get_p_i(k)==1)
26
                                clause = bdd_and(clause, *(underlying[k]));
27
                        if(rules[j][i].get_p_i(k)==0)
28
                                clause = bdd_and(clause, bdd_not(*(underlying[k])));
29
                }
30
                b = bdd_or(clause, b);
31
                   
32
        }
33
        return b;
34
}
35