...
 
Commits (19)
This diff is collapsed.
This diff is collapsed.
......@@ -34,7 +34,7 @@ class SteadyStatement : public Statement
private:
const OptionsList options_list;
public:
SteadyStatement(OptionsList options_list_arg);
explicit SteadyStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -45,7 +45,7 @@ class CheckStatement : public Statement
private:
const OptionsList options_list;
public:
CheckStatement(OptionsList options_list_arg);
explicit CheckStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -56,7 +56,7 @@ class SimulStatement : public Statement
private:
const OptionsList options_list;
public:
SimulStatement(OptionsList options_list_arg);
explicit SimulStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -67,7 +67,7 @@ class PerfectForesightSetupStatement : public Statement
private:
const OptionsList options_list;
public:
PerfectForesightSetupStatement(OptionsList options_list_arg);
explicit PerfectForesightSetupStatement(OptionsList options_list_arg);
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
......@@ -77,7 +77,7 @@ class PerfectForesightSolverStatement : public Statement
private:
const OptionsList options_list;
public:
PerfectForesightSolverStatement(OptionsList options_list_arg);
explicit PerfectForesightSolverStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -104,7 +104,7 @@ private:
const bool linear_decomposition;
public:
DetCondForecast(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg,
OptionsList options_list_arg,
const bool linear_decompositiontion_arg);
//virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
......@@ -115,7 +115,7 @@ class ModelInfoStatement : public Statement
private:
const OptionsList options_list;
public:
ModelInfoStatement(OptionsList options_list_arg);
explicit ModelInfoStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -188,7 +188,7 @@ class VarEstimationStatement : public Statement
private:
const OptionsList options_list;
public:
VarEstimationStatement(OptionsList options_list_arg);
explicit VarEstimationStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
};
......@@ -210,7 +210,7 @@ class RamseyModelStatement : public Statement
private:
const OptionsList options_list;
public:
RamseyModelStatement(OptionsList options_list_arg);
explicit RamseyModelStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -270,7 +270,7 @@ class RplotStatement : public Statement
private:
const SymbolList symbol_list;
public:
RplotStatement(SymbolList symbol_list_arg);
explicit RplotStatement(SymbolList symbol_list_arg);
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
......@@ -278,7 +278,6 @@ public:
class UnitRootVarsStatement : public Statement
{
public:
UnitRootVarsStatement();
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
......@@ -288,7 +287,7 @@ class PeriodsStatement : public Statement
private:
const int periods;
public:
PeriodsStatement(int periods_arg);
explicit PeriodsStatement(int periods_arg);
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
......@@ -298,7 +297,7 @@ class DsampleStatement : public Statement
private:
const int val1, val2;
public:
DsampleStatement(int val1_arg);
explicit DsampleStatement(int val1_arg);
DsampleStatement(int val1_arg, int val2_arg);
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -322,7 +321,7 @@ class DynareSensitivityStatement : public Statement
private:
const OptionsList options_list;
public:
DynareSensitivityStatement(OptionsList options_list_arg);
explicit DynareSensitivityStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -388,7 +387,7 @@ class OsrParamsBoundsStatement : public Statement
private:
const vector<OsrParams> osr_params_list;
public:
OsrParamsBoundsStatement(vector<OsrParams> osr_params_list_arg);
explicit OsrParamsBoundsStatement(vector<OsrParams> osr_params_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -523,9 +522,7 @@ private:
StaticModel model_tree;
bool computing_pass_called{false};
public:
PlannerObjectiveStatement(SymbolTable &symbol_table,
NumericalConstants &num_constants,
ExternalFunctionsTable &external_functions_table);
PlannerObjectiveStatement(const StaticModel &model_tree_arg);
/*! \todo check there are only endogenous variables at the current period in the objective
(no exogenous, no lead/lag) */
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
......@@ -534,7 +531,7 @@ public:
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
//! Return a reference the Planner Objective model tree
StaticModel &getPlannerObjective();
const StaticModel &getPlannerObjective() const;
};
class BVARDensityStatement : public Statement
......@@ -566,7 +563,7 @@ class SBVARStatement : public Statement
private:
const OptionsList options_list;
public:
SBVARStatement(OptionsList options_list_arg);
explicit SBVARStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -577,7 +574,7 @@ class MSSBVAREstimationStatement : public Statement
private:
const OptionsList options_list;
public:
MSSBVAREstimationStatement(OptionsList options_list_arg);
explicit MSSBVAREstimationStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -588,7 +585,7 @@ class MSSBVARSimulationStatement : public Statement
private:
const OptionsList options_list;
public:
MSSBVARSimulationStatement(OptionsList options_list_arg);
explicit MSSBVARSimulationStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -599,7 +596,7 @@ class MSSBVARComputeMDDStatement : public Statement
private:
const OptionsList options_list;
public:
MSSBVARComputeMDDStatement(OptionsList options_list_arg);
explicit MSSBVARComputeMDDStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -610,7 +607,7 @@ class MSSBVARComputeProbabilitiesStatement : public Statement
private:
const OptionsList options_list;
public:
MSSBVARComputeProbabilitiesStatement(OptionsList options_list_arg);
explicit MSSBVARComputeProbabilitiesStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -634,7 +631,7 @@ class MSSBVARForecastStatement : public Statement
private:
const OptionsList options_list;
public:
MSSBVARForecastStatement(OptionsList options_list_arg);
explicit MSSBVARForecastStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -645,7 +642,7 @@ class MSSBVARVarianceDecompositionStatement : public Statement
private:
const OptionsList options_list;
public:
MSSBVARVarianceDecompositionStatement(OptionsList options_list_arg);
explicit MSSBVARVarianceDecompositionStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -656,7 +653,7 @@ class IdentificationStatement : public Statement
private:
OptionsList options_list;
public:
IdentificationStatement(const OptionsList &options_list_arg);
explicit IdentificationStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -700,7 +697,7 @@ class WriteLatexSteadyStateModelStatement : public Statement
private:
const SteadyStateModel &steady_state_model;
public:
WriteLatexSteadyStateModelStatement(const SteadyStateModel &steady_state_model_arg);
explicit WriteLatexSteadyStateModelStatement(const SteadyStateModel &steady_state_model_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -756,7 +753,7 @@ class ConditionalForecastStatement : public Statement
private:
const OptionsList options_list;
public:
ConditionalForecastStatement(OptionsList options_list_arg);
explicit ConditionalForecastStatement(OptionsList options_list_arg);
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
......@@ -791,7 +788,7 @@ class ExtendedPathStatement : public Statement
private:
const OptionsList options_list;
public:
ExtendedPathStatement(OptionsList options_list_arg);
explicit ExtendedPathStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -820,9 +817,9 @@ private:
int getMaxLag() const;
public:
SvarIdentificationStatement(svar_identification_restrictions_t restrictions_arg,
const bool &upper_cholesky_present_arg,
const bool &lower_cholesky_present_arg,
const bool &constants_exclusion_present_arg,
bool upper_cholesky_present_arg,
bool lower_cholesky_present_arg,
bool constants_exclusion_present_arg,
const SymbolTable &symbol_table_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
......@@ -835,7 +832,7 @@ private:
const OptionsList options_list;
map <pair<int, int >, double > restriction_map;
public:
MarkovSwitchingStatement(OptionsList options_list_arg);
explicit MarkovSwitchingStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeCOutput(ostream &output, const string &basename) override;
......@@ -847,7 +844,7 @@ class SvarStatement : public Statement
private:
const OptionsList options_list;
public:
SvarStatement(OptionsList options_list_arg);
explicit SvarStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -856,7 +853,6 @@ public:
class SvarGlobalIdentificationCheckStatement : public Statement
{
public:
SvarGlobalIdentificationCheckStatement();
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
......@@ -866,7 +862,7 @@ class SetTimeStatement : public Statement
private:
const OptionsList options_list;
public:
SetTimeStatement(OptionsList options_list_arg);
explicit SetTimeStatement(OptionsList options_list_arg);
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
......@@ -876,7 +872,7 @@ class EstimationDataStatement : public Statement
private:
const OptionsList options_list;
public:
EstimationDataStatement(OptionsList options_list_arg);
explicit EstimationDataStatement(OptionsList options_list_arg);
void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
......@@ -938,9 +934,6 @@ public:
class BasicPriorStatement : public Statement
{
public:
~BasicPriorStatement() override;
protected:
const string name;
const string subsample_name;
......@@ -1048,9 +1041,6 @@ public:
class BasicOptionsStatement : public Statement
{
public:
~BasicOptionsStatement() override;
protected:
const string name;
const string subsample_name;
......@@ -1140,7 +1130,6 @@ public:
class ModelDiagnosticsStatement : public Statement
{
public:
ModelDiagnosticsStatement();
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
......@@ -1150,7 +1139,7 @@ class Smoother2histvalStatement : public Statement
private:
const OptionsList options_list;
public:
Smoother2histvalStatement(OptionsList options_list_arg);
explicit Smoother2histvalStatement(OptionsList options_list_arg);
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
......
......@@ -53,19 +53,19 @@ SlaveNode::SlaveNode(string computerName_arg, string port_arg, int minCpuNbr_arg
string password_arg, string remoteDrive_arg, string remoteDirectory_arg,
string dynarePath_arg, string matlabOctavePath_arg, bool singleCompThread_arg, int numberOfThreadsPerJob_arg,
string operatingSystem_arg) :
computerName(move(computerName_arg)),
port(move(port_arg)),
minCpuNbr(minCpuNbr_arg),
maxCpuNbr(maxCpuNbr_arg),
userName(move(userName_arg)),
password(move(password_arg)),
remoteDrive(move(remoteDrive_arg)),
remoteDirectory(move(remoteDirectory_arg)),
dynarePath(move(dynarePath_arg)),
matlabOctavePath(move(matlabOctavePath_arg)),
singleCompThread(singleCompThread_arg),
numberOfThreadsPerJob(numberOfThreadsPerJob_arg),
operatingSystem(move(operatingSystem_arg))
computerName{move(computerName_arg)},
port{move(port_arg)},
minCpuNbr{minCpuNbr_arg},
maxCpuNbr{maxCpuNbr_arg},
userName{move(userName_arg)},
password{move(password_arg)},
remoteDrive{move(remoteDrive_arg)},
remoteDirectory{move(remoteDirectory_arg)},
dynarePath{move(dynarePath_arg)},
matlabOctavePath{move(matlabOctavePath_arg)},
singleCompThread{singleCompThread_arg},
numberOfThreadsPerJob{numberOfThreadsPerJob_arg},
operatingSystem{move(operatingSystem_arg)}
{
if (computerName.empty())
{
......@@ -82,7 +82,7 @@ SlaveNode::SlaveNode(string computerName_arg, string port_arg, int minCpuNbr_arg
}
Cluster::Cluster(member_nodes_t member_nodes_arg) :
member_nodes(move(member_nodes_arg))
member_nodes{move(member_nodes_arg)}
{
if (member_nodes.empty())
{
......@@ -93,8 +93,8 @@ Cluster::Cluster(member_nodes_t member_nodes_arg) :
ConfigFile::ConfigFile(bool parallel_arg, bool parallel_test_arg,
bool parallel_slave_open_mode_arg, string cluster_name_arg) :
parallel(parallel_arg), parallel_test(parallel_test_arg),
parallel_slave_open_mode(parallel_slave_open_mode_arg), cluster_name(move(cluster_name_arg))
parallel{parallel_arg}, parallel_test{parallel_test_arg},
parallel_slave_open_mode{parallel_slave_open_mode_arg}, cluster_name{move(cluster_name_arg)}
{
}
......
......@@ -86,7 +86,7 @@ class Cluster
{
friend class ConfigFile;
public:
Cluster(member_nodes_t member_nodes_arg);
explicit Cluster(member_nodes_t member_nodes_arg);
protected:
member_nodes_t member_nodes;
......
......@@ -26,12 +26,8 @@
#include "DataTree.hh"
DataTree::DataTree(SymbolTable &symbol_table_arg,
NumericalConstants &num_constants_arg,
ExternalFunctionsTable &external_functions_table_arg) :
symbol_table(symbol_table_arg),
num_constants(num_constants_arg),
external_functions_table(external_functions_table_arg)
void
DataTree::initConstants()
{
Zero = AddNonNegativeConstant("0");
One = AddNonNegativeConstant("1");
......@@ -46,7 +42,73 @@ DataTree::DataTree(SymbolTable &symbol_table_arg,
Pi = AddNonNegativeConstant("3.141592653589793");
}
DataTree::~DataTree() = default;
DataTree::DataTree(SymbolTable &symbol_table_arg,
NumericalConstants &num_constants_arg,
ExternalFunctionsTable &external_functions_table_arg,
bool is_dynamic_arg) :
symbol_table{symbol_table_arg},
num_constants{num_constants_arg},
external_functions_table{external_functions_table_arg},
is_dynamic {is_dynamic_arg}
{
initConstants();
}
DataTree::DataTree(const DataTree &d) :
symbol_table {d.symbol_table},
num_constants {d.num_constants},
external_functions_table {d.external_functions_table},
is_dynamic {d.is_dynamic},
local_variables_vector {d.local_variables_vector}
{
// Constants must be initialized first because they are used in some Add* methods
initConstants();
for (const auto & it : d.node_list)
it->clone(*this);
assert(node_list.size() == d.node_list.size());
for (const auto & it : d.local_variables_table)
local_variables_table[it.first] = it.second->clone(*this);
}
DataTree &
DataTree::operator=(const DataTree &d)
{
assert (&symbol_table == &d.symbol_table);
assert (&num_constants == &d.num_constants);
assert (&external_functions_table == &d.external_functions_table);
assert (is_dynamic == d.is_dynamic);
num_const_node_map.clear();
variable_node_map.clear();
unary_op_node_map.clear();
binary_op_node_map.clear();
trinary_op_node_map.clear();
external_function_node_map.clear();
var_expectation_node_map.clear();
pac_expectation_node_map.clear();
first_deriv_external_function_node_map.clear();
second_deriv_external_function_node_map.clear();
node_list.clear();
// Constants must be initialized first because they are used in some Add* methods
initConstants();
for (const auto & it : d.node_list)
it->clone(*this);
assert(node_list.size() == d.node_list.size());
local_variables_vector = d.local_variables_vector;
for (const auto & it : d.local_variables_table)
local_variables_table[it.first] = it.second->clone(*this);
return *this;
}
expr_t
DataTree::AddNonNegativeConstant(const string &value)
......@@ -65,8 +127,14 @@ DataTree::AddNonNegativeConstant(const string &value)
}
VariableNode *
DataTree::AddVariableInternal(int symb_id, int lag)
DataTree::AddVariable(int symb_id, int lag)
{
if (lag != 0 && !is_dynamic)
{
cerr << "Leads/lags not authorized in this DataTree" << endl;
exit(EXIT_FAILURE);
}
auto it = variable_node_map.find({ symb_id, lag });
if (it != variable_node_map.end())
return it->second;
......@@ -78,6 +146,18 @@ DataTree::AddVariableInternal(int symb_id, int lag)
return p;
}
VariableNode *
DataTree::getVariable(int symb_id, int lag) const
{
auto it = variable_node_map.find({ symb_id, lag });
if (it == variable_node_map.end())
{
cerr << "DataTree::getVariable: unknown variable node for symb_id=" << symb_id << " and lag=" << lag << endl;
exit(EXIT_FAILURE);
}
return it->second;
}
bool
DataTree::ParamUsedWithLeadLagInternal() const
{
......@@ -87,13 +167,6 @@ DataTree::ParamUsedWithLeadLagInternal() const
return false;
}
VariableNode *
DataTree::AddVariable(int symb_id, int lag)
{
assert(lag == 0);
return AddVariableInternal(symb_id, lag);
}
expr_t
DataTree::AddPlus(expr_t iArg1, expr_t iArg2)
{
......@@ -759,7 +832,7 @@ DataTree::writePowerDeriv(ostream &output) const
void
DataTree::writeNormcdfCHeader(ostream &output) const
{
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
#if defined(_WIN32) || defined(__CYGWIN32__)
if (isTrinaryOpUsed(TrinaryOpcode::normcdf))
output << "#ifdef _MSC_VER" << endl
<< "double normcdf(double);" << endl
......@@ -770,7 +843,7 @@ DataTree::writeNormcdfCHeader(ostream &output) const
void
DataTree::writeNormcdf(ostream &output) const
{
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
#if defined(_WIN32) || defined(__CYGWIN32__)
if (isTrinaryOpUsed(TrinaryOpcode::normcdf))
output << endl
<< "#ifdef _MSC_VER" << endl
......
......@@ -45,8 +45,10 @@ public:
NumericalConstants &num_constants;
//! A reference to the external functions table
ExternalFunctionsTable &external_functions_table;
//! Is it possible to use leads/lags on variable nodes?
const bool is_dynamic;
protected:
private:
//! num_constant_id -> NumConstNode
using num_const_node_map_t = map<int, NumConstNode *>;
num_const_node_map_t num_const_node_map;
......@@ -87,14 +89,12 @@ protected:
using second_deriv_external_function_node_map_t = map<tuple<vector<expr_t>, int, int, int>, SecondDerivExternalFunctionNode *>;
second_deriv_external_function_node_map_t second_deriv_external_function_node_map;
protected:
//! Stores local variables value (maps symbol ID to corresponding node)
map<int, expr_t> local_variables_table;
//! Stores the order of appearance of local variables in the model block. Needed following change in #563
vector<int> local_variables_vector;
//! Internal implementation of AddVariable(), without the check on the lag
VariableNode *AddVariableInternal(int symb_id, int lag);
//! Internal implementation of ParamUsedWithLeadLag()
bool ParamUsedWithLeadLagInternal() const;
......@@ -115,13 +115,21 @@ private:
inline expr_t AddBinaryOp(expr_t arg1, BinaryOpcode op_code, expr_t arg2, int powerDerivOrder = 0);
inline expr_t AddTrinaryOp(expr_t arg1, TrinaryOpcode op_code, expr_t arg2, expr_t arg3);
//! Initializes the predefined constants, used only from the constructors
void initConstants();
public:
DataTree(SymbolTable &symbol_table_arg,
NumericalConstants &num_constants_arg,
ExternalFunctionsTable &external_functions_table_arg);
ExternalFunctionsTable &external_functions_table_arg,
bool is_static_args = false);
virtual ~DataTree() = default;
virtual
~DataTree();
DataTree(const DataTree &d);
DataTree(DataTree &&) = delete;
DataTree & operator=(const DataTree &d);
DataTree & operator=(DataTree &&) = delete;
//! Some predefined constants
expr_t Zero, One, Two, MinusOne, NaN, Infinity, MinusInfinity, Pi;
......@@ -131,7 +139,7 @@ public:
{
public:
string name;
LocalVariableException(string name_arg) : name(move(name_arg))
explicit LocalVariableException(string name_arg) : name{move(name_arg)}
{
}
};
......@@ -144,8 +152,11 @@ public:
//! Adds a non-negative numerical constant (possibly Inf or NaN)
expr_t AddNonNegativeConstant(const string &value);
//! Adds a variable
/*! The default implementation of the method refuses any lag != 0 */
virtual VariableNode *AddVariable(int symb_id, int lag = 0);
VariableNode *AddVariable(int symb_id, int lag = 0);
//! Gets a variable
/*! Same as AddVariable, except that it fails if the variable node has not
already been created */
VariableNode *getVariable(int symb_id, int lag = 0) const;
//! Adds "arg1+arg2" to model tree
expr_t AddPlus(expr_t iArg1, expr_t iArg2);
//! Adds "arg1-arg2" to model tree
......@@ -279,7 +290,7 @@ public:
{
public:
string name;
TrendException(string name_arg) : name(move(name_arg))
explicit TrendException(string name_arg) : name{move(name_arg)}
{
}
};
......@@ -306,7 +317,7 @@ public:
public:
//! Symbol ID
int id;
UnknownLocalVariableException(int id_arg) : id(id_arg)
explicit UnknownLocalVariableException(int id_arg) : id(id_arg)
{
}
};
......
......@@ -31,31 +31,217 @@
#include "DynamicModel.hh"
void
DynamicModel::copyHelper(const DynamicModel &m)
{
auto f = [this](const ExprNode *e) { return e->clone(*this); };
for (const auto &it : m.static_only_equations)
static_only_equations.push_back(dynamic_cast<BinaryOpNode *>(f(it)));
auto convert_vector_tt = [f](vector<temporary_terms_t> vtt)
{
vector<temporary_terms_t> vtt2;
for (const auto &tt : vtt)
{
temporary_terms_t tt2;
for (const auto &it : tt)
tt2.insert(f(it));
vtt2.push_back(tt2);
}
return vtt2;
};
for (const auto &it : m.v_temporary_terms)
v_temporary_terms.push_back(convert_vector_tt(it));
for (const auto &it : m.first_chain_rule_derivatives)
first_chain_rule_derivatives[it.first] = f(it.second);
for (const auto &it : m.equation_type_and_normalized_equation)
equation_type_and_normalized_equation.push_back(make_pair(it.first, f(it.second)));
for (const auto &it : m.blocks_derivatives)
{
block_derivatives_equation_variable_laglead_nodeid_t v;
for (const auto &it2 : it)
v.push_back(make_pair(it2.first, make_pair(it2.second.first, f(it2.second.second))));
blocks_derivatives.push_back(v);
}
for (const auto &it : m.dynamic_jacobian)
dynamic_jacobian[it.first] = f(it.second);
auto convert_derivative_t = [f](derivative_t dt)
{
derivative_t dt2;
for (const auto &it : dt)
dt2[it.first] = f(it.second);
return dt2;
};
for (const auto &it : m.derivative_endo)
derivative_endo.push_back(convert_derivative_t(it));
for (const auto &it : m.derivative_other_endo)
derivative_other_endo.push_back(convert_derivative_t(it));
for (const auto &it : m.derivative_exo)
derivative_exo.push_back(convert_derivative_t(it));
for (const auto &it : m.derivative_exo_det)
derivative_exo_det.push_back(convert_derivative_t(it));
for (const auto &it : m.pac_expectation_info)
pac_expectation_info.insert(dynamic_cast<const PacExpectationNode *>(f(it)));
}
DynamicModel::DynamicModel(SymbolTable &symbol_table_arg,
NumericalConstants &num_constants_arg,
ExternalFunctionsTable &external_functions_table_arg,
TrendComponentModelTable &trend_component_model_table_arg,
VarModelTable &var_model_table_arg) :
ModelTree(symbol_table_arg, num_constants_arg, external_functions_table_arg),
trend_component_model_table(trend_component_model_table_arg),
var_model_table(var_model_table_arg),
max_lag(0), max_lead(0),
max_endo_lag(0), max_endo_lead(0),
max_exo_lag(0), max_exo_lead(0),
max_exo_det_lag(0), max_exo_det_lead(0),
max_lag_orig(0), max_lead_orig(0),
max_endo_lag_orig(0), max_endo_lead_orig(0),
max_exo_lag_orig(0), max_exo_lead_orig(0),
max_exo_det_lag_orig(0), max_exo_det_lead_orig(0),
dynJacobianColsNbr(0),
global_temporary_terms(true)
ModelTree {symbol_table_arg, num_constants_arg, external_functions_table_arg, true},
trend_component_model_table{trend_component_model_table_arg},
var_model_table{var_model_table_arg}
{
}
VariableNode *
DynamicModel::AddVariable(int symb_id, int lag)
DynamicModel::DynamicModel(const DynamicModel &m) :
ModelTree {m},
trend_component_model_table {m.trend_component_model_table},
var_model_table {m.var_model_table},
static_only_equations_lineno {m.static_only_equations_lineno},
static_only_equations_equation_tags {m.static_only_equations_equation_tags},
deriv_id_table {m.deriv_id_table},
inv_deriv_id_table {m.inv_deriv_id_table},
dyn_jacobian_cols_table {m.dyn_jacobian_cols_table},
max_lag {m.max_lag},
max_lead {m.max_lead},
max_endo_lag {m.max_endo_lag},
max_endo_lead {m.max_endo_lead},
max_exo_lag {m.max_exo_lag},
max_exo_lead {m.max_exo_lead},
max_exo_det_lag {m.max_exo_det_lag},
max_exo_det_lead {m.max_exo_det_lead},
max_lag_orig {m.max_lag_orig},
max_lead_orig {m.max_lead_orig},
max_endo_lag_orig {m.max_endo_lag_orig},
max_endo_lead_orig {m.max_endo_lead_orig},
max_exo_lag_orig {m.max_exo_lag_orig},
max_exo_lead_orig {m.max_exo_lead_orig},
max_exo_det_lag_orig {m.max_exo_det_lag_orig},
max_exo_det_lead_orig {m.max_exo_det_lead_orig},
xrefs {m.xrefs},
xref_param {m.xref_param},
xref_endo {m.xref_endo},
xref_exo {m.xref_exo},
xref_exo_det {m.xref_exo_det},
nonzero_hessian_eqs {m.nonzero_hessian_eqs},
v_temporary_terms_inuse {m.v_temporary_terms_inuse},
map_idx {m.map_idx},
global_temporary_terms {m.global_temporary_terms},
block_type_firstequation_size_mfs {m.block_type_firstequation_size_mfs},
blocks_linear {m.blocks_linear},
other_endo_block {m.other_endo_block},
exo_block {m.exo_block},
exo_det_block {m.exo_det_block},
block_var_exo {m.block_var_exo},
block_exo_index {m.block_exo_index},
block_det_exo_index {m.block_det_exo_index},
block_other_endo_index {m.block_other_endo_index},
block_col_type {m.block_col_type},
variable_block_lead_lag {m.variable_block_lead_lag},
equation_block {m.equation_block},
var_expectation_functions_to_write {m.var_expectation_functions_to_write},
endo_max_leadlag_block {m.endo_max_leadlag_block},
other_endo_max_leadlag_block {m.other_endo_max_leadlag_block},
exo_max_leadlag_block {m.exo_max_leadlag_block},
exo_det_max_leadlag_block {m.exo_det_max_leadlag_block},
max_leadlag_block {m.max_leadlag_block}
{
return AddVariableInternal(symb_id, lag);
copyHelper(m);
}
DynamicModel &
DynamicModel::operator=(const DynamicModel &m)
{
ModelTree::operator=(m);
assert(&trend_component_model_table == &m.trend_component_model_table);
assert(&var_model_table == &m.var_model_table);
static_only_equations_lineno = m.static_only_equations_lineno;
static_only_equations_equation_tags = m.static_only_equations_equation_tags;
deriv_id_table = m.deriv_id_table;
inv_deriv_id_table = m.inv_deriv_id_table;
dyn_jacobian_cols_table = m.dyn_jacobian_cols_table;
max_lag = m.max_lag;
max_lead = m.max_lead;
max_endo_lag = m.max_endo_lag;
max_endo_lead = m.max_endo_lead;
max_exo_lag = m.max_exo_lag;
max_exo_lead = m.max_exo_lead;
max_exo_det_lag = m.max_exo_det_lag;
max_exo_det_lead = m.max_exo_det_lead;
max_lag_orig = m.max_lag_orig;
max_lead_orig = m.max_lead_orig;
max_endo_lag_orig = m.max_endo_lag_orig;
max_endo_lead_orig = m.max_endo_lead_orig;
max_exo_lag_orig = m.max_exo_lag_orig;
max_exo_lead_orig = m.max_exo_lead_orig;
max_exo_det_lag_orig = m.max_exo_det_lag_orig;
max_exo_det_lead_orig = m.max_exo_det_lead_orig;
xrefs = m.xrefs;
xref_param = m.xref_param;
xref_endo = m.xref_endo;
xref_exo = m.xref_exo;
xref_exo_det = m.xref_exo_det;
nonzero_hessian_eqs = m.nonzero_hessian_eqs;
v_temporary_terms.clear();
v_temporary_terms_inuse = m.v_temporary_terms_inuse;
first_chain_rule_derivatives.clear();
map_idx = m.map_idx;
global_temporary_terms = m.global_temporary_terms;
equation_type_and_normalized_equation.clear();
block_type_firstequation_size_mfs = m.block_type_firstequation_size_mfs;
blocks_derivatives.clear();
dynamic_jacobian.clear();
blocks_linear = m.blocks_linear;
derivative_endo.clear();
derivative_other_endo.clear();
derivative_exo.clear();
derivative_exo_det.clear();
other_endo_block = m.other_endo_block;
exo_block = m.exo_block;
exo_det_block = m.exo_det_block;
block_var_exo = m.block_var_exo;
block_exo_index = m.block_exo_index;
block_det_exo_index = m.block_det_exo_index;
block_other_endo_index = m.block_other_endo_index;
block_col_type = m.block_col_type;
variable_block_lead_lag = m.variable_block_lead_lag;
equation_block = m.equation_block;
var_expectation_functions_to_write = m.var_expectation_functions_to_write;
pac_expectation_info.clear();
endo_max_leadlag_block = m.endo_max_leadlag_block;
other_endo_max_leadlag_block = m.other_endo_max_leadlag_block;
exo_max_leadlag_block = m.exo_max_leadlag_block;
exo_det_max_leadlag_block = m.exo_det_max_leadlag_block;
max_leadlag_block = m.max_leadlag_block;
copyHelper(m);
return *this;
}
void
......@@ -1552,7 +1738,7 @@ DynamicModel::writeDynamicCFile(const string &basename, const int order) const
<< " * Warning : this file is generated automatically by Dynare" << endl
<< " * from model file (.mod)" << endl
<< " */" << endl
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
#if defined(_WIN32) || defined(__CYGWIN32__)
<< "#ifdef _MSC_VER" << endl
<< "#define _USE_MATH_DEFINES" << endl
<< "#endif" << endl
......@@ -4837,61 +5023,12 @@ DynamicModel::writeAuxVarRecursiveDefinitions(ostream &output, ExprNodeOutputTyp
}
}
void
DynamicModel::updateAfterVariableChange(DynamicModel &dm)
{
variable_node_map.clear();
unary_op_node_map.clear();
binary_op_node_map.clear();
trinary_op_node_map.clear();
external_function_node_map.clear();
first_deriv_external_function_node_map.clear();
second_deriv_external_function_node_map.clear();
cloneDynamic(dm);
dm.replaceMyEquations(*this);
}
void
DynamicModel::cloneDynamic(DynamicModel &dynamic_model) const
{
/* Ensure that we are using the same symbol table, because at many places we manipulate
symbol IDs rather than strings */
assert(&symbol_table == &dynamic_model.symbol_table);
// Convert model local variables (need to be done first)
for (int it : local_variables_vector)
dynamic_model.AddLocalVariable(it, local_variables_table.find(it)->second->cloneDynamic(dynamic_model));
// Convert equations
for (size_t i = 0; i < equations.size(); i++)
{
vector<pair<string, string>> eq_tags;
for (const auto & equation_tag : equation_tags)
if (equation_tag.first == (int)i)
eq_tags.push_back(equation_tag.second);
dynamic_model.addEquation(equations[i]->cloneDynamic(dynamic_model), equations_lineno[i], eq_tags);
}
// Convert auxiliary equations
for (auto aux_equation : aux_equations)
dynamic_model.addAuxEquation(aux_equation->cloneDynamic(dynamic_model));
// Convert static_only equations
for (size_t i = 0; i < static_only_equations.size(); i++)
dynamic_model.addStaticOnlyEquation(static_only_equations[i]->cloneDynamic(dynamic_model),
static_only_equations_lineno[i],
static_only_equations_equation_tags[i]);
dynamic_model.setLeadsLagsOrig();
}
void
DynamicModel::replaceMyEquations(DynamicModel &dynamic_model) const
{
dynamic_model.equations.clear();
for (size_t i = 0; i < equations.size(); i++)
dynamic_model.addEquation(equations[i]->cloneDynamic(dynamic_model),
dynamic_model.addEquation(equations[i]->clone(dynamic_model),
equations_lineno[i]);
}
......@@ -4912,7 +5049,7 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model, const boo
// Add Planner Objective to equations to include in computeDerivIDs
assert(static_model.equations.size() == 1);
addEquation(static_model.equations[0]->cloneDynamic(*this), static_model.equations_lineno[0]);
addEquation(static_model.equations[0]->clone(*this), static_model.equations_lineno[0]);
// Get max endo lead and max endo lag
set<pair<int, int>> dynvars;
......@@ -4982,55 +5119,6 @@ DynamicModel::toNonlinearPart(DynamicModel &non_linear_equations_dynamic_model)
non_linear_equations_dynamic_model.AddLocalVariable(it->first, it->second);
}
void
DynamicModel::toStatic(StaticModel &static_model) const
{
/* Ensure that we are using the same symbol table, because at many places we manipulate
symbol IDs rather than strings */
assert(&symbol_table == &static_model.symbol_table);
// Convert model local variables (need to be done first)
for (int it : local_variables_vector)
static_model.AddLocalVariable(it, local_variables_table.find(it)->second->toStatic(static_model));
// Convert equations
int static_only_index = 0;
for (int i = 0; i < (int) equations.size(); i++)
{
// Detect if equation is marked [dynamic]
bool is_dynamic_only = false;
vector<pair<string, string>> eq_tags;
for (const auto & equation_tag : equation_tags)
if (equation_tag.first == i)
{
eq_tags.push_back(equation_tag.second);
if (equation_tag.second.first == "dynamic")
is_dynamic_only = true;
}
try
{
// If yes, replace it by an equation marked [static]
if (is_dynamic_only)
{
static_model.addEquation(static_only_equations[static_only_index]->toStatic(static_model), static_only_equations_lineno[static_only_index], static_only_equations_equation_tags[static_only_index]);
static_only_index++;
}
else
static_model.addEquation(equations[i]->toStatic(static_model), equations_lineno[i], eq_tags);
}
catch (DataTree::DivisionByZeroException)
{
cerr << "...division by zero error encountred when converting equation " << i << " to static" << endl;
exit(EXIT_FAILURE);
}
}
// Convert auxiliary equations
for (auto aux_equation : aux_equations)
static_model.addAuxEquation(aux_equation->toStatic(static_model));
}
bool
DynamicModel::ParamUsedWithLeadLag() const
{
......
......@@ -39,7 +39,7 @@ private:
constexpr static double zero_band{1e-8};
//! Stores equations declared as [static]
/*! They will be used in toStatic() to replace equations marked as [dynamic] */
/*! They will be used in the conversion to StaticModel to replace equations marked as [dynamic] */
vector<BinaryOpNode *> static_only_equations;
//! Stores line numbers of equations declared as [static]
......@@ -60,24 +60,24 @@ private:
//! Maximum lag and lead over all types of variables (positive values)
/*! Set by computeDerivIDs() */
int max_lag, max_lead;
int max_lag{0}, max_lead{0};
//! Maximum lag and lead over endogenous variables (positive values)
/*! Set by computeDerivIDs() */
int max_endo_lag, max_endo_lead;
int max_endo_lag{0}, max_endo_lead{0};
//! Maximum lag and lead over exogenous variables (positive values)
/*! Set by computeDerivIDs() */
int max_exo_lag, max_exo_lead;
int max_exo_lag{0}, max_exo_lead{0};
//! Maximum lag and lead over deterministic exogenous variables (positive values)
/*! Set by computeDerivIDs() */
int max_exo_det_lag, max_exo_det_lead;
int max_exo_det_lag{0}, max_exo_det_lead{0};
//! Maximum lag and lead over all types of variables (positive values) of original model
int max_lag_orig, max_lead_orig;
int max_lag_orig{0}, max_lead_orig{0};
//! Maximum lag and lead over endogenous variables (positive values) of original model
int max_endo_lag_orig, max_endo_lead_orig;
int max_endo_lag_orig{0}, max_endo_lead_orig{0};
//! Maximum lag and lead over exogenous variables (positive values) of original model
int max_exo_lag_orig, max_exo_lead_orig;
int max_exo_lag_orig{0}, max_exo_lead_orig{0};
//! Maximum lag and lead over deterministic exogenous variables (positive values) of original model
int max_exo_det_lag_orig, max_exo_det_lead_orig;
int max_exo_det_lag_orig{0}, max_exo_det_lead_orig{0};
//! Cross reference information
map<int, ExprNode::EquationInfo> xrefs;
......@@ -91,7 +91,7 @@ private:
//! Number of columns of dynamic jacobian
/*! Set by computeDerivID()s and computeDynJacobianCols() */
int dynJacobianColsNbr;
int dynJacobianColsNbr{0};
//! Temporary terms for block decomposed models
vector< vector<temporary_terms_t>> v_temporary_terms;
......@@ -180,9 +180,8 @@ private:
*/
void substituteLeadLagInternal(AuxVarType type, bool deterministic_model, const vector<string> &subset);
private:
//! Indicate if the temporary terms are computed for the overall model (true) or not (false). Default value true
bool global_temporary_terms;
bool global_temporary_terms{true};
//! Vector describing equations: BlockSimulationType, if BlockSimulationType == EVALUATE_s then a expr_t on the new normalized equation
equation_type_and_normalized_equation_t equation_type_and_normalized_equation;
......@@ -254,15 +253,22 @@ private:
void findPacExpectationEquationNumbers(vector<int> &eqnumber) const;
//! Internal helper for the copy constructor and assignment operator
/*! Copies all the structures that contain ExprNode*, by the converting the
pointers into their equivalent in the new tree */
void copyHelper(const DynamicModel &m);
public:
DynamicModel(SymbolTable &symbol_table_arg,
NumericalConstants &num_constants_arg,
ExternalFunctionsTable &external_functions_table_arg,
TrendComponentModelTable &trend_component_model_table_arg,
VarModelTable &var_model_table_arg);
//! Adds a variable node
/*! This implementation allows for non-zero lag */
VariableNode *AddVariable(int symb_id, int lag = 0) override;
DynamicModel(const DynamicModel &m);
DynamicModel(DynamicModel &&) = delete;
DynamicModel & operator=(const DynamicModel &m);
DynamicModel & operator=(DynamicModel &&) = delete;
//! Compute cross references
void computeXrefs();
......@@ -357,11 +363,6 @@ public:
//! Writes file containing parameters derivatives
void writeParamsDerivativesFile(const string &basename, bool julia) const;
//! Converts to static model (only the equations)
/*! It assumes that the static model given in argument has just been allocated */
void toStatic(StaticModel &static_model) const;
//! Converts to nonlinear model (only the equations)
/*! It assumes that the nonlinear model given in argument has just been allocated */
void toNonlinearPart(DynamicModel &non_linear_equations_dynamic_model) const;
......@@ -374,13 +375,6 @@ public:
//! Set the max leads/lags of the original model
void setLeadsLagsOrig();
//! Copies a dynamic model (only the equations)
/*! It assumes that the dynamic model given in argument has just been allocated */
void cloneDynamic(DynamicModel &dynamic_model) const;
//! update equations after variable type change in model block
void updateAfterVariableChange(DynamicModel &dynamic_model);
//! Replaces model equations with derivatives of Lagrangian w.r.t. endogenous
void computeRamseyPolicyFOCs(const StaticModel &static_model, const bool nopreprocessoroutput);
//! Replaces the model equations in dynamic_model with those in this model
......@@ -474,6 +468,8 @@ public:
//! Fills eval context with values of model local variables and auxiliary variables
void fillEvalContext(eval_context_t &eval_context) const;
auto getStaticOnlyEquationsInfo() const { return make_tuple(static_only_equations, static_only_equations_lineno, static_only_equations_equation_tags); };
//! Return the number of blocks
unsigned int
getNbBlocks() const override
......
......@@ -1037,7 +1037,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
%%
DynareFlex::DynareFlex(istream* in, ostream* out)
: DynareFlexLexer(in, out)
: DynareFlexLexer{in, out}
{
}
......
......@@ -42,7 +42,7 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
WarningConsolidation &warnings_arg, bool nostrict, bool stochastic, bool check_model_changes,
bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode,
LanguageOutputType lang, int params_derivs_order, bool transform_unary_ops
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
#if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc, bool mingw
#endif
, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple
......@@ -59,7 +59,7 @@ usage()
<< " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test]"
<< " [-D<variable>[=<value>]] [-I/path] [nostrict] [stochastic] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=julia]"
<< " [params_derivs_order=0|1|2] [transform_unary_ops]"
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
#if defined(_WIN32) || defined(__CYGWIN32__)
<< " [cygwin] [msvc] [mingw]"
#endif
<< " [json=parse|check|transform|compute] [jsonstdout] [onlyjson] [jsonderivsimple] [nopathchange] [nopreprocessoroutput]"
......@@ -99,7 +99,7 @@ main(int argc, char **argv)
bool console = false;
bool nograph = false;
bool nointeractive = false;
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
#if defined(_WIN32) || defined(__CYGWIN32__)
bool cygwin = false;
bool msvc = false;
bool mingw = false;
......@@ -180,7 +180,7 @@ main(int argc, char **argv)
nograph = true;
else if (!strcmp(argv[arg], "nointeractive"))
nointeractive = true;
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
#if defined(_WIN32) || defined(__CYGWIN32__)
else if (!strcmp(argv[arg], "cygwin"))
cygwin = true;
else if (!strcmp(argv[arg], "msvc"))
......@@ -401,7 +401,7 @@ main(int argc, char **argv)
no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive,
parallel, config_file, warnings, nostrict, stochastic, check_model_changes, minimal_workspace,
compute_xrefs, output_mode, language, params_derivs_order, transform_unary_ops
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
#if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc, mingw
#endif
, json, json_output_mode, onlyjson, jsonderivsimple, nopreprocessoroutput
......
......@@ -33,7 +33,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
WarningConsolidation &warnings, bool nostrict, bool stochastic, bool check_model_changes,
bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode,
LanguageOutputType language, int params_derivs_order, bool transform_unary_ops
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
#if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc, bool mingw
#endif
, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple
......@@ -73,7 +73,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
else
mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph,
nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
#if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc, mingw
#endif
, nopreprocessoroutput
......
This diff is collapsed.
......@@ -172,7 +172,7 @@ class ExprNode
const int idx;
//! Is the data member non_null_derivatives initialized ?
bool preparedForDerivation;
bool preparedForDerivation{false};
//! Set of derivation IDs with respect to which the derivative is potentially non-null
set<int> non_null_derivatives;
......@@ -207,8 +207,12 @@ class ExprNode
const temporary_terms_idxs_t &temporary_terms_idxs) const;
public:
ExprNode(DataTree &datatree_arg, int idx_arg);
virtual
~ExprNode();
virtual ~ExprNode() = default;
ExprNode(const ExprNode &) = delete;
ExprNode(ExprNode &&) = delete;
ExprNode & operator=(const ExprNode &) = delete;
ExprNode & operator=(ExprNode &&) = delete;
//! Initializes data member non_null_derivatives
virtual void prepareForDerivation() = 0;
......@@ -534,7 +538,7 @@ class ExprNode
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table) = 0;
//! Add ExprNodes to the provided datatree
virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const = 0;
virtual expr_t clone(DataTree &datatree) const = 0;
//! Move a trend variable with lag/lead to time t by dividing/multiplying by its growth factor
virtual expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const = 0;
......@@ -660,7 +664,7 @@ public:
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
......@@ -688,7 +692,6 @@ class VariableNode : public ExprNode
private:
//! Id from the symbol table
const int symb_id;
const SymbolType type;
//! A positive value is a lead, a negative is a lag
const int lag;
expr_t computeDerivative(int deriv_id) override;
......@@ -712,11 +715,7 @@ public:
void compile(ostream &CompileCode, unsigned int &instruction_number, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic, const deriv_node_temp_terms_t &tef_terms) const override;
expr_t toStatic(DataTree &static_datatree) const override;
void computeXrefs(EquationInfo &ei) const override;
SymbolType
get_type() const
{
return type;
};
SymbolType get_type() const;
int
get_symb_id() const
{
......@@ -762,7 +761,7 @@ public:
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
......@@ -888,7 +887,7 @@ public:
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
......@@ -1036,7 +1035,7 @@ public:
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
//! Function to write out the oPowerNode in expr_t terms as opposed to writing out the function itself
expr_t unpackPowerDeriv() const;
......@@ -1157,7 +1156,7 @@ public:
bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const override;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
......@@ -1282,7 +1281,7 @@ public:
virtual void writePrhs(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, const temporary_terms_idxs_t &temporary_terms_idxs, const deriv_node_temp_terms_t &tef_terms, const string &ending) const;
expr_t replaceTrendVar() const override;
expr_t detrend(int symb_id, bool log_trend, expr_t trend) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override = 0;
expr_t clone(DataTree &datatree) const override = 0;
expr_t removeTrendLeadLag(map<int, expr_t> trend_symbols_map) const override;
bool isInStaticForm() const override;
void addParamInfoToPac(pair<int, int> &lhs_arg, int optim_share_arg, pair<int, pair<vector<int>, vector<bool>>> &ec_params_and_vars_arg, set<pair<int, pair<int, int>>> &params_and_vars_arg, set<pair<int, pair<pair<int, int>, double>>> &params_vars_and_scaling_factor_arg) override;
......@@ -1340,7 +1339,7 @@ public:
expr_t toStatic(DataTree &static_datatree) const override;
void computeXrefs(EquationInfo &ei) const override;
expr_t buildSimilarExternalFunctionNode(vector<expr_t> &alt_args, DataTree &alt_datatree) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
};
class FirstDerivExternalFunctionNode : public AbstractExternalFunctionNode
......@@ -1383,7 +1382,7 @@ public:
expr_t toStatic(DataTree &static_datatree) const override;
void computeXrefs(EquationInfo &ei) const override;
expr_t buildSimilarExternalFunctionNode(vector<expr_t> &alt_args, DataTree &alt_datatree) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
};
class SecondDerivExternalFunctionNode : public AbstractExternalFunctionNode
......@@ -1428,7 +1427,7 @@ public:
expr_t toStatic(DataTree &static_datatree) const override;
void computeXrefs(EquationInfo &ei) const override;
expr_t buildSimilarExternalFunctionNode(vector<expr_t> &alt_args, DataTree &alt_datatree) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
};
class VarExpectationNode : public ExprNode
......@@ -1448,7 +1447,7 @@ public:
vector< vector<temporary_terms_t>> &v_temporary_terms,
int equation) const override;
expr_t toStatic(DataTree &static_datatree) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
int maxEndoLead() const override;
int maxExoLead() const override;
int maxEndoLag() const override;
......@@ -1547,7 +1546,7 @@ public:
vector< vector<temporary_terms_t>> &v_temporary_terms,
int equation) const override;
expr_t toStatic(DataTree &static_datatree) const override;
expr_t cloneDynamic(DataTree &dynamic_datatree) const override;
expr_t clone(DataTree &datatree) const override;
int maxEndoLead() const override;
int maxExoLead() const override;
int maxEndoLag() const override;
......
......@@ -26,9 +26,6 @@
#include "ExternalFunctionsTable.hh"
#include "SymbolTable.hh"
ExternalFunctionsTable::ExternalFunctionsTable()