0001-Add-a-BayesNetwork-proto-description.patch

BayesNetwork and BayesVariable - V. Richter, 11/20/2015 12:12 PM

Download (4.82 KB)

View differences:

proto/sandbox/rst/graph/BayesNetwork.proto
1
package rst.graph;
2

  
3
import "rst/graph/BayesVariable.proto";
4

  
5
option java_outer_classname = "BayesNetworkType";
6

  
7
/**
8
 * The BayesNetwork message holds the description of a bayesian network
9
 * following the XMLBIF Format:
10
 *
11
 *   <!DOCTYPE BIF [
12
 *     <!ELEMENT BIF ( NETWORK )*>
13
 *       <!ATTLIST BIF VERSION CDATA #REQUIRED>
14
 *     <!ELEMENT NETWORK ( NAME, ( PROPERTY | VARIABLE | DEFINITION )* )>
15
 *     <!ELEMENT NAME (#PCDATA)>
16
 *     <!ELEMENT VARIABLE ( NAME, ( OUTCOME |  PROPERTY )* ) >
17
 *       <!ATTLIST VARIABLE TYPE (nature|decision|utility) "nature">
18
 *     <!ELEMENT OUTCOME (#PCDATA)>
19
 *     <!ELEMENT DEFINITION ( FOR | GIVEN | TABLE | PROPERTY )* >
20
 *     <!ELEMENT FOR (#PCDATA)>
21
 *     <!ELEMENT GIVEN (#PCDATA)>
22
 *     <!ELEMENT TABLE (#PCDATA)>
23
 *     <!ELEMENT PROPERTY (#PCDATA)>
24
 *     ]>
25
 *
26
 * See: http://www.cs.cmu.edu/afs/cs/user/fgcozman/www/Research/InterchangeFormat/
27
 *
28
 * @author Viktor Richter <vrichter@techfak.uni-bielefeld.de>
29
 */
30
message BayesNetwork {
31

  
32
    /**
33
     * The name of this BayesNetwork
34
     */
35
    optional string name = 1;
36

  
37
    /**
38
     * Arbitrary properties associated with the network.
39
     */
40
    repeated string property = 2;
41

  
42
    /**
43
     * List of the BayesVariables describing the nodes of the network in
44
     * combination with theyr connectivity and conditional probability
45
     * distribution.
46
     */
47
    repeated BayesVariable variable = 3;
48

  
49
}
proto/sandbox/rst/graph/BayesVariable.proto
1
package rst.graph;
2

  
3
option java_outer_classname = "BayesVariableType";
4

  
5
/**
6
 * BayesVariable used in a BayesNetwork.
7
 * Describes a variable with its possible outcomes.
8
 *
9
 * @author Viktor Richter <vrichter@techfak.uni-bielefeld.de>
10
 */
11
message BayesVariable {
12

  
13
    /**
14
     * Enum describing the type of a BayesVariable.
15
     */
16
    enum Type {
17

  
18
        /**
19
         * A Simple Variable in the BayesNetwork representing a world state.
20
         */
21
        NATURE = 1;
22

  
23
        /**
24
         * Represents an action to choose from.
25
         */
26
        DECISION = 2;
27

  
28
        /**
29
         * Represents the quality or benefit of a decision.
30
         */
31
        UTILITY = 3;
32
    }
33

  
34
    /**
35
     * The name of the Variable. This has to be unique in a bayes Network.
36
     */
37
    optional string name = 1;
38

  
39
    /**
40
     * The Type of the Variable.
41
     */
42
    optional Type type = 2;
43

  
44
    /**
45
     * The possible outcomes (states) of the variables.
46
     */
47
    repeated string outcomes = 3;
48

  
49
    /**
50
     * Arbitrary properties associated with the variable.
51
     */
52
    repeated string property = 4;
53

  
54
    /**
55
     * The variables on which state this BayesVariable depends.
56
     */
57
    repeated string parents = 5;
58

  
59
    /**
60
     * The conditional probability table describing the probability
61
     * of each outcome of this variable for each combination of the
62
     * parents states.
63
     *
64
     * The cpt holds the probability values for the variable outcomes
65
     * in the order \f$ v_1, \dots, v_n, v_0 \f$ with the value
66
     * permutation from right to left.
67
     *
68
     * \verbatim
69
     *  An example with three binary variables would look the following way:
70
     *
71
     *  | parent1 | parent2 | variable | position in table |
72
     *  ----------------------------------------------------
73
     *  |    0    |    0    |     0    |         0         |
74
     *  |    0    |    0    |     1    |         1         |
75
     *  |    0    |    1    |     0    |         2         |
76
     *  |    0    |    1    |     1    |         3         |
77
     *  |    1    |    0    |     0    |         4         |
78
     *  |    1    |    0    |     1    |         5         |
79
     *  |    1    |    1    |     0    |         6         |
80
     *  |    1    |    1    |     1    |         7         |
81
     *  \endverbatim
82
     */
83
    repeated double probabilities = 6;
84

  
85
}
0
-