Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
29bead75
Commit
29bead75
authored
Nov 29, 2011
by
Houtan Bastani
Browse files
preprocessor: add set_time command
parent
75e12577
Changes
9
Hide whitespace changes
Inline
Side-by-side
matlab/global_initialization.m
View file @
29bead75
...
...
@@ -182,6 +182,7 @@ options_.ramsey_policy = 0;
options_
.
timeless
=
0
;
% estimation
options_
.
initial_period
=
dynDate
(
1
);
options_
.
Harvey_scale_factor
=
10
;
options_
.
MaxNumberOfBytes
=
1e6
;
options_
.
MaximumNumberOfMegaBytes
=
111
;
...
...
preprocessor/ComputingTasks.cc
View file @
29bead75
...
...
@@ -1431,3 +1431,14 @@ SvarStatement::writeOutput(ostream &output, const string &basename) const
else
output
<<
"'ALL';"
<<
endl
;
}
SetTimeStatement
::
SetTimeStatement
(
const
OptionsList
&
options_list_arg
)
:
options_list
(
options_list_arg
)
{
}
void
SetTimeStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
{
options_list
.
writeOutput
(
output
);
}
preprocessor/ComputingTasks.hh
View file @
29bead75
...
...
@@ -556,4 +556,14 @@ public:
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
;
};
class
SetTimeStatement
:
public
Statement
{
private:
const
OptionsList
options_list
;
public:
SetTimeStatement
(
const
OptionsList
&
options_list_arg
);
virtual
void
writeOutput
(
ostream
&
output
,
const
string
&
basename
)
const
;
};
#endif
preprocessor/DynareBison.yy
View file @
29bead75
...
...
@@ -96,13 +96,14 @@ class ParsingDriver;
%token CHANGE_TYPE CHECK CONDITIONAL_FORECAST CONDITIONAL_FORECAST_PATHS CONF_SIG CONSTANT CONTROLLED_VAREXO CORR COVAR CUTOFF
%token DATAFILE DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE CALIBRATION
%token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT
%token FILENAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS
%token FILENAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS
SET_TIME
%token <string_val> FLOAT_NUMBER
%token FORECAST K_ORDER_SOLVER INSTRUMENTS
%token GAMMA_PDF GRAPH CONDITIONAL_VARIANCE_DECOMPOSITION NOCHECK
%token HISTVAL HOMOTOPY_SETUP HOMOTOPY_MODE HOMOTOPY_STEPS HP_FILTER HP_NGRID
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE
%token <string_val> INT_NUMBER
%token <string_val> DATE_NUMBER
%token INV_GAMMA_PDF INV_GAMMA1_PDF INV_GAMMA2_PDF IRF IRF_SHOCKS
%token KALMAN_ALGO KALMAN_TOL
%token LABELS LAPLACE LIK_ALGO LIK_INIT LINEAR LOAD_IDENT_FILES LOAD_MH_FILE LOAD_PARAMS_AND_STEADY_STATE LOGLINEAR
...
...
@@ -173,7 +174,7 @@ class ParsingDriver;
%type <node_val> expression expression_or_empty
%type <node_val> equation hand_side
%type <string_val> non_negative_number signed_number signed_integer
%type <string_val> non_negative_number signed_number signed_integer
date_number
%type <string_val> filename symbol
%type <string_val> vec_value_1 vec_value
%type <string_val> range prior
...
...
@@ -213,6 +214,7 @@ statement : parameters
| estimated_params
| estimated_params_bounds
| estimated_params_init
| set_time
| varobs
| observation_trends
| unit_root_vars
...
...
@@ -963,6 +965,10 @@ non_negative_number : INT_NUMBER
| FLOAT_NUMBER
;
date_number : DATE_NUMBER
| INT_NUMBER
;
signed_number : PLUS non_negative_number
{ $$ = $2; }
| MINUS non_negative_number
...
...
@@ -1153,6 +1159,10 @@ prior : BETA_PDF
{ $$ = new string("6"); }
;
set_time : SET_TIME '
(
' date_number '
)
' '
;
'
{ driver.set_time($3); }
;
estimation : ESTIMATION '
;
'
{ driver.run_estimation(); }
| ESTIMATION '
(
' estimation_options_list '
)
' '
;
'
...
...
preprocessor/DynareFlex.ll
View file @
29bead75
...
...
@@ -108,6 +108,7 @@ string eofbuff;
<INITIAL>periods {BEGIN DYNARE_STATEMENT; return token::PERIODS;}
<INITIAL>model_info {BEGIN DYNARE_STATEMENT; return token::MODEL_INFO;}
<INITIAL>estimation {BEGIN DYNARE_STATEMENT; return token::ESTIMATION;}
<INITIAL>set_time {BEGIN DYNARE_STATEMENT; return token::SET_TIME;}
<INITIAL>varobs {BEGIN DYNARE_STATEMENT; return token::VAROBS;}
<INITIAL>unit_root_vars {BEGIN DYNARE_STATEMENT; return token::UNIT_ROOT_VARS;}
<INITIAL>rplot {BEGIN DYNARE_STATEMENT; return token::RPLOT;}
...
...
@@ -591,6 +592,11 @@ string eofbuff;
return token::INT_NUMBER;
}
<DYNARE_STATEMENT,DYNARE_BLOCK>([1-2][0-9]{3}[Mm](([1-9])|(1[0-2])))|([1-2][0-9]{3}[Qq][1-4])|([1-2][0-9]{3}[Ww](([1-9]{1})|([1-5][0-9]))) {
yylval->string_val = new string(yytext);
return token::DATE_NUMBER;
}
<DYNARE_STATEMENT,DYNARE_BLOCK>\'[^\']+\' {
yylval->string_val = new string(yytext + 1);
yylval->string_val->resize(yylval->string_val->length() - 1);
...
...
preprocessor/ParsingDriver.cc
View file @
29bead75
...
...
@@ -1056,6 +1056,23 @@ ParsingDriver::option_str(const string &name_option, const string &opt)
options_list
.
string_options
[
name_option
]
=
opt
;
}
void
ParsingDriver
::
option_date
(
const
string
&
name_option
,
string
*
opt
)
{
option_date
(
name_option
,
*
opt
);
delete
opt
;
}
void
ParsingDriver
::
option_date
(
const
string
&
name_option
,
const
string
&
opt
)
{
if
(
options_list
.
date_options
.
find
(
name_option
)
!=
options_list
.
date_options
.
end
())
error
(
"option "
+
name_option
+
" declared twice"
);
options_list
.
date_options
[
name_option
]
=
opt
;
}
void
ParsingDriver
::
option_symbol_list
(
const
string
&
name_option
)
{
...
...
@@ -1184,6 +1201,17 @@ ParsingDriver::set_unit_root_vars()
symbol_list
.
clear
();
}
void
ParsingDriver
::
set_time
(
string
*
arg
)
{
string
arg1
=
*
arg
;
for
(
size_t
i
=
0
;
i
<
arg1
.
length
();
i
++
)
arg1
[
i
]
=
toupper
(
arg1
[
i
]);
option_date
(
"initial_period"
,
arg1
);
mod_file
->
addStatement
(
new
SetTimeStatement
(
options_list
));
options_list
.
clear
();
}
void
ParsingDriver
::
run_estimation
()
{
...
...
preprocessor/ParsingDriver.hh
View file @
29bead75
...
...
@@ -319,6 +319,10 @@ public:
void
option_str
(
const
string
&
name_option
,
string
*
opt
);
//! Sets an option to a string value
void
option_str
(
const
string
&
name_option
,
const
string
&
opt
);
//! Sets an option to a date value
void
option_date
(
const
string
&
name_option
,
string
*
opt
);
//! Sets an option to a date value
void
option_date
(
const
string
&
name_option
,
const
string
&
opt
);
//! Sets an option to a list of symbols (used in conjunction with add_in_symbol_list())
void
option_symbol_list
(
const
string
&
name_option
);
//! Sets an option to a vector of integers
...
...
@@ -351,6 +355,8 @@ public:
void
external_function_option
(
const
string
&
name_option
,
const
string
&
opt
);
//! Add a line in an estimated params block
void
add_estimated_params_element
();
//! Sets the frequency of the data
void
set_time
(
string
*
arg
);
//! Runs estimation process
void
run_estimation
();
//! Runs dynare_sensitivy()
...
...
preprocessor/Statement.cc
View file @
29bead75
...
...
@@ -88,6 +88,10 @@ OptionsList::writeOutput(ostream &output) const
it
!=
string_options
.
end
();
it
++
)
output
<<
"options_."
<<
it
->
first
<<
" = '"
<<
it
->
second
<<
"';"
<<
endl
;
for
(
date_options_t
::
const_iterator
it
=
date_options
.
begin
();
it
!=
date_options
.
end
();
it
++
)
output
<<
"options_."
<<
it
->
first
<<
" = dynDate('"
<<
it
->
second
<<
"');"
<<
endl
;
for
(
symbol_list_options_t
::
const_iterator
it
=
symbol_list_options
.
begin
();
it
!=
symbol_list_options
.
end
();
it
++
)
it
->
second
.
writeOutput
(
"options_."
+
it
->
first
,
output
);
...
...
@@ -127,6 +131,10 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const
it
!=
string_options
.
end
();
it
++
)
output
<<
option_group
<<
"."
<<
it
->
first
<<
" = '"
<<
it
->
second
<<
"';"
<<
endl
;
for
(
date_options_t
::
const_iterator
it
=
date_options
.
begin
();
it
!=
date_options
.
end
();
it
++
)
output
<<
option_group
<<
"."
<<
it
->
first
<<
" = dynDate('"
<<
it
->
second
<<
"');"
<<
endl
;
for
(
symbol_list_options_t
::
const_iterator
it
=
symbol_list_options
.
begin
();
it
!=
symbol_list_options
.
end
();
it
++
)
it
->
second
.
writeOutput
(
option_group
+
"."
+
it
->
first
,
output
);
...
...
@@ -154,6 +162,7 @@ OptionsList::clear()
num_options
.
clear
();
paired_num_options
.
clear
();
string_options
.
clear
();
date_options
.
clear
();
symbol_list_options
.
clear
();
vector_int_options
.
clear
();
}
preprocessor/Statement.hh
View file @
29bead75
...
...
@@ -118,11 +118,13 @@ public:
typedef
map
<
string
,
string
>
num_options_t
;
typedef
map
<
string
,
pair
<
string
,
string
>
>
paired_num_options_t
;
typedef
map
<
string
,
string
>
string_options_t
;
typedef
map
<
string
,
string
>
date_options_t
;
typedef
map
<
string
,
SymbolList
>
symbol_list_options_t
;
typedef
map
<
string
,
vector
<
int
>
>
vec_int_options_t
;
num_options_t
num_options
;
paired_num_options_t
paired_num_options
;
string_options_t
string_options
;
date_options_t
date_options
;
symbol_list_options_t
symbol_list_options
;
vec_int_options_t
vector_int_options
;
void
writeOutput
(
ostream
&
output
)
const
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment