コード例 #1
0
ファイル: rp_operator.cpp プロジェクト: JichaoS/dreal
// Destruction
rp_operator_newton::~rp_operator_newton()
{
  for (int i=0; i<_fi; ++i)
  {
    rp_free(_vf[i]);
  }
  rp_free(_vf);
  rp_free(_f);
  rp_free(_v);
  rp_box_destroy(&_midpoint);
  rp_interval_matrix_destroy(&_jacobi);
  rp_interval_matrix_destroy(&_izero);
  rp_interval_vector_destroy(&_negfmid);
  rp_interval_vector_destroy(&_unknown);
  rp_real_matrix_destroy(&_midjacobi);
  rp_real_matrix_destroy(&_precond);
  rp_real_matrix_destroy(&_identity);

  rp_interval_matrix_destroy(&_precond_jacobi);
  rp_interval_vector_destroy(&_precond_negfmid);
}
コード例 #2
0
ファイル: rp_operator.cpp プロジェクト: JichaoS/dreal
// Destruction
rp_operator_3b::~rp_operator_3b()
{
  rp_box_destroy(&_baux);
  rp_delete(_o);
}
コード例 #3
0
void rp_splitter_mixed_hybrid::apply(rp_box_set& bs, int var) {
  rp_interval i1, i2;
  rp_box b1 = bs.remove_insert();
  this->observe(b1, var);
  rp_box b2 = bs.insert(b1);

  rp_box b1_copy;
  rp_box_clone(&b1_copy, b1);
  rp_box suggestion = m_ode_sim_heuristic->sim(b1_copy, var);


  DREAL_LOG_DEBUG << "rp_splitter_mixed_hybrid::apply() "
                  << "suggestion = " << var << " [" << rp_binf(rp_box_elem(suggestion, var)) << ", "
                  << rp_bsup(rp_box_elem(suggestion, var))
                  << "]";
  if (rp_variable_integer(rp_problem_var(*_problem, var)))  {
    if (this->integer_hole(rp_box_elem(b1, var),
                           rp_variable_domain(rp_problem_var(*_problem, var)),
                           i1, i2)){
      if (rp_interval_included(i1, rp_box_elem(suggestion, var))){
        rp_interval_copy(rp_box_elem(b1, var), i1);
        rp_interval_copy(rp_box_elem(b2, var), i2);
      } else{
        rp_interval_copy(rp_box_elem(b1, var), i2);
        rp_interval_copy(rp_box_elem(b2, var), i1);
      }
    } else  { // no hole found
      ++rp_binf(rp_box_elem(b1, var));
      if (rp_interval_included(rp_box_elem(b1, var), rp_box_elem(suggestion, var))){
        // Integer variable: [a,b] --> [a+1,b] and [a,a]
        rp_bsup(rp_box_elem(b2, var)) = rp_binf(rp_box_elem(b2, var));
      } else {
        --rp_binf(rp_box_elem(b1, var));
        ++rp_binf(rp_box_elem(b2, var));
        rp_bsup(rp_box_elem(b1, var)) = rp_binf(rp_box_elem(b1, var));
      }
    }
  }  else  {
    if (this->real_hole(rp_box_elem(b1, var),
                        rp_variable_domain(rp_problem_var(*_problem, var)),
                        i1, i2)) {
      if (rp_interval_included(i1, rp_box_elem(suggestion,  var))){
        rp_interval_copy(rp_box_elem(b1, var), i1);
        rp_interval_copy(rp_box_elem(b2, var), i2);
      }  else {
        rp_interval_copy(rp_box_elem(b1, var), i2);
        rp_interval_copy(rp_box_elem(b2, var), i1);
      }
    }  else {
      // Real variable: [a,b] --> [center,b] and [a,center]
      double mid = rp_interval_midpoint(rp_box_elem(b1, var));

      rp_binf(rp_box_elem(b1, var)) =
        rp_bsup(rp_box_elem(b2, var)) =
          mid;

      double b1Intersection =
        std::min(rp_bsup(rp_box_elem(b1, var)), rp_bsup(rp_box_elem(suggestion, var))) -
        std::max(rp_binf(rp_box_elem(b1, var)), rp_binf(rp_box_elem(suggestion, var)));
      double b2Intersection =
        std::min(rp_bsup(rp_box_elem(b2, var)), rp_bsup(rp_box_elem(suggestion, var))) -
        std::max(rp_binf(rp_box_elem(b2, var)), rp_binf(rp_box_elem(suggestion, var)));

      if (b2Intersection > b1Intersection
          // rp_interval_included(rp_box_elem(suggestion, var), rp_box_elem(b2, var))
          ){
        // okay
        DREAL_LOG_DEBUG << "rp_splitter_mixed_hybrid::apply() "
                        << "*[" << rp_binf(rp_box_elem(b2, var)) << ", " << rp_bsup(rp_box_elem(b2, var))
                        << "]* [" << rp_binf(rp_box_elem(b1, var)) << ", " << rp_bsup(rp_box_elem(b1, var))
                        << "]";
        // cout  << "*[" << rp_binf(rp_box_elem(b2, var)) << ", " << rp_bsup(rp_box_elem(b2, var))
        //                 << "]* [" << rp_binf(rp_box_elem(b1, var)) << ", " << rp_bsup(rp_box_elem(b1, var))
        //                 << "] \t";
      } else if (b2Intersection < b1Intersection){
          // rp_interval_included(rp_box_elem(suggestion, var), rp_box_elem(b1, var))){
        // reverse

        double b2_sup = rp_bsup(rp_box_elem(b1, var));
        rp_binf(rp_box_elem(b1, var)) = rp_binf(rp_box_elem(b2, var));
        rp_bsup(rp_box_elem(b1, var)) = mid;
        rp_binf(rp_box_elem(b2, var)) = mid;
        rp_bsup(rp_box_elem(b2, var)) = b2_sup;
        DREAL_LOG_DEBUG << "rp_splitter_mixed_hybrid::apply() "
                        << "[" << rp_binf(rp_box_elem(b1, var)) << ", " << rp_bsup(rp_box_elem(b1, var))
                        << "] *[" << rp_binf(rp_box_elem(b2, var)) << ", " << rp_bsup(rp_box_elem(b2, var))
                        << "]*";
        // cout << "[" << rp_binf(rp_box_elem(b1, var)) << ", " << rp_bsup(rp_box_elem(b1, var))
        //                 << "] *[" << rp_binf(rp_box_elem(b2, var)) << ", " << rp_bsup(rp_box_elem(b2, var))
        //                 << "]* \t";
      } else {
        DREAL_LOG_DEBUG << "rp_splitter_mixed_hybrid::apply() suggestion not found";
        DREAL_LOG_DEBUG << "rp_splitter_mixed_hybrid::apply() "
                        << "-[" << rp_binf(rp_box_elem(b2, var)) << ", " << rp_bsup(rp_box_elem(b2, var))
                        << "]- [" << rp_binf(rp_box_elem(b1, var)) << ", " << rp_bsup(rp_box_elem(b1, var))
                        << "]";
        // cout << "-[" << rp_binf(rp_box_elem(b2, var)) << ", " << rp_bsup(rp_box_elem(b2, var))
        //      << "]- [" << rp_binf(rp_box_elem(b1, var)) << ", " << rp_bsup(rp_box_elem(b1, var))
        //      << "] \t";
      }
    }
  }
  rp_box_destroy(&b1_copy);
}