From 255d64e6d1f4ff67d3c22f8614178110180e830f Mon Sep 17 00:00:00 2001 From: Ferhat Date: Fri, 17 Feb 2012 10:48:28 +0100 Subject: [PATCH] Corrects the number of lead and lags of a block --- DynamicModel.cc | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/DynamicModel.cc b/DynamicModel.cc index ed8d0e1f..7e4e9531 100644 --- a/DynamicModel.cc +++ b/DynamicModel.cc @@ -2507,6 +2507,8 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de output << "block_structure.block(" << block+1 << ").lead_lag_incidence = [];\n"; int last_var = -1; vector local_state_var; + vector local_stat_var; + int n_static = 0, n_backward = 0, n_forward = 0, n_mixed = 0; for (int lag = -1; lag < 1+1; lag++) { last_var = -1; @@ -2515,7 +2517,32 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de if (lag == it->first.first && last_var != it->first.second.first) { if (lag == -1) - local_state_var.push_back(getBlockVariableID(block, it->first.second.first)+1); + { + local_state_var.push_back(getBlockVariableID(block, it->first.second.first)+1); + n_backward++; + } + else if (lag == 0) + { + if (find( local_state_var.begin(), local_state_var.end(), getBlockVariableID(block, it->first.second.first)+1) == local_state_var.end()) + { + local_stat_var.push_back(getBlockVariableID(block, it->first.second.first)+1); + n_static++; + } + } + else + { + if (find(local_state_var.begin(), local_state_var.end(), getBlockVariableID(block, it->first.second.first)+1) != local_state_var.end()) + { + n_backward--; + n_mixed++; + } + else + { + if (find(local_stat_var.begin(), local_stat_var.end(),getBlockVariableID(block, it->first.second.first)+1) != local_stat_var.end()) + n_static--; + n_forward++; + } + } count_lead_lag_incidence++; for (int i = last_var; i < it->first.second.first-1; i++) tmp_s << " 0"; @@ -2564,10 +2591,10 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de } output << "block_structure.block(" << block+1 << ").lead_lag_incidence_other = [ block_structure.block(" << block+1 << ").lead_lag_incidence_other; " << tmp_s.str() << "]; %lag = " << lag << "\n"; } - output << "block_structure.block(" << block+1 << ").n_static = " << block_col_type[block].first.first << ";\n"; - output << "block_structure.block(" << block+1 << ").n_forward = " << block_col_type[block].first.second << ";\n"; - output << "block_structure.block(" << block+1 << ").n_backward = " << block_col_type[block].second.first << ";\n"; - output << "block_structure.block(" << block+1 << ").n_mixed = " << block_col_type[block].second.second << ";\n"; + output << "block_structure.block(" << block+1 << ").n_static = " << n_static << ";\n"; + output << "block_structure.block(" << block+1 << ").n_forward = " << n_forward << ";\n"; + output << "block_structure.block(" << block+1 << ").n_backward = " << n_backward << ";\n"; + output << "block_structure.block(" << block+1 << ").n_mixed = " << n_mixed << ";\n"; } output << "M_.block_structure.block = block_structure.block;\n"; string cst_s; @@ -4210,7 +4237,7 @@ DynamicModel::fillEvalContext(eval_context_t &eval_context) const eval_context[*it] = 2; //not <= 0 bc of log, not 1 bc of powers } -bool +bool DynamicModel::isModelLocalVariableUsed() const { set used_local_vars;