From 670f6ea0f6fc030fd066257ff807ec54631124dc Mon Sep 17 00:00:00 2001 From: Viktor Richter Date: Fri, 20 Nov 2015 11:26:28 +0100 Subject: [PATCH 1/2] Add a BayesNetwork proto description. This description can reproduce networks in XMLBIF Format. --- proto/sandbox/rst/graph/BayesNetwork.proto | 49 +++++++++++++++++ proto/sandbox/rst/graph/BayesVariable.proto | 85 +++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100755 proto/sandbox/rst/graph/BayesNetwork.proto create mode 100755 proto/sandbox/rst/graph/BayesVariable.proto diff --git a/proto/sandbox/rst/graph/BayesNetwork.proto b/proto/sandbox/rst/graph/BayesNetwork.proto new file mode 100755 index 0000000..ba0f3e1 --- /dev/null +++ b/proto/sandbox/rst/graph/BayesNetwork.proto @@ -0,0 +1,49 @@ +package rst.graph; + +import "rst/graph/BayesVariable.proto"; + +option java_outer_classname = "BayesNetworkType"; + +/** + * The BayesNetwork message holds the description of a bayesian network + * following the XMLBIF Format: + * + * + * + * + * + * + * + * + * + * + * + * + * + * ]> + * + * See: http://www.cs.cmu.edu/afs/cs/user/fgcozman/www/Research/InterchangeFormat/ + * + * @author Viktor Richter + */ +message BayesNetwork { + + /** + * The name of this BayesNetwork + */ + optional string name = 1; + + /** + * Arbitrary properties associated with the network. + */ + repeated string property = 2; + + /** + * List of the BayesVariables describing the nodes of the network in + * combination with theyr connectivity and conditional probability + * distribution. + */ + repeated BayesVariable variable = 3; + +} diff --git a/proto/sandbox/rst/graph/BayesVariable.proto b/proto/sandbox/rst/graph/BayesVariable.proto new file mode 100755 index 0000000..d0420c7 --- /dev/null +++ b/proto/sandbox/rst/graph/BayesVariable.proto @@ -0,0 +1,85 @@ +package rst.graph; + +option java_outer_classname = "BayesVariableType"; + +/** + * BayesVariable used in a BayesNetwork. + * Describes a variable with its possible outcomes. + * + * @author Viktor Richter + */ +message BayesVariable { + + /** + * Enum describing the type of a BayesVariable. + */ + enum Type { + + /** + * A Simple Variable in the BayesNetwork representing a world state. + */ + NATURE = 1; + + /** + * Represents an action to choose from. + */ + DECISION = 2; + + /** + * Represents the quality or benefit of a decision. + */ + UTILITY = 3; + } + + /** + * The name of the Variable. This has to be unique in a bayes Network. + */ + optional string name = 1; + + /** + * The Type of the Variable. + */ + optional Type type = 2; + + /** + * The possible outcomes (states) of the variables. + */ + repeated string outcomes = 3; + + /** + * Arbitrary properties associated with the variable. + */ + repeated string property = 4; + + /** + * The variables on which state this BayesVariable depends. + */ + repeated string parents = 5; + + /** + * The conditional probability table describing the probability + * of each outcome of this variable for each combination of the + * parents states. + * + * The cpt holds the probability values for the variable outcomes + * in the order \f$ v_1, \dots, v_n, v_0 \f$ with the value + * permutation from right to left. + * + * \verbatim + * An example with three binary variables would look the following way: + * + * | parent1 | parent2 | variable | position in table | + * ---------------------------------------------------- + * | 0 | 0 | 0 | 0 | + * | 0 | 0 | 1 | 1 | + * | 0 | 1 | 0 | 2 | + * | 0 | 1 | 1 | 3 | + * | 1 | 0 | 0 | 4 | + * | 1 | 0 | 1 | 5 | + * | 1 | 1 | 0 | 6 | + * | 1 | 1 | 1 | 7 | + * \endverbatim + */ + repeated double probabilities = 6; + +} -- 1.9.1