diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 679a5ab3e1215410a9e451663f42772282e86bcf..8e979f88af4aaa838fa45535bae39ebcc81183c8 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -2945,8 +2945,8 @@ Finding the steady state with Dynare nonlinear solver ``5`` - Newton algorithm with a sparse Gaussian elimination - (SPE) (requires ``bytecode`` option, see + Newton algorithm with a sparse Gaussian elimination (SPE) + solver at each iteration (requires ``bytecode`` option, see :ref:`model-decl`). ``6`` @@ -2964,7 +2964,7 @@ Finding the steady state with Dynare nonlinear solver ``8`` Newton algorithm with a Stabilized Bi-Conjugate - Gradient (BICGSTAB) solver at each iteration (requires + Gradient (BiCGStab) solver at each iteration (requires bytecode and/or block option, see :ref:`model-decl`). ``9`` @@ -3680,60 +3680,64 @@ speed-up on large models. ``0`` Use a Newton algorithm with a direct sparse LU solver at each - iteration, applied on the stacked system of all the equations at - every period (Default). + iteration, applied to the stacked system of all equations in all + periods (Default). ``1`` Use the Laffargue-Boucekkine-Juillard (LBJ) algorithm proposed - in *Juillard (1996)*. It is slower than ``stack_solve_algo=0``, - but may be less memory consuming on big models. Note that if the - ``block`` option is used (see :ref:`model-decl`), a simple - Newton algorithm with sparse matrices is used for blocks which - are purely backward or forward (of type ``SOLVE BACKWARD`` or - ``SOLVE FORWARD``, see :comm:`model_info`), since LBJ only makes - sense on blocks with both leads and lags (of type ``SOLVE TWO - BOUNDARIES``). + in *Juillard (1996)* on top of a LU solver. It is slower + than ``stack_solve_algo=0``, but may be less memory consuming on + big models. Note that if the ``block`` option is used (see + :ref:`model-decl`), a simple Newton algorithm with sparse + matrices, applied to the stacked system of all block equations + in all periods, is used for blocks which are purely backward or + forward (of type ``SOLVE BACKWARD`` or ``SOLVE FORWARD``, see + :comm:`model_info`), since LBJ only makes sense on blocks with + both leads and lags (of type ``SOLVE TWO BOUNDARIES``). ``2`` - Use a Newton algorithm with a Generalized Minimal - Residual (GMRES) solver at each iteration (requires - ``bytecode`` and/or ``block`` option, see - :ref:`model-decl`) + Use a Newton algorithm with a Generalized Minimal Residual + (GMRES) solver at each iteration, applied on the stacked system + of all equations in all periods (requires ``bytecode`` and/or + ``block`` option, see :ref:`model-decl`) ``3`` - Use a Newton algorithm with a Stabilized Bi-Conjugate - Gradient (BICGSTAB) solver at each iteration (requires - ``bytecode`` and/or ``block`` option, see - :ref:`model-decl`). + Use a Newton algorithm with a Stabilized Bi-Conjugate Gradient + (BiCGStab) solver at each iteration, applied on the stacked + system of all equations in all periods (requires ``bytecode`` + and/or ``block`` option, see :ref:`model-decl`). ``4`` - Use a Newton algorithm with an optimal path length at - each iteration (requires ``bytecode`` and/or ``block`` - option, see :ref:`model-decl`). + Use a Newton algorithm with a direct sparse LU solver and an + optimal path length at each iteration, applied on the stacked + system of all equations in all periods (requires ``bytecode`` + and/or ``block`` option, see :ref:`model-decl`). ``5`` - Use a Newton algorithm with a sparse Gaussian - elimination (SPE) solver at each iteration (requires - ``bytecode`` option, see :ref:`model-decl`). + Use the Laffargue-Boucekkine-Juillard (LBJ) algorithm proposed + in *Juillard (1996)* on top of a sparse Gaussian elimination + (SPE) solver. The latter takes advantage of the similarity of + the Jacobian across periods when searching for the pivots + (requires ``bytecode`` option, see :ref:`model-decl`). ``6`` - Synonymous for ``stack_solve_algo=1``. Kept for historical - reasons. + Synonymous for ``stack_solve_algo=1``. Kept for backward + compatibility. ``7`` - Allows the user to solve the perfect foresight model - with the solvers available through option - ``solve_algo`` (See :ref:`solve_algo <solvalg>` for a - list of possible values, note that values 5, 6, 7 and - 8, which require ``bytecode`` and/or ``block`` options, - are not allowed). For instance, the following + Allows the user to solve the perfect foresight model with the + solvers available through option ``solve_algo``, applied on the + stacked system of all equations in all periods (See + :ref:`solve_algo <solvalg>` for a list of possible values, note + that values 5, 6, 7 and 8, which require ``bytecode`` and/or + ``block`` options, are not allowed). For instance, the following commands:: perfect_foresight_setup(periods=400); diff --git a/matlab/perfect-foresight-models/solve_block_decomposed_problem.m b/matlab/perfect-foresight-models/solve_block_decomposed_problem.m index 38aa374ad09683314aada3ed8b6c1500b755fe84..d7524d7cefbbefece98f8f76229150bd525c2be3 100644 --- a/matlab/perfect-foresight-models/solve_block_decomposed_problem.m +++ b/matlab/perfect-foresight-models/solve_block_decomposed_problem.m @@ -14,7 +14,7 @@ function [y, success, maxerror, per_block_status] = solve_block_decomposed_probl % maxerror [double] ∞-norm of the residual % per_block_status [struct] vector structure with per-block information about convergence -% Copyright © 2020-2023 Dynare Team +% Copyright © 2020-2024 Dynare Team % % This file is part of Dynare. % @@ -33,18 +33,21 @@ function [y, success, maxerror, per_block_status] = solve_block_decomposed_probl cutoff = 1e-15; -if options_.stack_solve_algo==0 - mthd='Sparse LU'; -elseif options_.stack_solve_algo==1 || options_.stack_solve_algo==6 - mthd='LBJ'; -elseif options_.stack_solve_algo==2 - mthd='GMRES'; -elseif options_.stack_solve_algo==3 - mthd='BICGSTAB'; -elseif options_.stack_solve_algo==4 - mthd='OPTIMPATH'; -else - mthd='UNKNOWN'; +switch options_.stack_solve_algo + case 0 + mthd='Sparse LU on stacked system'; + case {1,6} + mthd='LBJ with LU solver'; + case 2 + mthd='GMRES on stacked system'; + case 3 + mthd='BiCGStab on stacked system'; + case 4 + mthd='Sparse LU solver with optimal path length on stacked system'; + case 7 + mthd='Solver from solve_algo option on stacked system' + otherwise + error('Unsupported stack_solve_algo value') end if options_.verbosity printline(41) diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index deaea53bf845b9bd8fdbe36dd07304a3f957b611..559e27e2831eed56251caae6f4355dba9c466a28 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -1,5 +1,5 @@ /* - * Copyright © 2007-2023 Dynare Team + * Copyright © 2007-2024 Dynare Team * * This file is part of Dynare. * @@ -4710,23 +4710,26 @@ Interpreter::Simulate_Newton_Two_Boundaries( switch (stack_solve_algo) { case 0: - mexPrintf("MODEL SIMULATION: (method=Sparse LU)\n"); + mexPrintf("MODEL SIMULATION: (method=Sparse LU solver on stacked system)\n"); break; case 2: - mexPrintf(preconditioner_print_out("MODEL SIMULATION: (method=GMRES)\n", - preconditioner, false) - .c_str()); + mexPrintf( + preconditioner_print_out("MODEL SIMULATION: (method=GMRES on stacked system)\n", + preconditioner, false) + .c_str()); break; case 3: - mexPrintf(preconditioner_print_out("MODEL SIMULATION: (method=BiCGStab)\n", - preconditioner, false) + mexPrintf(preconditioner_print_out( + "MODEL SIMULATION: (method=BiCGStab on stacked system)\n", + preconditioner, false) .c_str()); break; case 4: - mexPrintf("MODEL SIMULATION: (method=Sparse LU & optimal path length)\n"); + mexPrintf("MODEL SIMULATION: (method=Sparse LU solver with optimal path length on " + "stacked system)\n"); break; case 5: - mexPrintf("MODEL SIMULATION: (method=Sparse Gaussian Elimination)\n"); + mexPrintf("MODEL SIMULATION: (method=LBJ with Sparse Gaussian Elimination)\n"); break; } }