Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dynare
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MichelJuillard
dynare
Commits
f85c43d8
Commit
f85c43d8
authored
Nov 06, 2011
by
MichelJuillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ms-sbvar: fixing more bugs in linear restrictions
parent
35113350
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
27 deletions
+61
-27
preprocessor/DynareBison.yy
preprocessor/DynareBison.yy
+14
-10
preprocessor/ParsingDriver.cc
preprocessor/ParsingDriver.cc
+37
-10
preprocessor/ParsingDriver.hh
preprocessor/ParsingDriver.hh
+10
-7
No files found.
preprocessor/DynareBison.yy
View file @
f85c43d8
...
...
@@ -706,16 +706,20 @@ svar_var_list : svar_var_list COMMA symbol
{ driver.add_in_svar_restriction_symbols($1); }
;
restriction_expression : COEFF '
(
' symbol COMMA INT_NUMBER '
)
'
{ driver.add_positive_restriction_element($3,$5);}
| expression
| MINUS COEFF '
(
' symbol COMMA INT_NUMBER '
)
'
{ driver.add_negative_restriction_element($4,$6);}
| expression TIMES COEFF '
(
' symbol COMMA INT_NUMBER '
)
'
{ driver.add_positive_restriction_element($1,$5,$7);}
| MINUS expression COEFF TIMES '
(
' symbol COMMA INT_NUMBER '
)
'
{ driver.add_negative_restriction_element($2,$6,$8);}
restriction_expression : expression {driver.check_restriction_expression_constant($1);}
| restriction_elem_expression
| restriction_expression restriction_elem_expression
;
restriction_elem_expression : COEFF '
(
' symbol COMMA INT_NUMBER '
)
'
{ driver.add_positive_restriction_element($3,$5);}
| MINUS COEFF '
(
' symbol COMMA INT_NUMBER '
)
'
{ driver.add_negative_restriction_element($4,$6);}
| expression TIMES COEFF '
(
' symbol COMMA INT_NUMBER '
)
'
{ driver.add_positive_restriction_element($1,$5,$7);}
| MINUS expression COEFF TIMES '
(
' symbol COMMA INT_NUMBER '
)
'
{ driver.add_negative_restriction_element($2,$6,$8);}
;
markov_switching : MARKOV_SWITCHING '
(
' ms_options_list '
)
' '
;
'
{ driver.markov_switching(); }
...
...
preprocessor/ParsingDriver.cc
View file @
f85c43d8
...
...
@@ -760,7 +760,8 @@ ParsingDriver::end_svar_identification()
svar_restriction_symbols
.
clear
();
svar_equation_restrictions
.
clear
();
svar_ident_restrictions
.
clear
();
svar_restriction_nbr
.
clear
();
svar_Qi_restriction_nbr
.
clear
();
svar_Ri_restriction_nbr
.
clear
();
}
void
...
...
@@ -780,7 +781,10 @@ ParsingDriver::combine_lag_and_restriction(string *lag)
{
SvarIdentificationStatement
::
svar_identification_restriction
new_restriction
;
new_restriction
.
equation
=
it
->
first
;
new_restriction
.
restriction_nbr
=
++
svar_restriction_nbr
[
it
->
first
];
if
(
current_lag
>
0
)
new_restriction
.
restriction_nbr
=
++
svar_Ri_restriction_nbr
[
it
->
first
];
else
new_restriction
.
restriction_nbr
=
++
svar_Qi_restriction_nbr
[
it
->
first
];
new_restriction
.
lag
=
current_lag
;
new_restriction
.
variable
=
*
it1
;
new_restriction
.
value
=
data_tree
->
One
;
...
...
@@ -829,7 +833,6 @@ void
ParsingDriver
::
add_restriction_equation_nbr
(
string
*
eq_nbr
)
{
svar_equation_nbr
=
atoi
(
eq_nbr
->
c_str
());
++
svar_restriction_nbr
[
svar_equation_nbr
];
svar_left_handside
=
true
;
}
...
...
@@ -852,10 +855,14 @@ ParsingDriver::add_positive_restriction_element(expr_t value, string *variable,
if
(
!
svar_left_handside
)
value
=
add_uminus
(
value
);
int
current_lag
=
atoi
(
lag
->
c_str
());
SvarIdentificationStatement
::
svar_identification_restriction
new_restriction
;
new_restriction
.
equation
=
svar_equation_nbr
;
new_restriction
.
restriction_nbr
=
svar_restriction_nbr
[
svar_equation_nbr
];
new_restriction
.
lag
=
atoi
(
lag
->
c_str
());
if
(
current_lag
>
0
)
new_restriction
.
restriction_nbr
=
++
svar_Ri_restriction_nbr
[
svar_equation_nbr
];
else
new_restriction
.
restriction_nbr
=
++
svar_Qi_restriction_nbr
[
svar_equation_nbr
];
new_restriction
.
lag
=
current_lag
;
new_restriction
.
variable
=
symb_id
;
new_restriction
.
value
=
value
;
...
...
@@ -873,10 +880,14 @@ ParsingDriver::add_positive_restriction_element(string *variable, string *lag)
if
(
!
svar_left_handside
)
value
=
add_uminus
(
value
);
int
current_lag
=
atoi
(
lag
->
c_str
());
SvarIdentificationStatement
::
svar_identification_restriction
new_restriction
;
new_restriction
.
equation
=
svar_equation_nbr
;
new_restriction
.
restriction_nbr
=
svar_restriction_nbr
[
svar_equation_nbr
];
new_restriction
.
lag
=
atoi
(
lag
->
c_str
());
if
(
current_lag
>
0
)
new_restriction
.
restriction_nbr
=
++
svar_Ri_restriction_nbr
[
svar_equation_nbr
];
else
new_restriction
.
restriction_nbr
=
++
svar_Qi_restriction_nbr
[
svar_equation_nbr
];
new_restriction
.
lag
=
current_lag
;
new_restriction
.
variable
=
symb_id
;
new_restriction
.
value
=
value
;
...
...
@@ -893,10 +904,14 @@ ParsingDriver::add_negative_restriction_element(expr_t value, string *variable,
if
(
svar_left_handside
)
value
=
add_uminus
(
value
);
int
current_lag
=
atoi
(
lag
->
c_str
());
SvarIdentificationStatement
::
svar_identification_restriction
new_restriction
;
new_restriction
.
equation
=
svar_equation_nbr
;
new_restriction
.
restriction_nbr
=
svar_restriction_nbr
[
svar_equation_nbr
];
new_restriction
.
lag
=
atoi
(
lag
->
c_str
());
if
(
current_lag
>
0
)
new_restriction
.
restriction_nbr
=
++
svar_Ri_restriction_nbr
[
svar_equation_nbr
];
else
new_restriction
.
restriction_nbr
=
++
svar_Qi_restriction_nbr
[
svar_equation_nbr
];
new_restriction
.
lag
=
current_lag
;
new_restriction
.
variable
=
symb_id
;
new_restriction
.
value
=
value
;
...
...
@@ -914,15 +929,27 @@ ParsingDriver::add_negative_restriction_element(string *variable, string *lag)
if
(
svar_left_handside
)
value
=
add_uminus
(
value
);
int
current_lag
=
atoi
(
lag
->
c_str
());
SvarIdentificationStatement
::
svar_identification_restriction
new_restriction
;
new_restriction
.
equation
=
svar_equation_nbr
;
new_restriction
.
lag
=
atoi
(
lag
->
c_str
());
if
(
current_lag
>
0
)
new_restriction
.
restriction_nbr
=
++
svar_Ri_restriction_nbr
[
svar_equation_nbr
];
else
new_restriction
.
restriction_nbr
=
++
svar_Qi_restriction_nbr
[
svar_equation_nbr
];
new_restriction
.
lag
=
current_lag
;
new_restriction
.
variable
=
symb_id
;
new_restriction
.
value
=
value
;
svar_ident_restrictions
.
push_back
(
new_restriction
);
}
void
ParsingDriver
::
check_restriction_expression_constant
(
expr_t
value
)
{
if
(
value
->
eval
(
eval_context_t
())
!=
0
)
error
(
"SVAR_INDENTIFICATION restrictions must be homogenous"
);
}
void
ParsingDriver
::
add_upper_cholesky
()
{
...
...
preprocessor/ParsingDriver.hh
View file @
f85c43d8
...
...
@@ -157,7 +157,8 @@ private:
//! Temporary storage for left/right handside of a restriction equation within an svar_identificaton block
bool
svar_left_handside
;
//! Temporary storage for current restriction number in svar_identification block
map
<
int
,
int
>
svar_restriction_nbr
;
map
<
int
,
int
>
svar_Qi_restriction_nbr
;
map
<
int
,
int
>
svar_Ri_restriction_nbr
;
//! Temporary storage for argument list of external function
stack
<
vector
<
expr_t
>
>
stack_external_function_args
;
...
...
@@ -365,18 +366,20 @@ public:
void
add_in_svar_restriction_symbols
(
string
*
name
);
//! Svar_Identification Statement: add exclusions of constants
void
add_constants_exclusion
();
//! Svar_Identification Statment: add equation number for following restriction equations
//! Svar_Identification Stat
e
ment: add equation number for following restriction equations
void
add_restriction_equation_nbr
(
string
*
eq_nbr
);
//! Svar_Identification Statment: record presence of equal sign
//! Svar_Identification Stat
e
ment: record presence of equal sign
void
add_restriction_equal
();
//! Svar_Idenditification Stat
mene
t: add coefficient of a linear restriction (positive value)
//! Svar_Idenditification Stat
emen
t: add coefficient of a linear restriction (positive value)
void
add_positive_restriction_element
(
expr_t
value
,
string
*
variable
,
string
*
lag
);
//! Svar_Idenditification Stat
mene
t: add unit coefficient of a linear restriction
//! Svar_Idenditification Stat
emen
t: add unit coefficient of a linear restriction
void
add_positive_restriction_element
(
string
*
variable
,
string
*
lag
);
//! Svar_Idenditification Stat
mene
t: add coefficient of a linear restriction (negative value)
//! Svar_Idenditification Stat
emen
t: add coefficient of a linear restriction (negative value)
void
add_negative_restriction_element
(
expr_t
value
,
string
*
variable
,
string
*
lag
);
//! Svar_Idenditification Stat
mene
t: add negative unit coefficient of a linear restriction
//! Svar_Idenditification Stat
emen
t: add negative unit coefficient of a linear restriction
void
add_negative_restriction_element
(
string
*
variable
,
string
*
lag
);
//! Svar_Identification Statement: check that restriction is homogenous
void
check_restriction_expression_constant
(
expr_t
value
);
//! Svar_Identification Statement: restriction of form upper cholesky
void
add_upper_cholesky
();
//! Svar_Identification Statement: restriction of form lower cholesky
...
...
Write
Preview
Markdown
is supported
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