v4 matlab+preprocessor: the three homotopy modes should now work

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1769 ac1d8469-bf42-47a9-8791-bf33cf982152
issue#70
sebastien 2008-03-31 16:19:16 +00:00
parent 95d2118111
commit 47c22072f0
4 changed files with 12 additions and 25 deletions

View File

@ -154,7 +154,7 @@ HistValStatement::writeOutput(ostream &output, const string &basename) const
}
HomotopyStatement::HomotopyStatement(const homotopy_values_type &homotopy_values_arg,
const SymbolTable &symbol_table_arg) :
const SymbolTable &symbol_table_arg) :
homotopy_values(homotopy_values_arg),
symbol_table(symbol_table_arg)
{
@ -163,11 +163,10 @@ HomotopyStatement::HomotopyStatement(const homotopy_values_type &homotopy_values
void
HomotopyStatement::writeOutput(ostream &output, const string &basename) const
{
output << interfaces::comment() << "\n" << interfaces::comment() << "HOMOTOPY_SETUP instructions\n"
<< interfaces::comment() << "\n";
output << "homotopy_param = {};" << endl;
output << "homotopy_exo = {};" << endl;
output << "homotopy_exodet = {};" << endl;
output << interfaces::comment() << endl
<< interfaces::comment() << "HOMOTOPY_SETUP instructions" << endl
<< interfaces::comment() << endl
<< "options_.homotopy_values = [];" << endl;
for(homotopy_values_type::const_iterator it = homotopy_values.begin();
it != homotopy_values.end(); it++)
@ -176,24 +175,13 @@ HomotopyStatement::writeOutput(ostream &output, const string &basename) const
const NodeID expression1 = it->second.first;
const NodeID expression2 = it->second.second;
Type type = symbol_table.getType(name);
const Type type = symbol_table.getType(name);
const int id = symbol_table.getID(name) + 1;
if (type == eParameter)
output << "homotopy_param = vertcat(homotopy_param,{ '" << name << "', ";
else if (type == eExogenous)
output << "homotopy_exo = vertcat(homotopy_exo,{ '" << name << "', ";
else if (type != eExogenousDet)
output << "homotopy_exodet = vertcat(homotopy_exodet,{ '" << name << "', ";
output << "options_.homotopy_values = vertcat(options_.homotopy_values, [ " << type << ", " << id << ", ";
expression1->writeOutput(output);
output << ", ";
expression2->writeOutput(output);
output << "});" << endl;
output << "]);" << endl;
}
output << "options_.homotopy_param = homotopy_param;" << endl;
output << "options_.homotopy_exo = homotopy_exo;" << endl;
output << "options_.homotopy_exodet = homotopy_exodet;" << endl;
}

View File

@ -350,8 +350,7 @@ ParsingDriver::homotopy_val(string *name, NodeID val1, NodeID val2)
if (homotopy_values.find(*name) != homotopy_values.end())
error("homotopy_val: " + *name +" declared twice");
pair<NodeID, NodeID> expressions(val1, val2);
homotopy_values[*name] = expressions;
homotopy_values[*name] = make_pair(val1, val2);
delete name;
}

View File

@ -58,7 +58,7 @@ const int EVALUATE_FOREWARD_R=8;
const int EVALUATE_BACKWARD_R=9;
//! Enumeration of possible symbol types
/*! Warning: do not to change the order of the enumeration, it matters for VariableTable (at least ensure that eEndogenous is the first one) */
/*! Warning: do not to change existing values: the order matters for VariableTable (at least ensure that eEndogenous is the first one), and the values matter for homotopy_setup command */
enum Type
{
eEndogenous = 0, //!< Endogenous

View File

@ -105,7 +105,7 @@ private:
const SymbolTable &symbol_table;
public:
HomotopyStatement(const homotopy_values_type &homotopy_values_arg,
const SymbolTable &symbol_table_arg);
const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
};
#endif