Ejemplo n.º 1
0
int rp_operator_newton::reduce(rp_box b)
{
  bool proof = true;

  for (int i=0; i<_arity; ++i)
  {
    int v = _v[i];
    rp_interval aux, save;

    rp_interval_add(aux,rp_ivector_elem(_unknown,i),rp_box_elem(_midpoint,v));
    rp_interval_copy(save,rp_box_elem(b,v));

    if (!(rp_interval_strictly_included(aux,save))) proof = false;

    rp_interval_inter(rp_box_elem(b,v),save,aux);

    if (rp_interval_empty(rp_box_elem(b,v)))
    {
      return( 0 );
    }
  }

  if (proof) rp_box_set_safe(b);

  return( 1 );
}
Ejemplo n.º 2
0
// Application function
// b(x) := hull (b(x) inter initial_domain)
int rp_operator_domain::apply(rp_box b)
{
  DREAL_LOG_DEBUG << "rp_operator_domain::apply";
  /* Rounding for discrete variables */
  if (rp_variable_integer(_x))
  {
    rp_interval_trunc(rp_box_elem(b,_id));
    if (rp_interval_empty(rp_box_elem(b,_id)))
    {
      return( 0 );
    }
  }

  /* Intersection with initial domain */
  return( rp_union_inter_iu(rp_box_elem(b,_id),rp_variable_domain(_x)) );
}
Ejemplo n.º 3
0
// Application of operator to reduce the box b
int rp_operator_piecewise::apply(rp_box b)
{
  DREAL_LOG_DEBUG << "rp_operator_piecewise::apply";
  // Check each piece Ij:Cj, if Cj violated then the elements of Ij
  // are removed from the domain of the main variable of _c
  for (int i=0; i<rp_ctr_piecewise_arity(_c); ++i)
  {
    int violated = 0, j = 0;
    while ((!violated) && (j<rp_ctr_piecewise_elem_size(_c,i)))
    {
      if (rp_ctr_num_unfeasible(rp_ctr_piecewise_elem_ctrnum(_c,i,j),b))
      {
        violated = 1;
      }
      else ++j;
    }
    if (violated)
    {
      // domain restriction dom(var) := dom(var) \ Ij
      rp_interval aux;
      rp_interval_copy(aux,rp_box_elem(b,rp_ctr_piecewise_var(_c)));
      rp_interval_setminus(rp_box_elem(b,rp_ctr_piecewise_var(_c)),
                           aux,
                           rp_ctr_piecewise_elem_dom(_c,i));

      if (rp_interval_empty(rp_box_elem(b,rp_ctr_piecewise_var(_c))))
      {
        return( 0 );
      }
    }
  }

  // Check whether the domain of the main variable of _c
  // intersects at least one Ij
  int intersect = 0, i = 0;
  while ((!intersect) && (i<rp_ctr_piecewise_arity(_c)))
  {
    if (!rp_interval_disjoint(rp_box_elem(b,rp_ctr_piecewise_var(_c)),
                              rp_ctr_piecewise_elem_dom(_c,i)))
    {
      intersect = 1;
    }
    else ++i;
  }
  return( intersect );
}
Ejemplo n.º 4
0
/* Returns true if no point of b is solution of c */
int rp_ctr_numeq_unfeasible(rp_ctr_num c, rp_box b)
{
  int res;
  if ((!rp_expression_eval(rp_ctr_num_left(c),b)) ||
      (!rp_expression_eval(rp_ctr_num_right(c),b)))
  {
    /* at least one expression has an empty range over b */
    res = 1;
  }
  else
  {
    /* unfeasible if empty intersection */
    rp_interval i;
    rp_interval_inter(i,rp_expression_val(rp_ctr_num_left(c)),
                        rp_expression_val(rp_ctr_num_right(c)));
    res = rp_interval_empty(i);
  }
  return( res );
}
Ejemplo n.º 5
0
// Application of operator to reduce the box b
int rp_operator_3b::apply(rp_box b)
{
  DREAL_LOG_DEBUG << "rp_operator_3b::apply";
  // domain to be reduced
  double u = rp_binf(rp_box_elem(b,_v));
  double v = rp_bsup(rp_box_elem(b,_v));
  double x;

  // Reduction of left bound [a,x]
  RP_ROUND_UPWARD();
  x = u + _improve * (v-u);

  if (x>=v)
  {
    // reduction of whole domain
    return _o->apply(b);
  }
  else
  {
    rp_box_copy(_baux,b);
    rp_bsup(rp_box_elem(_baux,_v)) = x;
    if (!_o->apply(_baux))
    {
      rp_binf(rp_box_elem(b,_v)) = x;
    }
  }

  // Reduction of right bound [x,b]
  RP_ROUND_DOWNWARD();
  x = v - _improve * (v-u);

  rp_box_copy(_baux,b);
  rp_binf(rp_box_elem(_baux,_v)) = x;
  if (!_o->apply(_baux))
  {
    rp_bsup(rp_box_elem(b,_v)) = x;
  }

  return( !(rp_interval_empty(rp_box_elem(b,_v))) );
}