// FIXME It actually performs intersection which is inconsistent with intersect bool sqr_inverse(interval& z, interval& x, interval& gap) { bool has_gap = false; const interval x_1 = sqrt(z); const interval x_2 = -x_1; interval x_image; if (disjoint(x, x_2)) { x_image = x_1; } else if (disjoint(x, x_1)) { x_image = x_2; } else { gap = interval(x_2.sup(), x_1.inf()); has_gap = gap.diameter() > IMPROVEMENT_TOL; // FIXME GAP_SQRT_TOL ? x_image = hull_of(x_1, x_2); } x.intersect(x_image); z.intersect(sqr(x)); return has_gap; }
inline bool RuleIntroductionSolver::isIntroducedRuleSatisfied(const Hypergraph::Vertices& trueAtoms, const Hypergraph::Vertices& falseAtoms) const { assert(heads.find(introducedRule) != heads.end()); assert(positiveBody.find(introducedRule) != positiveBody.end()); assert(negativeBody.find(introducedRule) != negativeBody.end()); return !disjoint(heads.at(introducedRule), trueAtoms) || !disjoint(positiveBody.at(introducedRule), falseAtoms) || !disjoint(negativeBody.at(introducedRule), trueAtoms); }
void RdfDB::bindVariables (ResultSet* rs, const POS* graph, const BasicGraphPattern* toMatch) { if (graph == NULL) graph = DefaultGraph; graphmap_type::const_iterator vi; size_t matched = 0; /* Look in each candidate graph. */ if (graph->isConstant()) { if ((vi = graphs.find(graph)) != graphs.end()) { vi->second->bindVariables(rs, graph, toMatch, vi->first); ++matched; } } else { ResultSet island(rs->getPOSFactory()); delete *(island.begin()); island.erase(island.begin()); for (vi = graphs.begin(); vi != graphs.end(); vi++) if (vi->first != DefaultGraph) { ResultSet disjoint(rs->getPOSFactory()); vi->second->bindVariables(&disjoint, graph, toMatch, vi->first); for (ResultSetIterator row = disjoint.begin() ; row != disjoint.end(); ) { island.insert(island.end(), (*row)->duplicate(&island, island.end())); delete *row; row = disjoint.erase(row); } ++matched; } rs->joinIn(&island, false); } if (matched == 0) for (ResultSetIterator it = rs->begin(); it != rs->end(); ) { delete *it; it = rs->erase(it); } }
void compare(char *a, char *b) { if (equal(a, b)) printf("A equals B\n"); else if (contain(a, b)) printf("B is a proper subset of A\n"); else if (contain(b, a)) printf("A is a proper subset of B\n"); else if (disjoint(a, b)) printf("A and B are disjoint\n"); else printf("I'm confused!\n"); }
typename mpfr_bin_ieee754_flavor<T>::representation mpfr_bin_ieee754_flavor<T>::intersection(mpfr_bin_ieee754_flavor<T>::representation const& x, mpfr_bin_ieee754_flavor<T>::representation const& y) { if (!is_valid(x) || !is_valid(y)) return empty(); if (disjoint(x, y)) return empty(); else return representation(std::max(x.first, y.first), std::min(x.second, y.second)); }
void interval_set_operators_4_bicremental_types() { typedef IntervalSet<T> IntervalSetT; typedef typename IntervalSetT::interval_type IntervalT; T v0 = make<T>(0); T v1 = make<T>(1); T v3 = make<T>(3); T v5 = make<T>(5); T v7 = make<T>(7); T v8 = make<T>(8); IntervalSet<T> left, left2, right, all, all2, section, complement, naught; left.add(IntervalT::closed(v0,v1)).add(IntervalT::closed(v3,v5)); (right += IntervalT::closed(v3,v5)) += IntervalT::closed(v7,v8); BOOST_CHECK_EQUAL( disjoint(left, right), false ); (all += left) += right; (section += left) &= right; (complement += all) -= section; (all2 += section) += complement; BOOST_CHECK_EQUAL( disjoint(section, complement), true ); BOOST_CHECK_EQUAL( all, all2 ); BOOST_CHECK_EQUAL( icl::contains(all, left), true ); BOOST_CHECK_EQUAL( icl::contains(all, right), true ); BOOST_CHECK_EQUAL( icl::contains(all, complement), true ); BOOST_CHECK_EQUAL( icl::contains(left, section), true ); BOOST_CHECK_EQUAL( icl::contains(right, section), true ); BOOST_CHECK_EQUAL( within(left, all), true ); BOOST_CHECK_EQUAL( within(right, all), true ); BOOST_CHECK_EQUAL( within(complement, all), true ); BOOST_CHECK_EQUAL( within(section, left), true ); BOOST_CHECK_EQUAL( within(section, right), true ); }
void interval_set_mixed_disjoint_4_bicremental_types() { typedef interval_set<T> IntervalSetT; typedef typename IntervalSetT::interval_type IntervalT; T v0 = make<T>(0); T v2 = make<T>(2); T v3 = make<T>(3); T v4 = make<T>(4); T v6 = make<T>(6); IntervalT I0_2D = IntervalT::right_open(v0,v2); IntervalT I2_3D = IntervalT::right_open(v2,v3); IntervalT I3_4D = IntervalT::right_open(v3,v4); IntervalT I4_4I = IntervalT::closed(v4,v4); IntervalT C4_6D = IntervalT::open(v4,v6); IntervalT I6_6I = IntervalT::closed(v6,v6); //-------------------------------------------------------------------------- //split_A: [0 2) [4 4] [6 6] //split_B: [2 3)[3 4) (4 6) split_interval_set<T> split_A, split_B; split_A.add(I0_2D).add(I4_4I).add(I6_6I); split_B.add(I2_3D).add(I3_4D).add(C4_6D); separate_interval_set<T> sep_A(split_A), sep_B(split_B); interval_set<T> join_A(split_A), join_B(split_B); BOOST_CHECK_EQUAL( disjoint(split_A, split_B), true ); BOOST_CHECK_EQUAL( disjoint(split_A, sep_B), true ); BOOST_CHECK_EQUAL( disjoint(split_A, join_B), true ); BOOST_CHECK_EQUAL( disjoint(sep_A, split_B), true ); BOOST_CHECK_EQUAL( disjoint(sep_A, sep_B), true ); BOOST_CHECK_EQUAL( disjoint(sep_A, join_B), true ); BOOST_CHECK_EQUAL( disjoint(join_A, split_B), true ); BOOST_CHECK_EQUAL( disjoint(join_A, sep_B), true ); BOOST_CHECK_EQUAL( disjoint(join_A, join_B), true ); }
// expand index set by s1. // it is assumed that s1 is disjoint from the current index set. void DoubleCRT::addPrimes(const IndexSet& s1) { if (empty(s1)) return; // nothing to do assert( disjoint(s1,map.getIndexSet()) ); // s1 is disjoint from *this ZZX poly; toPoly(poly); // recover in coefficient representation map.insert(s1); // add new rows to the map if (dryRun) return; // fill in new rows for (long i = s1.first(); i <= s1.last(); i = s1.next(i)) { context.ithModulus(i).FFT(map[i], poly); // reduce mod p_i and store FFT image } }
ExecStatus EqInt<VY>::propagate(Space& home, const ModEventDelta& med) { // Add assigned views to value set if (IntView::me(med) == ME_INT_VAL) add(home); GECODE_ME_CHECK(y.gq(home, vs.size())); GECODE_ME_CHECK(y.lq(home, x.size() + vs.size())); if (x.size() == 0) return home.ES_SUBSUMED(*this); // All values must be in the value set if (y.max() == vs.size()) return all_in_valset(home); // Compute positions of disjoint views and eliminate subsumed views Region r(home); int* dis; int n_dis; disjoint(home,r,dis,n_dis); // The number might have changed due to elimination of subsumed views GECODE_ME_CHECK(y.lq(home, x.size() + vs.size())); if (x.size() == 0) { assert(y.val() == vs.size()); return home.ES_SUBSUMED(*this); } GECODE_ES_CHECK(prune_upper(home,g)); // No lower bound pruning possible if (n_dis == 0) return ES_NOFIX; // Only if the propagator is at fixpoint here, continue with // propagating the lower bound if (IntView::me(Propagator::modeventdelta()) != ME_INT_NONE) return ES_NOFIX; // Do lower bound-based pruning GECODE_ES_CHECK(prune_lower(home,dis,n_dis)); return ES_NOFIX; }
ExecStatus LqInt<VY>::propagate(Space& home, const ModEventDelta& med) { // Add assigned views to value set if (IntView::me(med) == ME_INT_VAL) add(home); GECODE_ME_CHECK(y.gq(home, vs.size())); if (x.size() == 0) return home.ES_SUBSUMED(*this); // All values must be in the value set if (y.max() == vs.size()) return all_in_valset(home); if (x.size() + vs.size() <= y.min()) return home.ES_SUBSUMED(*this); // Compute positions of disjoint views Region r(home); int* dis; int n_dis; disjoint(home,r,dis,n_dis); // Some views might have been eliminated as they are subsumed if (x.size() == 0) return home.ES_SUBSUMED(*this); // No lower bound pruning possible if (n_dis == 0) return ES_NOFIX; // Do lower bound-based pruning GECODE_ES_CHECK(prune_lower(home,dis,n_dis)); return ES_NOFIX; }
bool pool::is_same_species(const genome& g1, const genome& g2){ double dd = this->speciating_parameters.delta_disjoint * disjoint(g1, g2); double dw = this->speciating_parameters.delta_weights * weights(g1, g2); return dd + dw < this->speciating_parameters.delta_threshold; }
inline bool RuleIntroductionSolver::doesIntroducedRuleDisappear(const Hypergraph::Vertices& trueAtoms) const { assert(negativeBody.find(introducedRule) != negativeBody.end()); return !disjoint(negativeBody.at(introducedRule), trueAtoms); }
bool samespecies(Genome* g1, Genome* g2) { return disjoint(g1, g2) * DeltaDisjoint + weightdiff(g1, g2) * DeltaWeights < DeltaThreshold; }