Esempio n. 1
0
bool operator<(ibex::Interval const & a, ibex::Interval const & b) {
    if (a.is_empty() || b.is_empty()) {
        return false;
    }
    return a.ub() < b.lb();
    return false;
}
Esempio n. 2
0
Interval Tube::operator[](const ibex::Interval& intv_t) const
{
  // Write access is not allowed for this operator:
  // a further call to computeTree() is needed when values change,
  // this call cannot be garanteed with a direct access to m_intv_y
  // For write access: use setY()

  if(intv_t.lb() == intv_t.ub())
    return (*this)[intv_t.lb()];

  Interval intersection = m_intv_t & intv_t;

  if(intersection.is_empty())
    return Interval::EMPTY_SET;

  else if(isSlice() || intv_t == m_intv_t || intv_t.is_unbounded() || intv_t.is_superset(m_intv_t))
  {
    if(m_tree_computation_needed)
      computeTree();
    
    return m_intv_y;
  }

  else
  {
    Interval inter_firstsubtube = m_first_subtube->getT() & intersection;
    Interval inter_secondsubtube = m_second_subtube->getT() & intersection;

    if(inter_firstsubtube == inter_secondsubtube)
      return (*m_first_subtube)[inter_firstsubtube.lb()] & (*m_second_subtube)[inter_secondsubtube.lb()];

    else if(inter_firstsubtube.lb() == inter_firstsubtube.ub()
            && inter_secondsubtube.lb() != inter_secondsubtube.ub())
      return (*m_second_subtube)[inter_secondsubtube];

    else if(inter_firstsubtube.lb() != inter_firstsubtube.ub()
            && inter_secondsubtube.lb() == inter_secondsubtube.ub())
      return (*m_first_subtube)[inter_firstsubtube];

    else
      return (*m_first_subtube)[inter_firstsubtube] | (*m_second_subtube)[inter_secondsubtube];
  }
}
Esempio n. 3
0
tuple<int, box, box> box::bisect_int_at(int const i) const {
    assert(0 <= i && i < m_values.size());
    assert(!m_values[i].is_empty());
    assert(m_values[i].is_bisectable());
    box b1(*this);
    box b2(*this);
    ibex::Interval const iv = ibex::integer(b1.m_values[i]);
    double const lb = iv.lb();
    double const ub = iv.ub();
    double const mid = iv.mid();
    double const mid_floor = floor(mid);
    double const mid_ceil  = ceil(mid);
    if (!iv.is_bisectable()) {
        DREAL_LOG_FATAL << "NOT BISECTABLE = " << iv;
    }
    pair<ibex::Interval, ibex::Interval> new_intervals = iv.bisect();
    b1.m_values[i] = ibex::Interval(lb, mid_floor);
    b2.m_values[i] = ibex::Interval(mid_ceil, ub);
    b1.m_idx_last_branched = i;
    b2.m_idx_last_branched = i;
    DREAL_LOG_DEBUG << "box::bisect on " << (*m_vars)[i] << " : int = " << m_values[i]
                    << " into " << b1.m_values[i] << " and " << b2.m_values[i];
    return make_tuple(i, b1, b2);
}
Esempio n. 4
0
 friend bool operator ==(ibex::Interval lhs, ApproxIntv const& rhs)
 {
   double e = rhs.m_epsilon;
   return lhs == rhs.m_value ||
          (fabs(lhs.lb() - rhs.m_value.lb()) < e && fabs(lhs.ub() - rhs.m_value.ub()) < e);
 }