raiseException("The list which should define the ordering of the variables does not match"
" the variables that this cpt depends on (plus the node itself)")
ifnotself.table.ndim==table.ndim:
raiseException("The provided probability table does not have the right number of dimensions")
ford,nodeinenumerate(nodes):
iflen(node.value_range)!=table.shape[d]:
raiseException("The size of the provided probability table does not match the number of possible values of the node "+node.name+" in dimension "+str(d))
self.table=table
self.variables=nodes
defset_utility(self,value,node_value_pairs):
index=self.get_ut_index(node_value_pairs)
self.table[index]=value
defget_utility_table(self):
returnself.table
defget_variables(self):
returnself.variables
defget_utility(self,node_value_pairs):
index=self.get_ut_index(node_value_pairs)
returnself.table[index]
def__str__(self):
returnstr(self.table)
classMakeDecision(object):
classMakeDecision(object):
"""
"""
...
@@ -65,7 +124,7 @@ class MakeDecision(object):
...
@@ -65,7 +124,7 @@ class MakeDecision(object):
#Check if the Decision Nodes that are ordered before the provided Decision Node have a state
#Check if the Decision Nodes that are ordered before the provided Decision Node have a state
fornodeinpartialOrder:
fornodeinpartialOrder:
ifisinstance(node,DecisionNode):
ifisinstance(node,primo.nodes.DecisionNode):
ifnotdecisionNode.name==node.name:
ifnotdecisionNode.name==node.name:
ifnode.get_state()isNone:
ifnode.get_state()isNone:
raiseException("Decision Nodes that are ordered before the provided Decision Node must have a state!")
raiseException("Decision Nodes that are ordered before the provided Decision Node must have a state!")