Skip to content
Snippets Groups Projects
Select Git revision
  • 9fcc73f41f55b25e13d0b3a58a57834ffe61e25a
  • master default
  • isfile
  • nlf-fixes
  • newton-quadratic-equation-solver
  • nlf-fixes-r
  • nls-fixes
  • sep-fixes
  • sep
  • use-dprior
  • ep-sparse
  • rebase-1
  • parfor
  • reset-seed-in-unit-tests
  • remove-persistent-variables
  • nonlinear-filter-fixes
  • pac-mce-with-composite-target
  • 6.x
  • dprior
  • covariance-quadratic-approximation
  • benchmark-ec
  • 5.5
  • 5.4
  • 5.3
  • 5.2
  • 5.1
  • 5.0
  • 5.0-rc1
  • 4.7-beta3
  • 4.7-beta2
  • 4.7-beta1
  • 4.6.4
  • 4.6.3
  • 4.6.2
  • 4.6.1
  • 4.6.0
  • 4.6.0-rc2
  • 4.6.0-rc1
  • 4.6-beta1
  • 4.5.7
  • 4.5.6
41 results

basic_plan.m

Blame
  • Forked from Dynare / dynare
    Source project has a limited visibility.
    NumericalInitialization.cc 21.56 KiB
    /*
     * Copyright © 2003-2022 Dynare Team
     *
     * This file is part of Dynare.
     *
     * Dynare is free software: you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * Dynare is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
     */
    
    #include <iostream>
    #include <fstream>
    #include <sstream>
    #include <cstdlib>
    #include <utility>
    
    #include "NumericalInitialization.hh"
    
    InitParamStatement::InitParamStatement(int symb_id_arg,
                                           const expr_t param_value_arg,
                                           const SymbolTable &symbol_table_arg) :
      symb_id{symb_id_arg},
      param_value{param_value_arg},
      symbol_table{symbol_table_arg}
    {
    }
    
    void
    InitParamStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
    {
      if (symbol_table.getName(symb_id) == "dsge_prior_weight")
        mod_file_struct.dsge_prior_weight_initialized = true;
    
      // Needed for the workaround discussed in dynare#1173
      if (symbol_table.getName(symb_id) == "optimal_policy_discount_factor")
        param_value->collectVariables(SymbolType::parameter, mod_file_struct.parameters_in_planner_discount);
    }
    
    void
    InitParamStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
    {
      int id = symbol_table.getTypeSpecificID(symb_id) + 1;
      output << "M_.params(" << id << ") = ";
      param_value->writeOutput(output);
      output << ";" << endl;
      if (!minimal_workspace)
        output << symbol_table.getName(symb_id) << " = M_.params(" << id << ");" << endl;
    }
    
    void
    InitParamStatement::writeJsonOutput(ostream &output) const
    {
      output << R"({"statementName": "param_init", "name": ")" << symbol_table.getName(symb_id) << R"(", )" << R"("value": ")";
      param_value->writeJsonOutput(output, {}, {});
      output << R"("})";
    }
    
    void
    InitParamStatement::fillEvalContext(eval_context_t &eval_context) const
    {
      try