// Application of operator to reduce the box b int rp_operator_condvar::apply(rp_box b) { DREAL_LOG_DEBUG << "rp_operator_condvar::apply"; // check whether the guard is certainly satisfied if (rp_interval_included(rp_box_elem(b,_v),_dom)) { return( _o->apply(b) ); } else { return( 1 ); } }
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); }