- corrections of bugs in exprnode and with solve_two_boundaries_simple type

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2333 ac1d8469-bf42-47a9-8791-bf33cf982152
issue#70
ferhat 2008-12-19 16:24:22 +00:00
parent ff0ae482ce
commit b1cf9c6d56
2 changed files with 14 additions and 10 deletions

View File

@ -278,7 +278,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
case eModelLocalVariable: case eModelLocalVariable:
case eModFileLocalVariable: case eModFileLocalVariable:
if(type==oMatlabDynamicModelSparse || type==oMatlabStaticModelSparse) if(output_type==oMatlabDynamicModelSparse || output_type==oMatlabStaticModelSparse)
datatree.local_variables_table[symb_id]->writeOutput(output, output_type,temporary_terms); datatree.local_variables_table[symb_id]->writeOutput(output, output_type,temporary_terms);
else else
output << datatree.symbol_table.getNameByID(type, symb_id); output << datatree.symbol_table.getNameByID(type, symb_id);

View File

@ -404,7 +404,7 @@ ModelTree::writeModelEquationsOrdered_M( Model_Block *ModelBlock, const string &
else else
tmp_output << " "; tmp_output << " ";
(*it)->writeOutput(tmp_output, oMatlabDynamicModelSparse, temporary_terms); (*it)->writeOutput(tmp_output, oMatlabStaticModelSparse, temporary_terms);
} }
if(tmp_output.str().length()) if(tmp_output.str().length())
@ -561,6 +561,7 @@ ModelTree::writeModelEquationsOrdered_M( Model_Block *ModelBlock, const string &
output << sps << "residual(" << i+1 << ") = ("; output << sps << "residual(" << i+1 << ") = (";
goto end; goto end;
case SOLVE_TWO_BOUNDARIES_COMPLETE: case SOLVE_TWO_BOUNDARIES_COMPLETE:
case SOLVE_TWO_BOUNDARIES_SIMPLE:
Uf[ModelBlock->Block_List[j].Equation[i]] << " b(" << i+1 << "+Per_J_) = -residual(" << i+1 << ", it_)"; Uf[ModelBlock->Block_List[j].Equation[i]] << " b(" << i+1 << "+Per_J_) = -residual(" << i+1 << ", it_)";
output << sps << "residual(" << i+1 << ", it_) = ("; output << sps << "residual(" << i+1 << ", it_) = (";
goto end; goto end;
@ -571,7 +572,7 @@ ModelTree::writeModelEquationsOrdered_M( Model_Block *ModelBlock, const string &
rhs->writeOutput(output, oMatlabDynamicModelSparse, temporary_terms); rhs->writeOutput(output, oMatlabDynamicModelSparse, temporary_terms);
output << ");\n"; output << ");\n";
#ifdef CONDITION #ifdef CONDITION
if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE) if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE)
output << " condition(" << i+1 << ")=0;\n"; output << " condition(" << i+1 << ")=0;\n";
#endif #endif
} }
@ -1020,6 +1021,7 @@ ModelTree::writeModelStaticEquationsOrdered_M(Model_Block *ModelBlock, const str
case SOLVE_BACKWARD_COMPLETE: case SOLVE_BACKWARD_COMPLETE:
case SOLVE_FORWARD_COMPLETE: case SOLVE_FORWARD_COMPLETE:
case SOLVE_TWO_BOUNDARIES_COMPLETE: case SOLVE_TWO_BOUNDARIES_COMPLETE:
case SOLVE_TWO_BOUNDARIES_SIMPLE:
Uf[ModelBlock->Block_List[j].Equation[i]] << "b(" << i+1 << ") = residual(" << i+1 << ")"; Uf[ModelBlock->Block_List[j].Equation[i]] << "b(" << i+1 << ") = residual(" << i+1 << ")";
goto end; goto end;
default: default:
@ -1030,7 +1032,7 @@ ModelTree::writeModelStaticEquationsOrdered_M(Model_Block *ModelBlock, const str
rhs->writeOutput(output, oMatlabStaticModelSparse, temporary_terms); rhs->writeOutput(output, oMatlabStaticModelSparse, temporary_terms);
output << ");\n"; output << ");\n";
#ifdef CONDITION #ifdef CONDITION
if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE) if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE)
output << " condition(" << i+1 << ")=0;\n"; output << " condition(" << i+1 << ")=0;\n";
#endif #endif
} }
@ -1220,7 +1222,7 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
code_file.write(reinterpret_cast<char *>(&v),sizeof(v)); code_file.write(reinterpret_cast<char *>(&v),sizeof(v));
v=block_triangular.ModelBlock->Block_List[j].Max_Lead; v=block_triangular.ModelBlock->Block_List[j].Max_Lead;
code_file.write(reinterpret_cast<char *>(&v),sizeof(v)); code_file.write(reinterpret_cast<char *>(&v),sizeof(v));
if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE) if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE)
{ {
int u_count_int=0; int u_count_int=0;
Write_Inf_To_Bin_File(file_name, bin_basename, j, u_count_int,SGE.file_open); Write_Inf_To_Bin_File(file_name, bin_basename, j, u_count_int,SGE.file_open);
@ -1291,11 +1293,11 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
lhs->compile(code_file,false, output_type, temporary_terms, map_idx); lhs->compile(code_file,false, output_type, temporary_terms, map_idx);
rhs->compile(code_file,true, output_type, temporary_terms, map_idx); rhs->compile(code_file,true, output_type, temporary_terms, map_idx);
break; break;
case SOLVE_TWO_BOUNDARIES_SIMPLE: /*case SOLVE_TWO_BOUNDARIES_SIMPLE:
v=ModelBlock->Block_List[j].Equation[i]; v=ModelBlock->Block_List[j].Equation[i];
Uf[v].eqr=i; Uf[v].eqr=i;
Uf[v].Ufl=NULL; Uf[v].Ufl=NULL;
goto end; goto end;*/
case SOLVE_BACKWARD_COMPLETE: case SOLVE_BACKWARD_COMPLETE:
case SOLVE_FORWARD_COMPLETE: case SOLVE_FORWARD_COMPLETE:
v=ModelBlock->Block_List[j].Equation[i]; v=ModelBlock->Block_List[j].Equation[i];
@ -1303,6 +1305,7 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
Uf[v].Ufl=NULL; Uf[v].Ufl=NULL;
goto end; goto end;
case SOLVE_TWO_BOUNDARIES_COMPLETE: case SOLVE_TWO_BOUNDARIES_COMPLETE:
case SOLVE_TWO_BOUNDARIES_SIMPLE:
v=ModelBlock->Block_List[j].Equation[i]; v=ModelBlock->Block_List[j].Equation[i];
Uf[v].eqr=i; Uf[v].eqr=i;
Uf[v].Ufl=NULL; Uf[v].Ufl=NULL;
@ -2048,6 +2051,7 @@ ModelTree::writeSparseStaticMFile(const string &static_basename, const string &b
case SOLVE_FORWARD_SIMPLE: case SOLVE_FORWARD_SIMPLE:
case SOLVE_BACKWARD_SIMPLE: case SOLVE_BACKWARD_SIMPLE:
case SOLVE_TWO_BOUNDARIES_COMPLETE: case SOLVE_TWO_BOUNDARIES_COMPLETE:
case SOLVE_TWO_BOUNDARIES_SIMPLE:
mStaticModelFile << " y_index_eq = [" << tmp_eq.str() << "];\n"; mStaticModelFile << " y_index_eq = [" << tmp_eq.str() << "];\n";
mStaticModelFile << " y_index = ["; mStaticModelFile << " y_index = [";
mStaticModelFile << tmp.str(); mStaticModelFile << tmp.str();
@ -2098,7 +2102,7 @@ ModelTree::writeSparseStaticMFile(const string &static_basename, const string &b
} }
open_par=false; open_par=false;
} }
else if ((k == SOLVE_FORWARD_SIMPLE || k == SOLVE_BACKWARD_SIMPLE) || (k == SOLVE_FORWARD_COMPLETE || k == SOLVE_BACKWARD_COMPLETE || k == SOLVE_TWO_BOUNDARIES_COMPLETE) && (block_triangular.ModelBlock->Block_List[i].Size)) else if ((k == SOLVE_FORWARD_SIMPLE || k == SOLVE_BACKWARD_SIMPLE) || (k == SOLVE_FORWARD_COMPLETE || k == SOLVE_BACKWARD_COMPLETE || k == SOLVE_TWO_BOUNDARIES_COMPLETE || k == SOLVE_TWO_BOUNDARIES_SIMPLE) && (block_triangular.ModelBlock->Block_List[i].Size))
{ {
if (open_par) if (open_par)
{ {
@ -2183,7 +2187,7 @@ ModelTree::writeSparseDynamicMFile(const string &dynamic_basename, const string
OK=false; OK=false;
else else
tmp_output << " "; tmp_output << " ";
(*it)->writeOutput(tmp_output, oMatlabDynamicModel, temporary_terms); (*it)->writeOutput(tmp_output, oMatlabStaticModelSparse, temporary_terms);
} }
if (tmp_output.str().length()>0) if (tmp_output.str().length()>0)
mDynamicModelFile << " global " << tmp_output.str() << " M_ ;\n"; mDynamicModelFile << " global " << tmp_output.str() << " M_ ;\n";
@ -3086,7 +3090,7 @@ ModelTree::BlockLinear(Model_Block *ModelBlock)
} }
} }
} }
else if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE) else if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE)
{ {
for(m=0;m<=ModelBlock->Block_List[j].Max_Lead+ModelBlock->Block_List[j].Max_Lag;m++) for(m=0;m<=ModelBlock->Block_List[j].Max_Lead+ModelBlock->Block_List[j].Max_Lag;m++)
{ {