bool ilp_solution_t::do_satisfy_requirement( const pg::requirement_t::element_t &req) const { hash_set<variable_idx_t> vars; m_ilp->enumerate_variables_for_requirement(req, &vars); for (auto v : vars) if (variable_is_active(v)) return true; return false; }
void ilp_solution_t::enumerate_unified_terms_sets(std::list<hash_set<term_t> > *out) const { const ilp_problem_t *prob = problem(); const pg::proof_graph_t *graph = prob->proof_graph(); assert(out->empty()); // ON BEGINNING, OUT MUST BE EMPTY. for (auto n : graph->nodes()) if (n.is_equality_node()) { variable_idx_t v = problem()->find_variable_with_node(n.index()); if (v >= 0) if (variable_is_active(v)) { const std::vector<term_t> &unified = n.literal().terms; auto it_set = out->begin(); for (; it_set != out->end(); ++it_set) if (it_set->count(unified.at(0)) > 0 or it_set->count(unified.at(1)) > 0) break; if (it_set == out->end()) out->push_back(hash_set<term_t>(unified.begin(), unified.end())); else it_set->insert(unified.begin(), unified.end()); } } while (true) { bool has_merged(false); for (auto it1 = out->begin(); it1 != out->end() and not has_merged; ++it1) for (auto it2 = out->begin(); it2 != it1 and not has_merged; ++it2) if (it1 != it2) if (util::has_intersection(it1->begin(), it1->end(), it2->begin(), it2->end())) { it1->insert(it2->begin(), it2->end()); out->erase(it2); has_merged = true; } if (not has_merged) break; } }
void ilp_solution_t::get_reduced_sol(std::set<literal_t> *p_literals, std::set<literal_t> *p_non_eqs, const std::list< hash_set<term_t> > &terms) const { const ilp_problem_t *prob = problem(); const pg::proof_graph_t *graph = prob->proof_graph(); hash_map<term_t, term_t> t2r; _getRepresentative(&t2r, terms); auto reguralized = [&t2r](const std::list<hash_set<term_t> > &terms, const literal_t &lit) -> literal_t { literal_t out(lit); for (term_idx_t i = 0; i < out.terms.size(); ++i) { if (t2r.count(out.terms.at(i)) > 0) { out.terms[i] = t2r[out.terms.at(i)]; break; } } return out; }; // ENUMERATE ELEMENTS OF literals AND non_eqs for (auto n : graph->nodes()) if (not n.is_equality_node()) if (n.type() == pg::NODE_HYPOTHESIS or n.type() == pg::NODE_OBSERVABLE) { variable_idx_t v = problem()->find_variable_with_node(n.index()); if (v >= 0) if (variable_is_active(v)) { if (n.is_non_equality_node()) p_non_eqs->insert(reguralized(terms, n.literal())); else p_literals->insert(reguralized(terms, n.literal())); } } }