Class for balanced binary trees. More...
#include <scen-tree_struct.hpp>
Public Member Functions | |
BinTreeStruct (int const T) | |
Constructor. More... | |
~BinTreeStruct () | |
int | get_parent_node (int n) const |
Get the parent of a given node. More... | |
double | get_scen_prob (int const sc) const |
Get probability of a given scenarios. More... | |
int const * | get_scen_nodes (int const sc) |
Get the vector of nodes of a given scenarios. More... | |
int const * | get_next_scen (int &scen, int &parentScen, int &branchStage, double &prob) |
Get vector of nodes of a next scenario in the list. More... | |
![]() | |
ScenTreeStruct (int const nScens, int const nStages=0) | |
Constructor. More... | |
virtual | ~ScenTreeStruct () |
Destructor. More... | |
int | get_nmb_stages () const |
Get the number of stages. More... | |
int | get_nmb_scens () const |
Get the number of scenarios = the number of leaves. More... | |
int const * | get_core_scen () |
Get the vector of nodes of a core scenario - just a wrapper. More... | |
Protected Member Functions | |
int | set_scen_nodes (int const sc) |
Fill scenNodeNmb with nodes of a given scenarios. More... | |
Protected Attributes | |
int * | scenNodeNmb |
vector of nodes of a scenario - for internal use More... | |
int | nextScen |
next scenario to be processed by gen_next_scen More... | |
double | scenProb |
probability of each scenario (equiprobable) More... | |
![]() | |
int | nmbScens |
number of scenarios More... | |
vector< int > | leaves |
list of leaf nodes - they define scenarios More... | |
Additional Inherited Members | |
![]() | |
int | nmbStages |
number of stages, again counted from zero More... | |
Class for balanced binary trees.
Definition at line 80 of file scen-tree_struct.hpp.
FlopSmiEx::BinTreeStruct::BinTreeStruct | ( | int const | T | ) |
Constructor.
A binary tree with T periods has 2^(T-1) scenarios. We number the nodes in a breadth-first manner, so the leaves are at the end, with first leaf at node 2^(T-1)-1
|
inline |
Definition at line 97 of file scen-tree_struct.hpp.
|
protected |
Fill scenNodeNmb
with nodes of a given scenarios.
scenNodeNmb
|
inlinevirtual |
Get the parent of a given node.
In a general case, this would be given by a table, for balanced trees one can use a simple formula. The question is what to do with the root: should the function return 0, -1, or throw an exception?
Implements FlopSmiEx::ScenTreeStruct.
Definition at line 101 of file scen-tree_struct.hpp.
|
inlinevirtual |
Get probability of a given scenarios.
Implements FlopSmiEx::ScenTreeStruct.
Definition at line 105 of file scen-tree_struct.hpp.
|
inlinevirtual |
Get the vector of nodes of a given scenarios.
Implements FlopSmiEx::ScenTreeStruct.
Definition at line 107 of file scen-tree_struct.hpp.
|
virtual |
Get vector of nodes of a next scenario in the list.
This assumes that the class itself will keep track of the calls and hence knows what is the next scenario. This is used for Smi, when each scenario is described as a difference from a given parent scenario.
[out] | scen | number of the new scenario |
[out] | parentScen | parent scenario |
[out] | branchStage | stage where scen diverges from parentScen |
[out] | prob | probability of the new scenario |
Implements FlopSmiEx::ScenTreeStruct.
|
protected |
vector of nodes of a scenario - for internal use
Definition at line 82 of file scen-tree_struct.hpp.
|
protected |
next scenario to be processed by gen_next_scen
Definition at line 83 of file scen-tree_struct.hpp.
|
protected |
probability of each scenario (equiprobable)
Definition at line 84 of file scen-tree_struct.hpp.