Top Level Namespace

Includes:
REXML, RGL

Defined Under Namespace

Modules: Bn4r Classes: BNTPGFromPositiveNegativeRelations, BayesNet, BayesNetNode, BnTableProbabilitiesGenerator

Instance Method Summary collapse

Instance Method Details

#generate_boolean_combinations(num) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/bn4r/bn_table_probabilities.rb', line 66

def generate_boolean_combinations(num)
    boolean_combinations = []
    (2**num).times { |i|
      boolean_combination = Array.new(num, false)
      actual_value = i
      (num).times { |j|
        boolean_combination[j] = !(actual_value%2 == 1)
        actual_value = actual_value / 2
      }
      boolean_combinations << boolean_combination.reverse
    }
  boolean_combinations
end

#generate_combinations(nodes) ⇒ Object



80
81
82
83
84
85
86
87
88
# File 'lib/bn4r/bn_table_probabilities.rb', line 80

def generate_combinations(nodes)
  # Selecting nodes whith outcomes diferents from true, false.
  nodes_notbinaries = nodes.select {|node| !(node.outcomes - [true,false]).empty? }

  #TODO: Implement combinations for nodes with outcomes different from [true,false]
  raise "Function still not implemented ( parents with outcomes different from [true,false] )" \
     if !nodes_notbinaries.empty?
  generate_boolean_combinations(nodes.size)
end