Node types¶
This module is used to create and characterize the nodes of the tree. The package implements three types of nodes:
Terminal nodes.
Decision nodes.
Chance nodes.
- class smart_choice.datanodes.DataNodes(chance_probabilities='must_100%')[source]¶
Bases:
object
This is a bag used to create and contain the different types of the tree nodes. The functions terminal, chance, and decision are used to create the nodes.
- add_chance(name, branches)[source]¶
Adds a chance node to the bag.
- Parameters
name (str) – Name assigned to the node.
branches (List[tuple]) –
A list of tuples, where each tuple contains the following information:
Name of the branch.
Probability.
Associated value to the branch.
Name of the successor node.
- Return type
None
- add_decision(name, branches, maximize=False)[source]¶
Adds a decision node to the bag.
- Parameters
name (str) – Name assigned to the node.
branches (List[tuple]) –
A list of tuples, where each tuple contains the following information:
Name of the branch.
Associated value to the branch.
Name of the successor node.
maximize (bool) – When it is True, selects the branch with the maximum expected value.
- Return type
None
- add_terminal(name, payoff_fn=None)[source]¶
Adds a decision node to the bag.
- Parameters
name (str) – Name assigned to the node.
payoff_fn (Optional[Any]) – It is a valid python function used for computing the value of the terminal node in the tree. The names of the created nodes must be used as the parameters of the function.
- Return type
None
- get_top_bottom_branches(name)[source]¶
Gets the position of the branches with top and bottom values.
- set_outcome(outcome, **conditions)[source]¶
Creates a dependent outcome for a branch.
- Parameters
outcome – value assigned to the branch.
conditions – pairs of variables and values specifying the required conditions to assign the outcome to a branch.