bool Recurrence::calcIteratedUpdate(const UpdateMap &oldUpdate, const Expression &meterfunc, UpdateMap &newUpdate) { assert(newUpdate.empty()); UpdateMap update = oldUpdate; //might be changed by dependencyOrder, so copy here vector<VariableIndex> order = dependencyOrder(update); assert(order.size() == update.size()); //in the given order try to solve the recurrence for every updated variable for (VariableIndex vi : order) { Expression res; ExprSymbol target = itrs.getGinacSymbol(vi); //use update rhs, but replace already processed variables with their recurrences Expression todo = update.at(vi).subs(knownPreRecurrences); if (!findUpdateRecurrence(todo,target,res)) { return false; } //remember this recurrence to replace vi in the updates depending on vi //note that updates need the value at n-1, e.g. x(n) = x(n-1) + vi(n-1) for the update x=x+vi knownPreRecurrences[target] = res.subs(ginacN == ginacN-1); //calcuate the final update using the loop's runtime newUpdate[vi] = res.subs(ginacN == meterfunc); } return true; }