Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FlopSmiEx::BinTreeStruct Class Reference

Class for balanced binary trees. More...

#include <scen-tree_struct.hpp>

Inheritance diagram for FlopSmiEx::BinTreeStruct:
Inheritance graph
[legend]
Collaboration diagram for FlopSmiEx::BinTreeStruct:
Collaboration graph
[legend]

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...
 
- Public Member Functions inherited from FlopSmiEx::ScenTreeStruct
 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...
 
- Protected Attributes inherited from FlopSmiEx::ScenTreeStruct
int nmbScens
 number of scenarios More...
 
vector< int > leaves
 list of leaf nodes - they define scenarios More...
 

Additional Inherited Members

- Public Attributes inherited from FlopSmiEx::ScenTreeStruct
int nmbStages
 number of stages, again counted from zero More...
 

Detailed Description

Class for balanced binary trees.

Definition at line 80 of file scen-tree_struct.hpp.

Constructor & Destructor Documentation

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

FlopSmiEx::BinTreeStruct::~BinTreeStruct ( )
inline

Definition at line 97 of file scen-tree_struct.hpp.

Member Function Documentation

int FlopSmiEx::BinTreeStruct::set_scen_nodes ( int const  sc)
protected

Fill scenNodeNmb with nodes of a given scenarios.

Returns
first stage when the scen. differs from current scenNodeNmb
int FlopSmiEx::BinTreeStruct::get_parent_node ( int  n) const
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.

double FlopSmiEx::BinTreeStruct::get_scen_prob ( int const  sc) const
inlinevirtual

Get probability of a given scenarios.

Implements FlopSmiEx::ScenTreeStruct.

Definition at line 105 of file scen-tree_struct.hpp.

int const* FlopSmiEx::BinTreeStruct::get_scen_nodes ( int const  sc)
inlinevirtual

Get the vector of nodes of a given scenarios.

Implements FlopSmiEx::ScenTreeStruct.

Definition at line 107 of file scen-tree_struct.hpp.

int const* FlopSmiEx::BinTreeStruct::get_next_scen ( int &  scen,
int &  parentScen,
int &  branchStage,
double &  prob 
)
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.

Parameters
[out]scennumber of the new scenario
[out]parentScenparent scenario
[out]branchStagestage where scen diverges from parentScen
[out]probprobability of the new scenario
Returns
vector of node indices of the new scen, NULL at the end

Implements FlopSmiEx::ScenTreeStruct.

Member Data Documentation

int* FlopSmiEx::BinTreeStruct::scenNodeNmb
protected

vector of nodes of a scenario - for internal use

Definition at line 82 of file scen-tree_struct.hpp.

int FlopSmiEx::BinTreeStruct::nextScen
protected

next scenario to be processed by gen_next_scen

Definition at line 83 of file scen-tree_struct.hpp.

double FlopSmiEx::BinTreeStruct::scenProb
protected

probability of each scenario (equiprobable)

Definition at line 84 of file scen-tree_struct.hpp.


The documentation for this class was generated from the following file: