Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Dynare
preprocessor
Commits
5546658b
Commit
5546658b
authored
Apr 27, 2010
by
Sébastien Villemot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preprocessor: with 'steady_state_model' command, write auxiliary equations in the steady state file
parent
d68e984f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
12 deletions
+18
-12
ModFile.cc
ModFile.cc
+3
-3
ModFile.hh
ModFile.hh
+2
-2
StaticModel.cc
StaticModel.cc
+2
-2
StaticModel.hh
StaticModel.hh
+2
-2
SteadyStateModel.cc
SteadyStateModel.cc
+4
-2
SteadyStateModel.hh
SteadyStateModel.hh
+5
-1
No files found.
ModFile.cc
View file @
5546658b
...
...
@@ -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
...
...
ModFile.hh
View file @
5546658b
...
...
@@ -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
;
...
...
StaticModel.cc
View file @
5546658b
...
...
@@ -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
;
}
}
StaticModel.hh
View file @
5546658b
...
...
@@ -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
();
...
...
SteadyStateModel.cc
View file @
5546658b
...
...
@@ -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
;
}
...
...
SteadyStateModel.hh
View file @
5546658b
...
...
@@ -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
...
...
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