Commit 47c22072 authored by sebastien's avatar sebastien
Browse files

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
parent 95d21181
......@@ -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;
}
......@@ -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;
}
......
......@@ -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
......
......@@ -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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment