IMP logo
IMP Reference Guide  2.6.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-2016 IMP Inventors. 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/Object.h>
17 #include <IMP/Pointer.h>
18 #include <IMP/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::Object {
27 
28  public:
29  LocalPlanner(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  // somewhat close to q_rand
34  virtual std::vector<DOFValues> plan(DOFValues q_near, DOFValues q_rand,
35  ScoringFunction *sf) = 0;
36 
37  bool is_valid(const DOFValues& values, ScoringFunction *sf) {
38  dofs_sampler_->apply(values);
39  double score = sf->evaluate_if_below(false, 0.0); // TODO: what here?
40  // std::cerr << "score = " << score << std::endl;
41  if (score <= 0.000001) return true;
42  return false;
43  }
44 
45  protected:
46  PointerMember<Model> model_;
47  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(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  ScoringFunction *sf);
78 
79  private:
80  DirectionalDOF* d_;
81  unsigned int save_step_interval_; // if 0, save only last valid node
82 };
83 
86 
87 IMPKINEMATICS_END_NAMESPACE
88 
89 #endif /* IMPKINEMATICS_LOCAL_PLANNERS_H */
a simple class for storage of DOF values.
Copyright 2007-2016 IMP Inventors. All rights reserved.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Storage of a model, its restraints, constraints and particles.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Common base class for heavy weight IMP objects.
Definition: Object.h:106
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:146
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Definition: object_macros.h:42
A nullptr-initialized pointer to an IMP Object.
Represents a scoring function on the model.
A shared base class to help in debugging and things.