Class: Java::NorsysNetica::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/webget_netica/node.rb

Constant Summary collapse

NODE_KINDS =
{
 Java::NorsysNetica::Node::NATURE_NODE => :nature,
 Java::NorsysNetica::Node::DECISION_NODE => :decision,
 Java::NorsysNetica::Node::UTILITY_NODE => :utility,
 Java::NorsysNetica::Node::CONSTANT_NODE => :constant,
 Java::NorsysNetica::Node::DISCONNECTED_NODE => :disconnected,
}
NODE_TYPES =
{
 Java::NorsysNetica::Node::DISCRETE_TYPE => :nature,
 Java::NorsysNetica::Node::CONTINUOUS_TYPE => :decision,
}

Instance Method Summary collapse

Instance Method Details

#freeObject



60
61
62
63
64
65
66
67
# File 'lib/webget_netica/node.rb', line 60

def free()
  begin
    finalize()
    delete()
    states.each{|s| s==nil or s.free() }
  rescue Java::NorsysNetica::NeticaException
  end
end

#getKindSymObject



16
17
18
# File 'lib/webget_netica/node.rb', line 16

def getKindSym()
 return NODE_KINDS[getKind()]
end

#getTypeSymObject



20
21
22
# File 'lib/webget_netica/node.rb', line 20

def getTypeSym()
 return NODE_TYPES[getType()]
end

#pretty_print(q) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/webget_netica/node.rb', line 38

def pretty_print(q)
  q.group(1) {
    q.text "Node"
    q.breakable
    q.text "Name:#{getName()}"
    q.comma_breakable
    q.text "Kind:#{getKindSym()}"
    q.comma_breakable
    q.text "Type:#{getTypeSym()}"
    q.comma_breakable
    q.text "BeliefUpdated:#{isBeliefUpdated()}"
    q.comma_breakable
    q.text "Deterministic:#{isDeterministic()}"
    q.text "NumStates:#{getNumStates}"
    q.comma_breakable
  }
end

#state_belief_inspectObject



69
70
71
72
73
74
75
# File 'lib/webget_netica/node.rb', line 69

def state_belief_inspect
  states.map{|state|
   k = state.getName()
   v = getBelief(k)
    "#{k}:#{v.round_to(0.01)}"
  }.join(",")
end

#statesObject



56
57
58
# File 'lib/webget_netica/node.rb', line 56

def states()
  return (0...getNumStates()).map{|i| state(i) }
end

#to_sObject



24
25
26
27
28
29
30
31
32
# File 'lib/webget_netica/node.rb', line 24

def to_s
 "Node" +
    " Name:#{getName()}" +
    " Kind:#{getKindSym()}" +
    " Type:#{getTypeSym()}" +
    " BeliefUpdated:#{isBeliefUpdated()}" +
    " Deterministic:#{isDeterministic()}" +
    " NumStates:#{getNumStates}" 
end

#to_ssObject



34
35
36
# File 'lib/webget_netica/node.rb', line 34

def to_ss
  to_s + "\n" + states.map{|s| s.to_ss}.join("\n") 
end