bool ode_solver::inner_loop_backward(ITaylor & solver, interval prevTime, vector<pair<interval, IVector>> & bucket) { interval const stepMade = solver.getStep(); const ITaylor::CurveType& curve = solver.getCurve(); interval domain = interval(0, 1) * stepMade; list<interval> intvs; if (prevTime.rightBound() < m_T.leftBound()) { interval pre_T = interval(0, m_T.leftBound() - prevTime.rightBound()); domain.setLeftBound(m_T.leftBound() - prevTime.rightBound()); intvs = split(domain, m_config.nra_ODE_grid_size); intvs.push_front(pre_T); } else { intvs = split(domain, m_config.nra_ODE_grid_size); } for (interval subsetOfDomain : intvs) { interval dt = prevTime + subsetOfDomain; IVector v = curve(subsetOfDomain); if (!check_invariant(v, m_inv)) { // TODO(soonhok): invariant return true; } DREAL_LOG_INFO << dt << "\t" << v; if (prevTime + subsetOfDomain.rightBound() > m_T.leftBound()) { bucket.emplace_back(dt, v); } // TODO(soonhok): visualization // if (m_config.nra_json) { // m_trajectory.emplace_back(m_T.rightBound() - (prevTime + subsetOfDomain), v); // } } return false; }
list<interval> split(interval const & i, unsigned n) { list<interval> ret; double lb = i.leftBound(); double const rb = i.rightBound(); double const width = rb - lb; double const step = width / n; for (unsigned i = 0; i < n - 1; i++) { ret.emplace_back(lb, lb + step); lb += step; } ret.emplace_back(lb, rb); return ret; }
void ode_solver::prune_trajectory(interval& time, IVector& e) { // Remove datapoints after time interval. auto ite = find_if (m_trajectory.begin(), m_trajectory.end(), [&time](pair<interval, IVector>& item) { return item.first.leftBound() > time.rightBound(); }); m_trajectory.erase(ite, m_trajectory.end()); // Update the datapoints in the time interval ite = find_if (m_trajectory.begin(), m_trajectory.end(), [&time](pair<interval, IVector>& item) { return item.first.leftBound()>= time.leftBound(); }); for_each(ite, m_trajectory.end(), [&e](pair<interval, IVector>& item) { intersection(item.second, e, item.second); }); }