StageNode Class Reference

This is the base class for describing a model in one node of the tree. More...

Inheritance diagram for StageNode:

Inheritance graph
[legend]
Collaboration diagram for StageNode:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 StageNode (StageNode *ptPred, const int nmbAssets, const int nodeN, const double condProb)
virtual ~StageNode ()
virtual double get_wealth (const double *variableValues, const int nmbVars)
 get the wealth at the nodes

Public Attributes

MP_set ASSETS
 set of assets
MP_index a
 index used in formulas
MP_variable x
 the "buy" variable, defined on ASSETS
MP_expression objFunction
 objective function at this node
StageNodeptParent
 pointer to parent node
vector< StageNode * > children
 pointers to children of this node
int nodeNmb
 node number - used only for reporting
double prob
 probability (unconditional) of the node
References to variables and constraints
vector< VariableRef * > all_variables
 references to all variables
vector< MP_constraint * > all_constraints
MP_constraint * pt_balance_constraint
 A common way to access the balance constraints in the derived classes.

Protected Member Functions

virtual void make_obj_function_ ()
 Create the objective function expression, recursively for all children.


Detailed Description

This is the base class for describing a model in one node of the tree.

Note that variable x, as well as the vector of children, should not really be in this class, as they are not needed in all the nodes (they do not exist in leaves). It would thus be better to have an additional derived class for non-leaf nodes and then derive RootNode and MidStageNode from this one. This solution, however, brings some other problems...

Definition at line 38 of file investment.cpp.


Constructor & Destructor Documentation

StageNode::StageNode ( StageNode ptPred,
const int  nmbAssets,
const int  nodeN,
const double  condProb 
) [inline]

Definition at line 67 of file investment.cpp.

References children, prob, and ptParent.

virtual StageNode::~StageNode (  )  [inline, virtual]

Definition at line 77 of file investment.cpp.

References a, and all_variables.


Member Function Documentation

virtual double StageNode::get_wealth ( const double *  variableValues,
const int  nmbVars 
) [inline, virtual]

get the wealth at the nodes

We cannot use x.level(), because this is linked to the core model, not the stochastic model. Instead, we provide the function with the current values of the node's variables. Note that in general, we might have to provide the values of stochastic data as well.
By default, the wealth is the sum of all the x variables, so it must be overridden in the leaves.

Reimplemented in LeafNode.

Definition at line 90 of file investment.cpp.

References all_variables.

virtual void StageNode::make_obj_function_ (  )  [inline, protected, virtual]

Create the objective function expression, recursively for all children.

This function is protected, as it only makes sense to call it in the root, to create the complete objective function.

Reimplemented in LeafNode.

Definition at line 103 of file investment.cpp.

References children, and objFunction.

Referenced by RootNode::make_objective_function().


Member Data Documentation

MP_set StageNode::ASSETS

set of assets

Definition at line 40 of file investment.cpp.

Referenced by LeafNode::LeafNode(), MidStageNode::MidStageNode(), and RootNode::RootNode().

MP_index StageNode::a

index used in formulas

Definition at line 41 of file investment.cpp.

Referenced by MidStageNode::MidStageNode(), RootNode::RootNode(), and ~StageNode().

MP_variable StageNode::x

the "buy" variable, defined on ASSETS

Definition at line 42 of file investment.cpp.

Referenced by LeafNode::LeafNode(), MidStageNode::MidStageNode(), and RootNode::RootNode().

MP_expression StageNode::objFunction

objective function at this node

Definition at line 43 of file investment.cpp.

Referenced by main(), LeafNode::make_obj_function_(), and make_obj_function_().

StageNode* StageNode::ptParent

pointer to parent node

Definition at line 45 of file investment.cpp.

Referenced by LeafNode::LeafNode(), MidStageNode::MidStageNode(), and StageNode().

vector<StageNode *> StageNode::children

pointers to children of this node

Definition at line 46 of file investment.cpp.

Referenced by make_obj_function_(), and StageNode().

int StageNode::nodeNmb

node number - used only for reporting

Definition at line 47 of file investment.cpp.

double StageNode::prob

probability (unconditional) of the node

Definition at line 48 of file investment.cpp.

Referenced by LeafNode::make_obj_function_(), and StageNode().

vector<VariableRef *> StageNode::all_variables

references to all variables

The idea is to have "meta objects" with all variables and constraints in a node. This is important in creation of the Smi object, where we have to associate the nodes variables and constraints to stages. Without these new objects, we would have to access all the derived classes independently, cluttering the code.

Definition at line 57 of file investment.cpp.

Referenced by LeafNode::get_wealth(), get_wealth(), LeafNode::LeafNode(), MidStageNode::MidStageNode(), RootNode::RootNode(), and ~StageNode().

vector<MP_constraint *> StageNode::all_constraints

references to all constraints

Definition at line 58 of file investment.cpp.

Referenced by LeafNode::LeafNode(), MidStageNode::MidStageNode(), and RootNode::RootNode().

MP_constraint* StageNode::pt_balance_constraint

A common way to access the balance constraints in the derived classes.

Two of the derived classes have a cash-flow balance constraint with the Return values in it. These constraints have to be accessed when creating scenarios and without this common handle, we would need to write a separate code for the two classes.

Definition at line 64 of file investment.cpp.

Referenced by LeafNode::LeafNode(), MidStageNode::MidStageNode(), and RootNode::RootNode().


The documentation for this class was generated from the following file:
Generated on Mon Jan 26 10:55:21 2009 for investment by  doxygen 1.5.4