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
b3602541
Commit
b3602541
authored
Apr 27, 2010
by
Sébastien Villemot
Browse files
Preprocessor: with 'steady_state_model' command, write auxiliary equations in the steady state file
parent
37abe362
Changes
7
Hide whitespace changes
Inline
Side-by-side
preprocessor/ModFile.cc
View file @
b3602541
...
...
@@ -24,9 +24,9 @@
#include "ModFile.hh"
ModFile
::
ModFile
()
:
expressions_tree
(
symbol_table
,
num_constants
,
external_functions_table
),
steady_state_model
(
symbol_table
,
num_constants
,
external_functions_table
),
dynamic_model
(
symbol_table
,
num_constants
,
external_functions_table
),
static_model
(
symbol_table
,
num_constants
,
external_functions_table
),
steady_state_model
(
symbol_table
,
num_constants
,
external_functions_table
,
static_model
),
linear
(
false
),
block
(
false
),
byte_code
(
false
),
use_dll
(
false
),
no_static
(
false
)
{
...
...
@@ -402,14 +402,14 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all
InitValStatement
*
ivs
=
dynamic_cast
<
InitValStatement
*>
(
*
it
);
if
(
ivs
!=
NULL
)
{
static_model
.
writeAuxVarInitval
(
mOutputFile
);
static_model
.
writeAuxVarInitval
(
mOutputFile
,
oMatlabOutsideModel
);
ivs
->
writeOutputPostInit
(
mOutputFile
);
}
// Special treatment for load params and steady state statement: insert initial values for the auxiliary variables
LoadParamsAndSteadyStateStatement
*
lpass
=
dynamic_cast
<
LoadParamsAndSteadyStateStatement
*>
(
*
it
);
if
(
lpass
&&
!
no_static
)
static_model
.
writeAuxVarInitval
(
mOutputFile
);
static_model
.
writeAuxVarInitval
(
mOutputFile
,
oMatlabOutsideModel
);
}
// Remove path for block option with M-files
...
...
preprocessor/ModFile.hh
View file @
b3602541
...
...
@@ -48,12 +48,12 @@ public:
NumericalConstants
num_constants
;
//! Expressions outside model block
DataTree
expressions_tree
;
//! Static model, as declared in the "steady_state_model" block if present
SteadyStateModel
steady_state_model
;
//! Dynamic model, as declared in the "model" block
DynamicModel
dynamic_model
;
//! Static model, as derived from the "model" block when leads and lags have been removed
StaticModel
static_model
;
//! Static model, as declared in the "steady_state_model" block if present
SteadyStateModel
steady_state_model
;
//! Option linear
bool
linear
;
...
...
preprocessor/StaticModel.cc
View file @
b3602541
...
...
@@ -1362,11 +1362,11 @@ StaticModel::hessianHelper(ostream &output, int row_nb, int col_nb, ExprNodeOutp
}
void
StaticModel
::
writeAuxVarInitval
(
ostream
&
output
)
const
StaticModel
::
writeAuxVarInitval
(
ostream
&
output
,
ExprNodeOutputType
output_type
)
const
{
for
(
int
i
=
0
;
i
<
(
int
)
aux_equations
.
size
();
i
++
)
{
dynamic_cast
<
ExprNode
*>
(
aux_equations
[
i
])
->
writeOutput
(
output
);
dynamic_cast
<
ExprNode
*>
(
aux_equations
[
i
])
->
writeOutput
(
output
,
output_type
);
output
<<
";"
<<
endl
;
}
}
preprocessor/StaticModel.hh
View file @
b3602541
...
...
@@ -187,8 +187,8 @@ public:
//! Writes LaTeX file with the equations of the static model
void
writeLatexFile
(
const
string
&
basename
)
const
;
//! Writes initializations in oo_.steady_state for the auxiliary variables
void
writeAuxVarInitval
(
ostream
&
output
)
const
;
//! Writes initializations in oo_.steady_state
or steady state file
for the auxiliary variables
void
writeAuxVarInitval
(
ostream
&
output
,
ExprNodeOutputType
output_type
)
const
;
//! Initialize equation_reordered & variable_reordered
void
initializeVariablesAndEquations
();
...
...
preprocessor/SteadyStateModel.cc
View file @
b3602541
...
...
@@ -22,8 +22,8 @@
#include "SteadyStateModel.hh"
SteadyStateModel
::
SteadyStateModel
(
SymbolTable
&
symbol_table_arg
,
NumericalConstants
&
num_constants
,
ExternalFunctionsTable
&
external_functions_table_arg
)
:
DataTree
(
symbol_table_arg
,
num_constants
,
external_functions_table
)
SteadyStateModel
::
SteadyStateModel
(
SymbolTable
&
symbol_table_arg
,
NumericalConstants
&
num_constants
,
ExternalFunctionsTable
&
external_functions_table_arg
,
const
StaticModel
&
static_model_arg
)
:
DataTree
(
symbol_table_arg
,
num_constants
,
external_functions_table
)
,
static_model
(
static_model_arg
)
{
}
...
...
@@ -81,6 +81,8 @@ SteadyStateModel::writeSteadyStateFile(const string &basename) const
it
->
second
->
writeOutput
(
output
,
oSteadyStateFile
);
output
<<
";"
<<
endl
;
}
output
<<
" % Auxiliary equations"
<<
endl
;
static_model
.
writeAuxVarInitval
(
output
,
oSteadyStateFile
);
output
<<
" check_=0;"
<<
endl
<<
"end"
<<
endl
;
}
...
...
preprocessor/SteadyStateModel.hh
View file @
b3602541
...
...
@@ -21,6 +21,7 @@
#define _STEADY_STATE_MODEL_HH
#include "DataTree.hh"
#include "StaticModel.hh"
class
SteadyStateModel
:
public
DataTree
{
...
...
@@ -29,6 +30,9 @@ private:
map
<
int
,
NodeID
>
def_table
;
vector
<
int
>
recursive_order
;
//! Reference to static model (for writing auxiliary equations)
const
StaticModel
&
static_model
;
public:
class
AlreadyDefinedException
{
...
...
@@ -43,7 +47,7 @@ public:
UndefinedVariableException
(
const
string
&
varname_arg
)
:
varname
(
varname_arg
)
{}
};
SteadyStateModel
(
SymbolTable
&
symbol_table_arg
,
NumericalConstants
&
num_constants
,
ExternalFunctionsTable
&
external_functions_table_arg
);
SteadyStateModel
(
SymbolTable
&
symbol_table_arg
,
NumericalConstants
&
num_constants
,
ExternalFunctionsTable
&
external_functions_table_arg
,
const
StaticModel
&
static_model_arg
);
//! Add an expression of the form "var = expr;"
void
addDefinition
(
int
symb_id
,
NodeID
expr
)
throw
(
UndefinedVariableException
,
AlreadyDefinedException
);
//! Write the steady state file
...
...
tests/fs2000_ssfile.mod
View file @
b3602541
...
...
@@ -61,3 +61,6 @@ steady_state_model;
end;
steady;
// Launch stoch_simul in order to have auxiliary variables created for leads of 2
stoch_simul(nograph);
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