IMP logo
IMP Reference Guide  2.15.0
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-2021 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKINEMATICS_LOCAL_PLANNERS_H
10 #define IMPKINEMATICS_LOCAL_PLANNERS_H
11 
12 #include <IMP/kinematics/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  //std::cout << sf->evaluate(false) << " | ";
40  double score = sf->evaluate_if_below(false, 0.0); // TODO: what here?
41  if (score <= 0.000001) return true;
42  return false;
43  }
44 
45  protected:
46  PointerMember<Model> model_;
47  PointerMember<DOFsSampler> dofs_sampler_;
48 };
49 
50 //! Local planner that samples conformations on a path between two nodes.
51 /** @note the default path planning is over a linear interpolation between
52  the nodes
53  */
54 class IMPKINEMATICSEXPORT PathLocalPlanner : public LocalPlanner {
55  public:
56  //! Construct a path planner (default planning is linear)
57  /** @param model the working model
58  @param dofs_sampler an object for sampling node configurations
59  @param directional_dof XX TODO XX
60  @param save_step_interval the interval for recording nodes in the path.
61  For instance, 2 would mean save every
62  node in the local plan.
63  */
64  PathLocalPlanner(Model* model, DOFsSampler* dofs_sampler,
65  DirectionalDOF* directional_dof, int save_step_interval = 1);
66 
67  protected:
68  /** plan a linear path of intermediate nodes with a properly calculated
69  step size from existing node q_from until the valid node that is
70  found closest to q_rand (inclusive)
71  */
72  virtual std::vector<DOFValues> plan(DOFValues q_from, DOFValues q_rand,
73  ScoringFunction *sf);
74 
75  private:
77  unsigned int save_step_interval_; // if 0, save only last valid node
78 };
79 
82 
83 IMPKINEMATICS_END_NAMESPACE
84 
85 #endif /* IMPKINEMATICS_LOCAL_PLANNERS_H */
a simple class for storage of DOF values.
Copyright 2007-2021 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.
A more IMP-like version of the std::vector.
Definition: Vector.h:40
Base class for sampling certain combinations of degrees of freedom.
Definition: DOFsSampler.h:17
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 class that holds DOF values for DOFs.
Definition: DOFValues.h:20
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 lists of object pointers.
Definition: object_macros.h:44
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.
Local planner that samples conformations on a path between two nodes.