예제 #1
0
파일: bond_graph.cpp 프로젝트: apolitis/imp
IMPATOM_BEGIN_NAMESPACE
BondGraph::BondGraph(Hierarchy bd)
    : sc_(get_as<kernel::Particles>(get_leaves(bd))) {
  for (unsigned int i = 0; i < sc_.size(); ++i) {
    if (!Bonded::get_is_setup(sc_[i])) {
      Bonded::setup_particle(sc_[i]);
    }
  }
}
예제 #2
0
IMPATOM_BEGIN_NAMESPACE

double get_resolution(Model* m, ParticleIndex pi) {
  double min = std::numeric_limits<double>::max();
  IMP_FOREACH(Hierarchy l, get_leaves(Hierarchy(m, pi))) {
    double cur = core::XYZR(l).get_radius();
    IMP_USAGE_CHECK(cur > 0, "Particle " << l << " has an invalid radius");
    min = std::min(min, cur);
  }
예제 #3
0
void get_leaves(TreeNode *root, ItemSetNode **list)
{
  if (root == NULL)
    return;

  ItemSetNode *l;

  for (l = root->item_sets; l != NULL; l = l->next)
  {
    if ((float)l->data->count / TXNS >= MIN_SUPPORT)
    {
      append_to_list(list, l->data);
    }
  }

  get_leaves(root->left,list);
  get_leaves(root->middle, list);
  get_leaves(root->right, list);
}
예제 #4
0
파일: Hierarchy.cpp 프로젝트: apolitis/imp
algebra::Sphere3D get_bounding_sphere(const Hierarchy &h) {
  kernel::ParticlesTemp rep = get_leaves(h);
  algebra::Sphere3Ds ss;
  for (unsigned int i = 0; i < rep.size(); ++i) {
    core::XYZR xyzr = core::XYZR::decorate_particle(rep[i]);
    if (xyzr) {
      ss.push_back(xyzr.get_sphere());
    } else if (core::XYZ::get_is_setup(rep[i])) {
      ss.push_back(algebra::Sphere3D(core::XYZ(rep[i]).get_coordinates(), 0));
    }
  }
  return algebra::get_enclosing_sphere(ss);
}
예제 #5
0
파일: Hierarchy.cpp 프로젝트: apolitis/imp
core::RigidBody setup_as_rigid_body(Hierarchy h) {
  IMP_USAGE_CHECK(h.get_is_valid(true),
                  "Invalid hierarchy passed to setup_as_rigid_body");
  IMP_WARN("create_rigid_body should be used instead of setup_as_rigid_body"
           << " as the former allows one to get volumes correct at coarser"
           << " levels of detail.");
  core::RigidBody rbd = core::RigidBody::setup_particle(h, get_leaves(h));
  rbd.set_coordinates_are_optimized(true);
  kernel::ParticlesTemp internal = core::get_internal(h);
  for (unsigned int i = 0; i < internal.size(); ++i) {
    if (internal[i] != h) {
      core::RigidMembers leaves(get_leaves(Hierarchy(internal[i])));
      if (!leaves.empty()) {
        algebra::ReferenceFrame3D rf = core::get_initial_reference_frame(
            get_as<kernel::ParticlesTemp>(leaves));
        core::RigidBody::setup_particle(internal[i], rf);
      }
    }
  }
  IMP_INTERNAL_CHECK(h.get_is_valid(true), "Invalid hierarchy produced");
  return rbd;
}
예제 #6
0
algebra::BoundingBox3D get_bounding_box(const Hierarchy &h) {
  ParticlesTemp rep= get_leaves(h);
  algebra::BoundingBox3D bb;
  for (unsigned int i=0; i< rep.size(); ++i) {
    core::XYZR xyzr= core::XYZR::decorate_particle(rep[i]);
    if (xyzr) {
      bb+= algebra::get_bounding_box(xyzr.get_sphere());
    } else if (core::XYZ::particle_is_instance(rep[i])) {
      bb+= algebra::BoundingBox3D(core::XYZ(rep[i]).get_coordinates());
    }
  }
  IMP_LOG(VERBOSE, "Bounding box is " << bb << std::endl);
  return bb;
}
예제 #7
0
IMP::core::RigidBody create_compatible_rigid_body(Hierarchy h,
                                               Hierarchy reference) {
  ParticlesTemp hl= get_leaves(h);
  ParticlesTemp rl= get_leaves(reference);
  algebra::Transformation3D tr
    = algebra::get_transformation_aligning_first_to_second(rl, hl);
  algebra::Transformation3D rtr
    = core::RigidMember(reference).get_rigid_body().\
    get_reference_frame().get_transformation_to();
  algebra::Transformation3D rbtr= tr*rtr;

  Particle *rbp= new Particle(h->get_model());
  rbp->set_name(h->get_name()+" rigid body");
  ParticlesTemp all = rb_process(h);
  core::RigidBody rbd
    = core::RigidBody::setup_particle(rbp, algebra::ReferenceFrame3D(rbtr));
  for (unsigned int i=0; i< all.size(); ++i) {
    rbd.add_member(all[i]);
  }
  rbd.set_coordinates_are_optimized(true);
  IMP_INTERNAL_CHECK(h.get_is_valid(true), "Invalid hierarchy produced");
  return rbd;
}
예제 #8
0
ItemSetNode *get_frequent_itemsets(TreeNode *root)
{
  FILE *fp = fopen(DATA_FILE, "r");

  char *line = NULL;

  while ((line = read_line(fp)) != NULL && *line != '\0')
  {
    traverse_tree(root, line);
    free(line);
  }

  fclose(fp);

  ItemSetNode *tmp = NULL;

  get_leaves(root, &tmp);

  return tmp;

}
예제 #9
0
    /** Dump an entire forest to a DBMS.
     *
     *  FIXME: This should really be using something like ODBC, but ROSE is only configured to use specific DBMS like SQLite3
     *  or MySQL. Therefore, since we don't need to do any queries, we'll just generate straight SQL as text (the sqlite3x API
     *  converts all numeric values to text anyway, so there's not really any additional slowdown or loss of precision).
     *  Therefore, the @p user_name and @p password arguments are unused, and @p server_name is the name of the file to which
     *  the SQL statements are written. */
    void dump(const std::string &server_name, const std::string &user_name, const std::string &password) {
        std::ofstream dbc(server_name.c_str());
        renumber_vertices();
        dump_outputsets(dbc);
        dump_inputsets(dbc);

        Vertices leaves = get_leaves();
        size_t leafnum = 0;

        for (Vertices::const_iterator vi=leaves.begin(); vi!=leaves.end(); ++vi, ++leafnum) {
            Vertex *vertex = *vi;
            const Functions &functions = vertex->get_functions();
            dbc <<"insert into simsets (id) values (" <<leafnum <<");\n";

            for (Functions::const_iterator fi=functions.begin(); fi!=functions.end(); ++fi)
                dbc <<"insert into functions (entry_va, simset_id) values (" <<(*fi)->get_entry_va() <<", " <<leafnum <<");\n";
            for (Vertex *v=vertex; v; v=v->parent)
                dbc <<"insert into inoutpairs (simset_id, inputset_id, outputset_id) values ("
                    <<leafnum <<", " <<v->get_level() <<", " <<v->id <<");\n";
        }
    }
예제 #10
0
void Interpreter::Helper::interpret(
	const ParseTree::child_pointer_type &node,
	tree_set &output)
{
	ParseTreeMatcher::match_list_type matches;
	helper_key[0] = node;
	interpreter.parse_tree_matcher.find(helper_key, matches);

#	ifdef DEBUG
	std::cout << "MATCHED RULES:" << std::endl;
	for(ParseTreeMatcher::match_list_type::const_iterator
		i = matches.begin(), n = matches.end(); i != n; ++i)
	{
		i->first->print(interpreter.symbol_info, std::cout);
		std::cout << std::endl;
	}
#	endif

	typedef std::vector<tree_set> result_list_type;
	typedef std::vector<ParseTree::child_list_type> alternation_list_type;

	result_list_type sub_results;
	TranslationTree::child_list_type translation_leaves;
	alternation_list_type alternations;

	for(ParseTreeMatcher::match_list_type::const_iterator
		i = matches.begin(), n = matches.end(); i != n; ++i)
	{
		sub_results.clear();
		translation_leaves.clear();
		/* TODO A potential optimization is to precomute the list of
		leaf nodes in each translation tree. */
		get_leaves(i->first->translation, translation_leaves);
		for(TranslationTree::child_list_type::const_iterator
			j = translation_leaves.begin(), m = translation_leaves.end(); j != m; ++j)
		{
			assert((*j)->donor_index != TranslationTree::NO_DONOR);
			assert(0 <= (*j)->donor_index && (*j)->donor_index < (int) i->second.size());
			sub_results.push_back(tree_set());
			interpret(
				ParseTree::child_pointer_type(
					new ParseTree(
						(*j)->symbol,
						i->second[(*j)->donor_index]->children)),
				sub_results.back());
		}
		/* XXX Do note that since we are re-using references when
		generating alternations of the sub-results, the parse trees
		generated can share subtrees and therefore form a DAG. So, we
		can use this as a justification for using shared pointers as
		the pointer type for ParseTree. For TranslationTree, however,
		it is not important. */
		alternations.clear();
		algorithm::generate_alternations(
			sub_results.begin(), sub_results.end(), alternations);
		for(alternation_list_type::const_iterator
			j = alternations.begin(), m = alternations.end(); j != m; ++j)
		{
			ParseTree::child_list_type::const_iterator subroot_iter = j->begin();
			output.push_back(attach_leaves(i->first->translation, subroot_iter));
		}
	}

	/* Record any parse trees which did not have any matches. */
	if(output.empty()) {
		unmatched.push_back(node);
	}

}
예제 #11
0
void setup_as_approximation(Hierarchy h, double resolution) {
  setup_as_approximation_internal(h, get_leaves(h), resolution);
}