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
49bdcef6
Commit
49bdcef6
authored
Apr 28, 2010
by
Sébastien Villemot
Browse files
Preprocessor: replace non-standard operators 'and'/'or' by '&&'/'||'
parent
956b42fd
Changes
3
Show whitespace changes
Inline
Side-by-side
preprocessor/DynamicModel.cc
View file @
49bdcef6
...
...
@@ -619,7 +619,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
ostringstream
tmp_output
;
NodeID
id
=
it
->
second
.
second
;
int
lag
=
it
->
second
.
first
;
if
(
eq
>=
block_recursive
and
var
>=
block_recursive
)
if
(
eq
>=
block_recursive
&&
var
>=
block_recursive
)
{
if
(
lag
==
0
)
Uf
[
eqr
]
<<
"+g1("
<<
eq
+
1
-
block_recursive
...
...
@@ -1043,7 +1043,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin
unsigned
int
eqr
=
getBlockEquationID
(
block
,
eq
);
unsigned
int
varr
=
getBlockVariableID
(
block
,
var
);
int
lag
=
it
->
second
.
first
;
if
(
eq
>=
block_recursive
and
var
>=
block_recursive
)
if
(
eq
>=
block_recursive
&&
var
>=
block_recursive
)
{
if
(
!
Uf
[
eqr
].
Ufl
)
{
...
...
@@ -1279,7 +1279,7 @@ DynamicModel::Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const
unsigned
int
eq
=
it
->
first
.
first
;
unsigned
int
var
=
it
->
first
.
second
;
int
lag
=
it
->
second
.
first
;
if
(
eq
>=
block_recursive
and
var
>=
block_recursive
)
if
(
eq
>=
block_recursive
&&
var
>=
block_recursive
)
{
int
v
=
eq
-
block_recursive
;
SaveCode
.
write
(
reinterpret_cast
<
char
*>
(
&
v
),
sizeof
(
v
));
...
...
@@ -2208,7 +2208,7 @@ DynamicModel::get_Derivatives(int block)
if
(
OK
)
{
if
(
getBlockEquationType
(
block
,
eq
)
==
E_EVALUATE_S
and
eq
<
block_nb_recursive
)
if
(
getBlockEquationType
(
block
,
eq
)
==
E_EVALUATE_S
&&
eq
<
block_nb_recursive
)
//It's a normalized equation, we have to recompute the derivative using chain rule derivative function
Derivatives
[
make_pair
(
make_pair
(
lag
,
make_pair
(
eq
,
var
)),
make_pair
(
eqr
,
varr
))]
=
1
;
else
...
...
@@ -2247,7 +2247,7 @@ DynamicModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
int
block_size
=
getBlockSize
(
block
);
int
block_nb_mfs
=
getBlockMfs
(
block
);
int
block_nb_recursives
=
block_size
-
block_nb_mfs
;
if
(
simulation_type
==
SOLVE_TWO_BOUNDARIES_COMPLETE
or
simulation_type
==
SOLVE_TWO_BOUNDARIES_SIMPLE
)
if
(
simulation_type
==
SOLVE_TWO_BOUNDARIES_COMPLETE
||
simulation_type
==
SOLVE_TWO_BOUNDARIES_SIMPLE
)
{
blocks_derivatives
.
push_back
(
t_block_derivatives_equation_variable_laglead_nodeid
(
0
));
for
(
int
i
=
0
;
i
<
block_nb_recursives
;
i
++
)
...
...
@@ -2283,8 +2283,8 @@ DynamicModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
tmp_derivatives
.
push_back
(
make_pair
(
make_pair
(
eq
,
var
),
make_pair
(
lag
,
first_chain_rule_derivatives
[
make_pair
(
eqr
,
make_pair
(
varr
,
lag
))])));
}
}
else
if
(
simulation_type
==
SOLVE_BACKWARD_SIMPLE
or
simulation_type
==
SOLVE_FORWARD_SIMPLE
or
simulation_type
==
SOLVE_BACKWARD_COMPLETE
or
simulation_type
==
SOLVE_FORWARD_COMPLETE
)
else
if
(
simulation_type
==
SOLVE_BACKWARD_SIMPLE
||
simulation_type
==
SOLVE_FORWARD_SIMPLE
||
simulation_type
==
SOLVE_BACKWARD_COMPLETE
||
simulation_type
==
SOLVE_FORWARD_COMPLETE
)
{
blocks_derivatives
.
push_back
(
t_block_derivatives_equation_variable_laglead_nodeid
(
0
));
for
(
int
i
=
0
;
i
<
block_nb_recursives
;
i
++
)
...
...
preprocessor/ModelTree.cc
View file @
49bdcef6
...
...
@@ -582,9 +582,11 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(jacob_map &
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
if
(
Equation_Type
[
equation_reordered
[
i
+
prologue
]].
first
==
E_SOLVE
or
variable_lag_lead
[
variable_reordered
[
i
+
prologue
]].
second
>
0
or
variable_lag_lead
[
variable_reordered
[
i
+
prologue
]].
first
>
0
or
equation_lag_lead
[
equation_reordered
[
i
+
prologue
]].
second
>
0
or
equation_lag_lead
[
equation_reordered
[
i
+
prologue
]].
first
>
0
or
mfs
==
0
)
||
variable_lag_lead
[
variable_reordered
[
i
+
prologue
]].
second
>
0
||
variable_lag_lead
[
variable_reordered
[
i
+
prologue
]].
first
>
0
||
equation_lag_lead
[
equation_reordered
[
i
+
prologue
]].
second
>
0
||
equation_lag_lead
[
equation_reordered
[
i
+
prologue
]].
first
>
0
||
mfs
==
0
)
add_edge
(
i
,
i
,
G2
);
}
else
...
...
@@ -737,7 +739,7 @@ ModelTree::reduceBlocksAndTypeDetermination(dynamic_jacob_map &dynamic_jacobian,
}
if
(
Blck_Size
==
1
)
{
if
(
Equation_Type
[
equation_reordered
[
eq
]].
first
==
E_EVALUATE
or
Equation_Type
[
equation_reordered
[
eq
]].
first
==
E_EVALUATE_S
)
if
(
Equation_Type
[
equation_reordered
[
eq
]].
first
==
E_EVALUATE
||
Equation_Type
[
equation_reordered
[
eq
]].
first
==
E_EVALUATE_S
)
{
if
(
Simulation_Type
==
SOLVE_BACKWARD_SIMPLE
)
Simulation_Type
=
EVALUATE_BACKWARD
;
...
...
@@ -746,8 +748,8 @@ ModelTree::reduceBlocksAndTypeDetermination(dynamic_jacob_map &dynamic_jacobian,
}
if
(
i
>
0
)
{
if
((
prev_Type
==
EVALUATE_FORWARD
and
Simulation_Type
==
EVALUATE_FORWARD
)
or
(
prev_Type
==
EVALUATE_BACKWARD
and
Simulation_Type
==
EVALUATE_BACKWARD
))
if
((
prev_Type
==
EVALUATE_FORWARD
&&
Simulation_Type
==
EVALUATE_FORWARD
)
||
(
prev_Type
==
EVALUATE_BACKWARD
&&
Simulation_Type
==
EVALUATE_BACKWARD
))
{
//merge the current block with the previous one
BlockSimulationType
c_Type
=
(
block_type_size_mfs
[
block_type_size_mfs
.
size
()
-
1
]).
first
.
first
;
...
...
preprocessor/StaticModel.cc
View file @
49bdcef6
...
...
@@ -694,7 +694,7 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string
unsigned
int
var
=
it
->
first
.
second
;
unsigned
int
eqr
=
getBlockEquationID
(
block
,
eq
);
unsigned
int
varr
=
getBlockVariableID
(
block
,
var
);
if
(
eq
>=
block_recursive
and
var
>=
block_recursive
)
if
(
eq
>=
block_recursive
&&
var
>=
block_recursive
)
{
if
(
!
Uf
[
eqr
].
Ufl
)
{
...
...
@@ -793,7 +793,7 @@ StaticModel::Write_Inf_To_Bin_File_Block(const string &static_basename, const st
unsigned
int
eq
=
it
->
first
.
first
;
unsigned
int
var
=
it
->
first
.
second
;
int
lag
=
0
;
if
(
eq
>=
block_recursive
and
var
>=
block_recursive
)
if
(
eq
>=
block_recursive
&&
var
>=
block_recursive
)
{
int
v
=
eq
-
block_recursive
;
SaveCode
.
write
(
reinterpret_cast
<
char
*>
(
&
v
),
sizeof
(
v
));
...
...
@@ -1173,7 +1173,7 @@ StaticModel::get_Derivatives(int block)
if
(
OK
)
{
if
(
getBlockEquationType
(
block
,
eq
)
==
E_EVALUATE_S
and
eq
<
block_nb_recursive
)
if
(
getBlockEquationType
(
block
,
eq
)
==
E_EVALUATE_S
&&
eq
<
block_nb_recursive
)
//It's a normalized equation, we have to recompute the derivative using chain rule derivative function
Derivatives
[
make_pair
(
make_pair
(
lag
,
make_pair
(
eq
,
var
)),
make_pair
(
eqr
,
varr
))]
=
1
;
else
...
...
@@ -1212,7 +1212,7 @@ StaticModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
int
block_size
=
getBlockSize
(
block
);
int
block_nb_mfs
=
getBlockMfs
(
block
);
int
block_nb_recursives
=
block_size
-
block_nb_mfs
;
if
(
simulation_type
==
SOLVE_TWO_BOUNDARIES_COMPLETE
or
simulation_type
==
SOLVE_TWO_BOUNDARIES_SIMPLE
)
if
(
simulation_type
==
SOLVE_TWO_BOUNDARIES_COMPLETE
||
simulation_type
==
SOLVE_TWO_BOUNDARIES_SIMPLE
)
{
blocks_derivatives
.
push_back
(
t_block_derivatives_equation_variable_laglead_nodeid
(
0
));
for
(
int
i
=
0
;
i
<
block_nb_recursives
;
i
++
)
...
...
@@ -1248,8 +1248,8 @@ StaticModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
tmp_derivatives
.
push_back
(
make_pair
(
make_pair
(
eq
,
var
),
make_pair
(
lag
,
first_chain_rule_derivatives
[
make_pair
(
eqr
,
make_pair
(
varr
,
lag
))])));
}
}
else
if
(
simulation_type
==
SOLVE_BACKWARD_SIMPLE
or
simulation_type
==
SOLVE_FORWARD_SIMPLE
or
simulation_type
==
SOLVE_BACKWARD_COMPLETE
or
simulation_type
==
SOLVE_FORWARD_COMPLETE
)
else
if
(
simulation_type
==
SOLVE_BACKWARD_SIMPLE
||
simulation_type
==
SOLVE_FORWARD_SIMPLE
||
simulation_type
==
SOLVE_BACKWARD_COMPLETE
||
simulation_type
==
SOLVE_FORWARD_COMPLETE
)
{
blocks_derivatives
.
push_back
(
t_block_derivatives_equation_variable_laglead_nodeid
(
0
));
for
(
int
i
=
0
;
i
<
block_nb_recursives
;
i
++
)
...
...
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