void
load_union(const Subset &s0, const Subset &s1,
           AssignmentContainer *nd0, AssignmentContainer *nd1,
           const EdgeData &ed, double max_error,
           ParticleStatesTable* pst,
           const statistics::Metrics &metrics,
           unsigned int max,
           AssignmentContainer *out) {
  Ints ii0= get_index(s0, ed.intersection_subset);
  Ints ii1= get_index(s1, ed.intersection_subset);
  Ints ui0= get_index(ed.union_subset, s0);
  Ints ui1= get_index(ed.union_subset, s1);
  Ints uii= get_index(ed.union_subset, ed.intersection_subset);
  Assignments nd1a
    = nd1->get_assignments(IntRange(0, nd1->get_number_of_assignments()));
  // chunck outer and writing later
  unsigned int nd0sz= nd0->get_number_of_assignments();
  for (unsigned int i=0; i< nd0sz; ++i) {
    Assignment nd0a=nd0->get_assignment(i);
    Assignment nd0ae=get_sub_assignment(nd0a, ii0);
    for (unsigned int j=0; j< nd1a.size(); ++j) {
      Assignment nd1ae=get_sub_assignment(nd1a[j], ii1);
      bool merged_ok=(nd1ae==nd0ae);
      Assignment ss;
      if (!merged_ok && pst) {;
        double n= get_distance_if_smaller_than(ed.intersection_subset,
                                               nd0ae, nd1ae, pst,
                                               metrics, max_error);
        if ( n < max_error) {
          merged_ok=true;
        }
      }
      if (merged_ok) {
        ss= get_merged_assignment(ed.union_subset,
                                  nd0a, ui0,
                                  nd1a[j], ui1);
      }
      if (merged_ok) {
        bool ok=true;
        for (unsigned int k=0; k< ed.filters.size(); ++k) {
          if (ed.filters[k]->get_is_ok(ss)) {
            // pass
          } else {
            ok=false;
            break;
          }
        }
        if (ok) {
          out->add_assignment(ss);
          if (out->get_number_of_assignments() > max) {
            IMP_WARN("Truncated number of states at " << max
                     << " when merging " << s0 << " and " << s1);
            return;
          }
        }
      }
    }
  }
}
예제 #2
0
void load_union(const Subset &s0, const Subset &s1, AssignmentContainer *nd0,
                AssignmentContainer *nd1, const EdgeData &ed, size_t max,
                AssignmentContainer *out) {
  Ints ii0 = get_index(s0, ed.intersection_subset);
  Ints ii1 = get_index(s1, ed.intersection_subset);
  Ints ui0 = get_index(ed.union_subset, s0);
  Ints ui1 = get_index(ed.union_subset, s1);
  Ints uii = get_index(ed.union_subset, ed.intersection_subset);
  Assignments nd1a =
      nd1->get_assignments(IntRange(0, nd1->get_number_of_assignments()));
  // chunck outer and writing later
  unsigned int nd0sz = nd0->get_number_of_assignments();
  IMP_PROGRESS_DISPLAY("Merging subsets " << s0 << " and " << s1,
                       nd0sz * nd1a.size());
  for (unsigned int i = 0; i < nd0sz; ++i) {
    Assignment nd0a = nd0->get_assignment(i);
    Assignment nd0ae = get_sub_assignment(nd0a, ii0);
    for (unsigned int j = 0; j < nd1a.size(); ++j) {
      Assignment nd1ae = get_sub_assignment(nd1a[j], ii1);
      if (nd1ae == nd0ae) {
        Assignment ss =
            get_merged_assignment(ed.union_subset, nd0a, ui0, nd1a[j], ui1);
        bool ok = true;
        for (unsigned int k = 0; k < ed.filters.size(); ++k) {
          if (!ed.filters[k]->get_is_ok(ss)) {
            ok = false;
            break;
          }
        }
        if (ok) {
          out->add_assignment(ss);
          if (out->get_number_of_assignments() > max) {
            IMP_WARN("Truncated number of states at " << max << " when merging "
                                                      << s0 << " and " << s1);
            return;
          }
        }
      }
      IMP::base::add_to_progress_display(1);
    }
  }
}