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
P
preprocessor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
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
Dynare
preprocessor
Commits
9b98da42
Unverified
Commit
9b98da42
authored
Mar 19, 2019
by
Sébastien Villemot
Committed by
Stéphane Adjemian (Charybdis)
Mar 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplification in BinaryOpNode::getPacAREC()
parent
4114b8a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
51 deletions
+33
-51
src/ExprNode.cc
src/ExprNode.cc
+33
-51
No files found.
src/ExprNode.cc
View file @
9b98da42
...
...
@@ -5617,63 +5617,45 @@ BinaryOpNode::getPacAREC(int lhs_symb_id, int lhs_orig_symb_id,
for
(
const
auto
&
it
:
terms
)
{
auto
bopn
=
dynamic_cast
<
BinaryOpNode
*>
(
it
.
first
);
auto
pen
=
dynamic_cast
<
PacExpectationNode
*>
(
it
.
first
);
if
(
pen
)
if
(
dynamic_cast
<
PacExpectationNode
*>
(
it
.
first
))
continue
;
if
(
bopn
!=
nullptr
)
int
pid
,
vid
,
lag
;
double
constant
;
try
{
tie
(
vid
,
lag
,
pid
,
constant
)
=
it
.
first
->
matchVariableTimesConstantTimesParam
();
constant
*=
it
.
second
;
}
catch
(
MatchFailureException
&
e
)
{
auto
vn1
=
dynamic_cast
<
VariableNode
*>
(
bopn
->
arg1
);
auto
vn2
=
dynamic_cast
<
VariableNode
*>
(
bopn
->
arg2
);
if
(
vn1
&&
vn2
)
cerr
<<
"Unsupported expression in PAC equation"
<<
endl
;
exit
(
EXIT_FAILURE
);
}
int
vidorig
=
vid
;
while
(
datatree
.
symbol_table
.
isAuxiliaryVariable
(
vid
))
try
{
vid
=
datatree
.
symbol_table
.
getOrigSymbIdForAuxVar
(
vid
);
}
catch
(...)
{
break
;
}
if
(
vid
==
lhs_symb_id
||
vid
==
lhs_orig_symb_id
)
{
// This is an autoregressive term
if
(
constant
!=
1
||
pid
==
-
1
)
{
int
pid
,
vid
,
lag
;
pid
=
vid
=
lag
=
-
1
;
if
(
datatree
.
symbol_table
.
getType
(
vn1
->
symb_id
)
==
SymbolType
::
parameter
&&
(
datatree
.
symbol_table
.
getType
(
vn2
->
symb_id
)
==
SymbolType
::
endogenous
||
datatree
.
symbol_table
.
getType
(
vn2
->
symb_id
)
==
SymbolType
::
exogenous
))
{
pid
=
vn1
->
symb_id
;
vid
=
vn2
->
symb_id
;
lag
=
vn2
->
lag
;
}
else
if
(
datatree
.
symbol_table
.
getType
(
vn2
->
symb_id
)
==
SymbolType
::
parameter
&&
(
datatree
.
symbol_table
.
getType
(
vn1
->
symb_id
)
==
SymbolType
::
endogenous
||
datatree
.
symbol_table
.
getType
(
vn1
->
symb_id
)
==
SymbolType
::
exogenous
))
{
pid
=
vn2
->
symb_id
;
vid
=
vn1
->
symb_id
;
lag
=
vn1
->
lag
;
}
if
(
pid
>=
0
&&
vid
>=
0
)
{
int
vidorig
=
vid
;
while
(
datatree
.
symbol_table
.
isAuxiliaryVariable
(
vid
))
try
{
vid
=
datatree
.
symbol_table
.
getOrigSymbIdForAuxVar
(
vid
);
}
catch
(...)
{
break
;
}
if
(
vid
==
lhs_symb_id
||
vid
==
lhs_orig_symb_id
)
ar_params_and_vars
.
insert
({
pid
,
{
vidorig
,
lag
}});
else
{
auto
m
=
it
.
first
->
matchVariableTimesConstantTimesParam
();
get
<
3
>
(
m
)
*=
it
.
second
;
additive_vars_params_and_constants
.
push_back
(
m
);
}
}
cerr
<<
"BinaryOpNode::getPacAREC: autoregressive terms must be of the form 'parameter*lagged_variable"
<<
endl
;
exit
(
EXIT_FAILURE
);
}
ar_params_and_vars
.
insert
({
pid
,
{
vidorig
,
lag
}});
}
else
{
auto
m
=
it
.
first
->
matchVariableTimesConstantTimesParam
();
get
<
3
>
(
m
)
*=
it
.
second
;
additive_vars_params_and_constants
.
push_back
(
m
);
}
// This is a residual additive term
additive_vars_params_and_constants
.
push_back
({
vidorig
,
lag
,
pid
,
constant
});
}
}
...
...
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