Commit 810416eb authored by Ferhat Mihoubi's avatar Ferhat Mihoubi

- Extends the algorithms compatible with bytecode to compute the steady-state...

- Extends the algorithms compatible with bytecode to compute the  steady-state (ticket #11). The new values for solve_algo are:
   * 0: fsolve
   * 1: solve1
   * 2, 4: solve1 + block decomposition
   * 3: csolve
   * 5: LU decomposition with UMFPack (method handling sparse matrix in Matlab)
   * 6: GMRES
   * 7: BiCGStab
   * 8: bytecode own solver (use Gaussian elimination + sparse matrix)

- Bytecode can now evaluate a specific block instead of the overall blocks (new bytecode's option 'Block = block_number')
parent d973c2ea
/* /*
* Copyright (C) 2007-2010 Dynare Team * Copyright (C) 2007-2010 Dynare Team
* *
...@@ -1182,6 +1183,7 @@ class CodeLoad ...@@ -1182,6 +1183,7 @@ class CodeLoad
private: private:
uint8_t *code; uint8_t *code;
unsigned int nb_blocks; unsigned int nb_blocks;
vector<unsigned int> begin_block;
public: public:
inline unsigned int inline unsigned int
...@@ -1189,6 +1191,12 @@ public: ...@@ -1189,6 +1191,12 @@ public:
{ {
return nb_blocks; return nb_blocks;
}; };
unsigned int inline
get_begin_block(int block)
{
return begin_block[block];
}
inline void * inline void *
get_current_code() get_current_code()
{ {
...@@ -1445,6 +1453,7 @@ public: ...@@ -1445,6 +1453,7 @@ public:
code = fbegin_block->load(code); code = fbegin_block->load(code);
begin_block.push_back(tags_liste.size());
tags_liste.push_back(make_pair(FBEGINBLOCK, fbegin_block)); tags_liste.push_back(make_pair(FBEGINBLOCK, fbegin_block));
nb_blocks++; nb_blocks++;
} }
......
This diff is collapsed.
...@@ -39,9 +39,12 @@ private: ...@@ -39,9 +39,12 @@ private:
//! Temporary terms for the file containing parameters dervicatives //! Temporary terms for the file containing parameters dervicatives
temporary_terms_t params_derivs_temporary_terms; temporary_terms_t params_derivs_temporary_terms;
//! Temporary terms for block decomposed models //! global temporary terms for block decomposed models
vector<vector<temporary_terms_t> > v_temporary_terms; vector<vector<temporary_terms_t> > v_temporary_terms;
//! local temporary terms for block decomposed models
vector<vector<temporary_terms_t> > v_temporary_terms_local;
vector<temporary_terms_inuse_t> v_temporary_terms_inuse; vector<temporary_terms_inuse_t> v_temporary_terms_inuse;
typedef map< pair< int, pair< int, int> >, expr_t> first_chain_rule_derivatives_t; typedef map< pair< int, pair< int, int> >, expr_t> first_chain_rule_derivatives_t;
...@@ -61,7 +64,7 @@ private: ...@@ -61,7 +64,7 @@ private:
void writeModelEquationsOrdered_M(const string &dynamic_basename) const; void writeModelEquationsOrdered_M(const string &dynamic_basename) const;
//! Writes the code of the Block reordred structure of the model in virtual machine bytecode //! Writes the code of the Block reordred structure of the model in virtual machine bytecode
void writeModelEquationsCode_Block(const string file_name, const string bin_basename, map_idx_t map_idx) const; void writeModelEquationsCode_Block(const string file_name, const string bin_basename, map_idx_t map_idx, vector<map_idx_t> map_idx2) const;
//! Writes the code of the model in virtual machine bytecode //! Writes the code of the model in virtual machine bytecode
void writeModelEquationsCode(const string file_name, const string bin_basename, map_idx_t map_idx) const; void writeModelEquationsCode(const string file_name, const string bin_basename, map_idx_t map_idx) const;
...@@ -76,15 +79,17 @@ private: ...@@ -76,15 +79,17 @@ private:
map_idx_t map_idx; map_idx_t map_idx;
vector<map_idx_t> map_idx2;
//! sorts the temporary terms in the blocks order //! sorts the temporary terms in the blocks order
void computeTemporaryTermsOrdered(); void computeTemporaryTermsOrdered();
//! creates a mapping from the index of temporary terms to a natural index //! creates a mapping from the index of temporary terms to a natural index
void computeTemporaryTermsMapping(); void computeTemporaryTermsMapping(temporary_terms_t &temporary_terms, map_idx_t &map_idx);
//! Write derivative code of an equation w.r. to a variable //! Write derivative code of an equation w.r. to a variable
void compileDerivative(ofstream &code_file, unsigned int &instruction_number, int eq, int symb_id, map_idx_t &map_idx) const; void compileDerivative(ofstream &code_file, unsigned int &instruction_number, int eq, int symb_id, map_idx_t &map_idx, temporary_terms_t temporary_terms) const;
//! Write chain rule derivative code of an equation w.r. to a variable //! Write chain rule derivative code of an equation w.r. to a variable
void compileChainRuleDerivative(ofstream &code_file, unsigned int &instruction_number, int eq, int var, int lag, map_idx_t &map_idx) const; void compileChainRuleDerivative(ofstream &code_file, unsigned int &instruction_number, int eq, int var, int lag, map_idx_t &map_idx, temporary_terms_t temporary_terms) const;
//! Get the type corresponding to a derivation ID //! Get the type corresponding to a derivation ID
virtual SymbolType getTypeByDerivID(int deriv_id) const throw (UnknownDerivIDException); virtual SymbolType getTypeByDerivID(int deriv_id) const throw (UnknownDerivIDException);
......
Markdown is supported
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