Changeset 2374


Ignore:
Timestamp:
Feb 19, 2010 4:29:33 PM (9 years ago)
Author:
jwatson
Message:

Added code to re-normalize node conditional probabilities following scenario tree compression, and to re-compute scenario absolute probabilities.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pysp/trunk/coopr/pysp/scenariotree.py

    r2365 r2374  
    428428      for tree_node in tree_nodes_to_delete:
    429429         self._tree_nodes.remove(tree_node)
     430
     431
     432      # re-normalize the conditional probabilities of the
     433      # children at each tree node.
     434      for tree_node in self._tree_nodes:
     435         sum_child_probabilities = 0.0
     436         for child_node in tree_node._children:
     437            sum_child_probabilities += child_node._conditional_probability
     438         for child_node in tree_node._children:
     439            child_node._conditional_probability = child_node._conditional_probability / sum_child_probabilities
     440
     441      # re-compute the absolute scenario probabilities based
     442      # on the re-normalized conditional node probabilities.
     443      for scenario in self._scenarios:
     444         probability = 1.0
     445         for tree_node in scenario._node_list:
     446            probability = probability * tree_node._conditional_probability
     447         scenario._probability = probability
    430448
    431449   #
Note: See TracChangeset for help on using the changeset viewer.