box naive_icp::solve(box b, contractor const & ctc, SMTConfig & config) { vector<box> solns; vector<box> box_stack; box_stack.push_back(b); do { DREAL_LOG_INFO << "icp_loop()" << "\t" << "box stack Size = " << box_stack.size(); b = box_stack.back(); box_stack.pop_back(); try { b = ctc.prune(b, config); if (config.nra_use_stat) { config.nra_stat.increase_prune(); } } catch (contractor_exception & e) { // Do nothing } if (!b.is_empty()) { tuple<int, box, box> splits = b.bisect(config.nra_precision); if (config.nra_use_stat) { config.nra_stat.increase_branch(); } int const i = get<0>(splits); if (i >= 0) { box const & first = get<1>(splits); box const & second = get<2>(splits); if (second.is_bisectable()) { box_stack.push_back(second); box_stack.push_back(first); } else { box_stack.push_back(first); box_stack.push_back(second); } if (config.nra_proof) { config.nra_proof_out << "[branched on " << b.get_name(i) << "]" << endl; } } else { config.nra_found_soln++; if (config.nra_found_soln >= config.nra_multiple_soln) { break; } if (config.nra_multiple_soln > 1) { // If --multiple_soln is used output_solution(b, config, config.nra_found_soln); } solns.push_back(b); } } } while (box_stack.size() > 0); if (config.nra_multiple_soln > 1 && solns.size() > 0) { return solns.back(); } else { assert(!b.is_empty() || box_stack.size() == 0); // cerr << "BEFORE ADJUST_BOUND\n==================\n" << b << "=========================\n\n\n"; b.adjust_bound(box_stack); // cerr << "AFTER ADJUST_BOUND\n==================\n" << b << "=========================\n\n\n"; return b; } }
box ncbt_icp::solve(box b, contractor const & ctc, SMTConfig & config) { static unsigned prune_count = 0; vector<box> box_stack; vector<int> bisect_var_stack; box_stack.push_back(b); bisect_var_stack.push_back(-1); // Dummy var do { // Loop Invariant assert(box_stack.size() == bisect_var_stack.size()); DREAL_LOG_INFO << "new_icp_loop()" << "\t" << "box stack Size = " << box_stack.size(); b = box_stack.back(); try { b = ctc.prune(b, config); if (config.nra_use_stat) { config.nra_stat.increase_prune(); } } catch (contractor_exception & e) { // Do nothing } prune_count++; box_stack.pop_back(); bisect_var_stack.pop_back(); if (!b.is_empty()) { // SAT tuple<int, box, box> splits = b.bisect(config.nra_precision); if (config.nra_use_stat) { config.nra_stat.increase_branch(); } int const index = get<0>(splits); if (index >= 0) { box const & first = get<1>(splits); box const & second = get<2>(splits); if (second.is_bisectable()) { box_stack.push_back(second); box_stack.push_back(first); } else { box_stack.push_back(first); box_stack.push_back(second); } bisect_var_stack.push_back(index); bisect_var_stack.push_back(index); } else { break; } } else { // UNSAT while (box_stack.size() > 0) { assert(box_stack.size() == bisect_var_stack.size()); int bisect_var = bisect_var_stack.back(); ibex::BitSet const & input = ctc.input(); DREAL_LOG_DEBUG << ctc; if (!input[bisect_var]) { box_stack.pop_back(); bisect_var_stack.pop_back(); } else { break; } } } } while (box_stack.size() > 0); DREAL_LOG_DEBUG << "prune count = " << prune_count; b.adjust_bound(box_stack); return b; }