# FlopSmiEx::BinTreeStruct Class Reference

Class for balanced binary trees. More...

`#include <scen-tree_struct.hpp>`

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

List of all members.

## Public Member Functions
| BinTreeStruct (int const T)
| Constructor.
| ~BinTreeStruct ()
int | get_parent_node (int n) const
| Get the parent of a given node.
double | get_scen_prob (int const sc) const
| Get probability of a given scenarios.
int const * | get_scen_nodes (int const sc)
| Get the vector of nodes of a given scenarios.
int const * | get_next_scen (int &scen, int &parentScen, int &branchStage, double &prob)
| Get vector of nodes of a next scenario in the list.
## Protected Member Functions
int | set_scen_nodes (int const sc)
| Fill `scenNodeNmb` with nodes of a given scenarios.
## Protected Attributes
int * | scenNodeNmb
| vector of nodes of a scenario - for internal use
int | nextScen
| next scenario to be processed by gen_next_scen
double | scenProb
| probability of each scenario (equiprobable)

## 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`[inline, virtual]`

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`[inline, virtual]`

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 | ) | `[inline, virtual]`

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]` | 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

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:

- /home/coin/svn-release/Smi-0.93.1/Smi/flopcpp_examples/scen-tree_struct.hpp