IMP  2.2.1
The Integrative Modeling Platform
local_planners.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kinematics/local_planners.h
3  * \brief Planners
4  *
5  * Copyright 2007-2014 Sali Lab. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKINEMATICS_LOCAL_PLANNERS_H
10 #define IMPKINEMATICS_LOCAL_PLANNERS_H
11 
12 #include "kinematics_config.h"
13 #include "DOFValues.h"
14 #include "directional_DOFs.h"
15 #include "DOFsSampler.h"
16 #include <IMP/base/Object.h>
17 #include <IMP/base/Pointer.h>
18 #include <IMP/kernel/Model.h>
19 
20 IMPKINEMATICS_BEGIN_NAMESPACE
21 
22 /** general interface for planning the motion between two
23  configuration nodes, each abstracted as a vector of DoFs
24 */
25 class IMPKINEMATICSEXPORT LocalPlanner : public IMP::base::Object {
27 
28  public:
29  LocalPlanner(kernel::Model* model, DOFsSampler* dofs_sampler);
30 
31  // plan a path of valid intermediate nodes
32  // from existing node q_from until the valid node that is
33  // somewhay close to q_rand
34  virtual std::vector<DOFValues> plan(DOFValues q_near, DOFValues q_rand) = 0;
35 
36  bool is_valid(const DOFValues& values) {
37  dofs_sampler_->apply(values);
38  double score = sf_->evaluate_if_below(false, 0.0); // TODO: what here?
39  // std::cerr << "score = " << score << std::endl;
40  if (score <= 0.000001) return true;
41  return false;
42  }
43 
44  protected:
46  DOFsSampler* dofs_sampler_;
48 };
49 
50 /**
51  Local planner implementation that samples conformations on a path
52  between two nodes.
53  @note the default path planning is over a linear interpolation between
54  the nodes
55 */
56 class IMPKINEMATICSEXPORT PathLocalPlanner : public LocalPlanner {
57  public:
58  //! construct a path planner (default planning is linear)
59  /**
60  construct a path planner
61  @param model the working model
62  @param dofs_sampler an object for sampling node configurations
63  @param directional_dof XX TODO XX
64  @param save_step_interval the interval for recording nodes in the path.
65  For instance, 2 would mean save every second node
66  in the local plan.
67  */
68  PathLocalPlanner(kernel::Model* model, DOFsSampler* dofs_sampler,
69  DirectionalDOF* directional_dof, int save_step_interval = 1);
70 
71  protected:
72  /** plan a linear path of intermediate nodes with a properly calculated
73  step size from existing node q_from until the valid node that is
74  found closest to q_rand (inclusive)
75  */
76  virtual std::vector<DOFValues> plan(DOFValues q_from, DOFValues q_rand);
77 
78  private:
79  DirectionalDOF* d_;
80  unsigned int save_step_interval_; // if 0, save only last valid node
81 };
82 
85 
86 IMPKINEMATICS_END_NAMESPACE
87 
88 #endif /* IMPKINEMATICS_LOCAL_PLANNERS_H */
A nullptr-initialized pointer to an IMP Object.
a simple class for storage of DOF values.
A smart pointer to a ref-counted Object that is a class memeber.
Definition: base/Pointer.h:147
Copyright 2007-2014 Sali Lab. All rights reserved.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Storage of a model, its restraints, constraints and particles.
Common base class for heavy weight IMP objects.
Definition: base/Object.h:106
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
A shared base class to help in debugging and things.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72