Fix illegal memory access when doing Ramsey
The preprocessor would try to write bytecode for the planner objective. But bytecode only works when there are as many endogenous as equations, which is not the case for the PlannerObjective object derived from StaticModel.master
parent
097c4fdc77
commit
a8ea57dd63
|
@ -142,6 +142,10 @@ DynamicModel::operator=(const DynamicModel &m)
|
|||
void
|
||||
DynamicModel::writeDynamicBytecode(const string &basename) const
|
||||
{
|
||||
/* Bytecode only works when there are with as many endogenous as equations.
|
||||
(e.g. the constructor of FBEGINBLOCK_ makes this assumption) */
|
||||
assert(static_cast<int>(equations.size()) == symbol_table.endo_nbr());
|
||||
|
||||
// Determine the type of model (used for typing the single block)
|
||||
BlockSimulationType simulation_type;
|
||||
if (max_endo_lag > 0 && max_endo_lead > 0)
|
||||
|
|
|
@ -37,6 +37,12 @@ PlannerObjective::computingPassBlock([[maybe_unused]] const eval_context_t &eval
|
|||
// Disable block decomposition on planner objective
|
||||
}
|
||||
|
||||
void
|
||||
PlannerObjective::writeStaticBytecode([[maybe_unused]] const string &basename) const
|
||||
{
|
||||
// Disable bytecode output, because there are not as many variables as equations
|
||||
}
|
||||
|
||||
OrigRamseyDynamicModel::OrigRamseyDynamicModel(SymbolTable &symbol_table_arg,
|
||||
NumericalConstants &num_constants_arg,
|
||||
ExternalFunctionsTable &external_functions_table_arg,
|
||||
|
|
|
@ -41,6 +41,7 @@ protected:
|
|||
|
||||
private:
|
||||
void computingPassBlock(const eval_context_t &eval_context, bool no_tmp_terms) override;
|
||||
void writeStaticBytecode(const string &basename) const override;
|
||||
};
|
||||
|
||||
class OrigRamseyDynamicModel : public DynamicModel
|
||||
|
|
|
@ -102,6 +102,10 @@ StaticModel::StaticModel(const DynamicModel &m) :
|
|||
void
|
||||
StaticModel::writeStaticBytecode(const string &basename) const
|
||||
{
|
||||
/* Bytecode only works when there are with as many endogenous as equations.
|
||||
(e.g. the constructor of FBEGINBLOCK_ makes this assumption) */
|
||||
assert(static_cast<int>(equations.size()) == symbol_table.endo_nbr());
|
||||
|
||||
// First write the .bin file
|
||||
int u_count_int { writeBytecodeBinFile(basename + "/model/bytecode/static.bin", false) };
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
void writeStaticBlockBytecode(const string &basename) const;
|
||||
|
||||
//! Writes the code of the model in virtual machine bytecode
|
||||
void writeStaticBytecode(const string &basename) const;
|
||||
virtual void writeStaticBytecode(const string &basename) const;
|
||||
|
||||
//! Computes jacobian and prepares for equation normalization
|
||||
/*! Using values from initval/endval blocks and parameter initializations:
|
||||
|
|
Loading…
Reference in New Issue