Commit 67838217 authored by michel's avatar michel
Browse files

v4: fixing initvalf

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1795 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 86d4dd0d
......@@ -92,7 +92,7 @@ class ParsingDriver;
%token FORECAST
%token GAMMA_PDF GAUSSIAN_ELIMINATION GCC_COMPILER GMRES GRAPH
%token HISTVAL HP_FILTER HP_NGRID
%token INITVAL
%token INITVAL INITVAL_FILE
%token <string_val> INT_NUMBER
%token INV_GAMMA_PDF IRF
%token KALMAN_ALGO KALMAN_TOL
......@@ -152,6 +152,7 @@ statement : declaration
| markowitz
| model
| initval
| initval_file
| endval
| histval
| init_param
......@@ -363,11 +364,10 @@ comma_expression : expression
initval : INITVAL ';' initval_list END
{ driver.end_initval(); }
| INITVAL '(' initval_option ')' ';' initval_list END
{ driver.end_initval(); }
;
initval_option : FILENAME EQUAL NAME { driver.init_val_filename($3); };
initval_file : INITVAL_FILE '(' FILENAME EQUAL NAME ')' ';'
{ driver.initval_file($5); }
;
endval : ENDVAL ';' initval_list END { driver.end_endval(); };
......
......@@ -129,6 +129,7 @@ int sigma_e = 0;
<INITIAL>bvar_density {BEGIN DYNARE_STATEMENT; return token::BVAR_DENSITY; }
<INITIAL>bvar_forecast {BEGIN DYNARE_STATEMENT; return token::BVAR_FORECAST; }
<INITIAL>dynare_sensitivity {BEGIN DYNARE_STATEMENT; return token::DYNARE_SENSITIVITY;}
<INITIAL>initval_file {BEGIN DYNARE_STATEMENT; return token::INITVAL_FILE;}
/* End of a Dynare statement */
<DYNARE_STATEMENT>; {
......@@ -207,6 +208,7 @@ int sigma_e = 0;
<DYNARE_STATEMENT>constant {return token::CONSTANT;}
<DYNARE_STATEMENT>noconstant {return token::NOCONSTANT;}
<DYNARE_STATEMENT>covar {return token::COVAR;}
<DYNARE_STATEMENT>filename {return token::FILENAME;}
<DYNARE_STATEMENT>bvar_prior_tau { return token::BVAR_PRIOR_TAU; }
<DYNARE_STATEMENT>bvar_prior_decay { return token::BVAR_PRIOR_DECAY; }
......@@ -234,7 +236,6 @@ int sigma_e = 0;
<DYNARE_BLOCK>periods {return token::PERIODS;}
<DYNARE_BLOCK>cutoff {return token::CUTOFF;}
<DYNARE_BLOCK>markowitz {return token::MARKOWITZ;}
<DYNARE_BLOCK>filename {return token::FILENAME;}
<DYNARE_BLOCK>gamma_pdf {return token::GAMMA_PDF;}
<DYNARE_BLOCK>beta_pdf {return token::BETA_PDF;}
<DYNARE_BLOCK>normal_pdf {return token::NORMAL_PDF;}
......
......@@ -153,6 +153,21 @@ HistValStatement::writeOutput(ostream &output, const string &basename) const
}
}
InitvalFileStatement::InitvalFileStatement(const string* const filename_arg):
filename(*filename_arg)
{
}
void InitvalFileStatement::writeOutput(ostream &output, const string &basename) const
{
output << interfaces::comment() << endl
<< interfaces::comment() << "INITVAL_FILE statement" << endl
<< interfaces::comment() << endl
<< "options_.intival_file = 1;" << endl;
output << "initvalf('" << filename << "');" << endl;
}
HomotopyStatement::HomotopyStatement(const homotopy_values_type &homotopy_values_arg,
const SymbolTable &symbol_table_arg) :
homotopy_values(homotopy_values_arg),
......
......@@ -305,10 +305,9 @@ ParsingDriver::init_val(string *name, NodeID rhs)
}
void
ParsingDriver::init_val_filename(string *filename)
ParsingDriver::initval_file(string *filename)
{
options_list.num_options["initval_file"] = "1";
options_list.string_options["initval_filename"] = *filename;
mod_file->addStatement(new InitvalFileStatement(filename));
delete filename;
}
......
......@@ -92,6 +92,15 @@ public:
virtual void writeOutput(ostream &output, const string &basename) const;
};
class InitvalFileStatement : public Statement
{
private:
string filename;
public:
InitvalFileStatement(const string* const filename);
virtual void writeOutput(ostream &output, const string &basename) const;
};
class HomotopyStatement : public Statement
{
public:
......
......@@ -174,7 +174,7 @@ public:
//! Sets the compiler type used in conjunction with SPARCE_DLL
void init_compiler(int compiler_type);
//! Sets the FILENAME for the initial value in initval
void init_val_filename(string *filename);
void initval_file(string *filename);
//! Declares an endogenous variable
void declare_endogenous(string *name, string *tex_name = new string);
//! Declares an exogenous variable
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment