Differences between revisions 10 and 11
Revision 10 as of 2009-09-02 16:35:51
Size: 12675
Comment:
Revision 11 as of 2009-09-03 11:23:17
Size: 4417
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Options =
For each representation of the model there are two kinds of options:
 * the options used during the preprocessing step and that modify permanently the model representation. They are the options of the model command:
  * the representation of the model after the preprocessing: bytecode if '''bytecode''' option is used (the model is stored in a .COD binary file) or human readable form, if '''bytecode''' is not used (the model is stored in a matlab M-file);
  * the block decomposition of the model: '''block''' option;
  * the model simplification. All the elements of the jacobian which are below a cutoff are discarded: '''cutoff=real value'''
  * Each block of the model can be rewritten in a quasi recursive form. The endogenous variables are split in two different groups: the recursive variables and the feedback variables. The recursive variables are simply evaluated conditional to the feedback variables. The system is solved only for the feedback variables. The set of feedback variables is determined according to the '''mfs''' option:
     * '''mfs = 0''': (default value) all the endogenous variables are considered as feedback variables;
     * '''mfs = 1''': the endogenous variables assigned to equation naturally normalized are potentially recursive variables. All the other variables are forced to belong to the set of feedback variables.
     * '''mfs = 2''': in addition of variables with mfs = 1 the endogenous variables related to linear equation which could be normalized are potential recursive variables. All the other variables are forced to belong to the set of feedback variables.
     * '''mfs = 3''': in addition of variables with mfs = 2 the endogenous variables related non-linear equation which could be normalized are potential recursive variables. All the other variables are forced to belong to the set of feedback variables.

 * the local options used during the computing step and which can be modified many times in the same mod file. They are defined as options of steady or simul command.
  * The algorithm used to solve the static model (steady command) is indicated with the '''solve_algo''' option.
    * '''solve_algo = 0''': the matlab solver fsolve is used. This option is available only with a matlab representation of the model;
    * '''solve_algo = 1''': use a Newton algorithm with variable path length. This option is available only with a matlab representation of the model;
    * '''solve_algo = 2''' or '''solve_algo =4''': the model is block decomposed (at the computing step) and each block is solved using the matlab solver fsolve. When '''solve_algo = 2''' is used a bad conditioning flag is activated but not with '''solve_algo = 4''';
    * '''solve_algo = 3''': use the Christopher Sims’s solver (http://sims.princeton.edu/yftp/optimize/mfiles/csolve.m).
    * '''solve_algo = 5''': Use a Newton algorithm with variable path length to solve each block of the static model.
  Note that '''solve_algo = 5''' can be used only with a binary representation of the model.
  * The algorithm used to solve the dynamic model (simul) is signified with the '''stack_solve_algo''' option:
    * '''stack_solve_algo=0''': use the simk.m or sim1.m solver which takes into account the sparse structure of the stacked time system according to Laffargue (1990)] and Juillard (1996).
    * '''stack_solve_algo=1''': use a Newton algorithm with a sparse LU solver at each iteration;
    * '''stack_solve_algo=2''': use a Newton algorithm with a GMRES solver at each iteration;
    * '''stack_solve_algo=3''': use a Newton algorithm with a BICGSTAB solver at each iteration;
    * '''stack_solve_algo=4''': use a Newton algorithm with a optimal path length at each iteration;
    * '''stack_solve_algo=5''': use a Newton algorithm with a sparse Gaussian elimination solver at each iteration. Once the sequence of operations used by the linear solver remains the same, it is directly used to speed up the resolution;
  With a matlab representation of the model, only the first four options are available.
  * The '''markowitz=real value''' option is used the sparse Gaussian elimination solver to maintain the sparse structure of the linear system solved at each step of the Newton algorithm. When '''markowitz''' is close to zero, the pivot in the Gaussian elimination is selected according to the maximum value (avoid singularity). For high values of '''markowitz''' the pivot is selected according to the minimum number of nonzero elements in the row (reduce the Fill-in). This option could be used only for a bytecode representation of the model.

= The different steps of the block decomposition and of the feedback variables determination =

== Model simplification ==

In a first step to get ride of nearly zero elements in the jacobian a threshold is used to determine whether a jacobian element has to be considered as null or not. If the absolute value of a jacobian element is below the threshold then it is considered as null and is discarded form the sparse representation of the jacobian. Eliminating nearly zero elements improves the sparsity of the model and hence the simulation time. Note that if the cutoff value is too high then the model properties could be strongly modified and the simulation could fail.
 
== Prologue and Epilogue determination ==

In a second step, the equations and the variables of the model could be reordered to get purely recursive initial and final blocks. The purely recursive equations are easily found.
 * The first block, called prologue, is composed of equations involving only exogenous variables or endogenous variables determined by previous equations.
 * The last block, the epilogue, is composed of variables which are pure output in the model: they do not appear in the previous equations of the model.

== Model normalization ==

To get a block decomposition of the model, each endogenous variable has to be assigned unambiguously to an equation or equivalently the model has to be normalized: This normalization is performed using the maximum cardinality matching with Edmonds’ matching algorithm (Boost-graph library). Attention has to be paid to potential singularity in the matching process (to avoid for example a normalisation where the variable x is assigned to the following equation: y+0*x=2*z). The matching algorithm is applied iteratively using the normalized Jacobian matrix (each row is divided by its maximum absolute value component) with a decreasing cutoff (all the elements in the Jacobian matrix below the cutoff are set to zero) until a matching is found.

== Equations renormalization ==

Once the model has been normalized, the preprocessor tries to rewrite the equations in a normalized form: for the variable x_i associated to the equation i, the equation has of the following form x_i = f(x_1, …, x_{i-1}, x_{i+1}, …, x_n). For equations belonging to a recursive block, the normalized equation has not to be solved but only evaluated. For equations normalized belonging to a simultaneous block, they could be simply evaluated if they belong to the recursive set of the block in the feedback variables determination.
  
== Block decomposition ==

The simultaneous block composed of equations and endogenous variables that do not belong to the prologue or the epilogue could be split sub recursive blocks. Those sub recursive blocks form the strong component of the graph representation of the model. To find them a depth search Tarjan algorithm is used.

== Splitting the variables of a simultaneous block in feedback and recursive variables ==

The simultaneous blocks computed in the previous step are rewritten in a quasi triangular form. The non normalized equations that could not be evaluated are forced to belong to the feedback variables set. In addition, for dynamic model the static variables associated with non static equation or the non static variables are imposed in the feedback variables set. The equations of the block are reordered as follow:
 * First the equations associated to variables belonging to recursive set ordered in a recursive way;
 * Second the equations associated to variables belonging to feedback set.

Description of the ByteCode format

List of tags

Each tag is coded as char.

  • FBEGINBLOCK:
    • Description: New block
    • Arguments:
      • Size of the block (int) (number of equations)
      • Type of the block (int) see appendix
      • for each equation
        • Variable number (int)
        • Equation number (int)
        • Own derivative (int) (unused)
  • FDIMT or FDIMST
    • Description: Indicate the number of temporary terms (needed to allocate the memory space for temporary terms) (FDIMT for dynamic model and FDIMTS for static model)
    • Arguments:
      • Number of temporary terms (int)
  • FEND
    • Description: End of the model
    • Arguments:
  • FENDBLOCK
    • Description: End of a model block
    • Arguments:
  • FLDV
    • Description: load a variable for dynamic model
    • Arguments:
      • Variable type (char)
      • for eEndogenous, eExogenous and eExogenousDet
        • Variable number (int)
        • Lag or lead (int)
      • for eParameter
        • Variable number (int)
  • FLDSV
    • Description: load a variable for static model
    • Arguments:
      • Variable type (char)
      • Variable number (int)
  • FLDT or FLDST
    • Description: load a temporary term (FLDT for dynamic model and FLDST for static model)
    • Arguments:
      • Number (int)
  • FLDU or FLDUS
    • Description: load an element of the sparse representation of the Jacobian matrix (FLDU for dynamic model or FLDUS for static model)
    • Argument:
      • Number (int)
  • FLDR
    • Description: load a residual
    • Argument:
      • Number (int)
  • FLDZ
    • Description: load zero
    • Arguments
  • FLDC
    • Description: load a constant
    • Arguments:
      • Value (double)
  • FSTPV
    • Description: store a variable for a dynamic model
    • Arguments:
      • Variable type (char)
      • for eEndogenous, eExogenous and eExogenousDet
        • Variable number (int)
        • Lag or lead (int)
      • for eParameter
        • Variable number (int)
  • FSTPSV
    • Description: store a variable for static model
    • Arguments:
      • Variable type (char)
      • Variable number (int)
  • FSTPT or FSTPST
    • Description: store a temporary term (FSTPT for dynamic model and FSTPST for static model)
    • Arguments:
      • Number (int)
  • FSTPU or FSTPUS
    • Description: store an element of the sparse representation of the Jacobian matrix (FSTPU for dynamic model or FSTPUS for static model)
    • Argument:
      • Number (int)
  • FSTPR
    • Description: store a residual
    • Argument:
      • Number (int)
  • FSTPG
    • Description: store a derivative
    • Argument:
      • Number (int)
  • FBINARY
    • Description: compute a binary operation
    • Argument:
      • opCode (int)
  • FUNARY
    • Description: compute a unary operation
    • Argument:
      • opCode (int)
  • FENDEQU
    • Description: End of an equation
    • Argument:
  • FCUML
    • Description: add two arguments in the stack and put the result in the stack
    • Argument:

Appendix: Type of block

  • EVALUATE_FORWARD: the block is recursive and the equations have to be simply evaluated. Because the block is backward looking, the simulation is performed from the first period to the last period.
  • EVALUATE_BACKWARD: the block is recursive and the equations have to be simply evaluated. Because the block is forward looking, the simulation is performed from the last period to the firs period.
  • SOLVE_FORWARD_SIMPLE: the block is composed of only one equation that has to be solved. Because the block is backward looking, the simulation is performed from the first period to the last period.
  • SOLVE_ BACKWARD _SIMPLE: the block is composed of only one equation that has to be solved. Because the block is forward looking, the simulation is performed from the last period to the firs period.
  • SOLVE_FORWARD_COMPLETE: the block is composed of several equations and it does not contain any lead endogenous variable. It has to be solved period by period from the first period to the last period
  • SOLVE_BACKWARD_COMPLETE: the block is composed of several equations and it does not contain any lag endogenous variable. It has to be solved period by period from the last period to the first period
  • SOLVE_TWO_BOUNDARIES_COMPLETE or SOLVE_TWO_BOUNDARIES_SIMPLE: the block is composed of equations and it contains lead and lag endogenous variables. The block is simulated, using its stacked-time representation.

DynareWiki: ByteCode (last edited 2009-09-03 11:23:17 by SébastienVillemot)