home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
develop.34c5cf4f65,2026/02/03
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
include
IMP
example
version 20260203.develop.34c5cf4f65
ExampleConstraint.h
Go to the documentation of this file.
1
/**
2
* \file IMP/example/ExampleConstraint.h
3
* \brief A restraint on a list of particle pairs.
4
*
5
* Copyright 2007-2026 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPEXAMPLE_EXAMPLE_CONSTRAINT_H
10
#define IMPEXAMPLE_EXAMPLE_CONSTRAINT_H
11
12
#include <IMP/example/example_config.h>
13
#include <
IMP/SingletonScore.h
>
14
#include <
IMP/Constraint.h
>
15
#include <
IMP/PairContainer.h
>
16
#include <
IMP/PairScore.h
>
17
#include <cereal/access.hpp>
18
19
IMPEXAMPLE_BEGIN_NAMESPACE
20
21
//! A trivial constraint that just increments a counter
22
/**
23
*/
24
class
IMPEXAMPLEEXPORT
ExampleConstraint
:
public
Constraint
{
25
ParticleIndex
p_;
26
IntKey
k_;
27
28
public
:
29
ExampleConstraint
(
Particle
*p);
30
ExampleConstraint
() {}
31
32
ParticleIndex
get_index
()
const
{
return
p_; }
33
34
virtual
void
do_update_attributes()
override
;
35
virtual
void
do_update_derivatives(
DerivativeAccumulator
*da)
override
;
36
virtual
ModelObjectsTemp
do_get_inputs
()
const override
;
37
virtual
ModelObjectsTemp
do_get_outputs
()
const override
;
38
39
static
IntKey
get_key();
40
IMP_OBJECT_METHODS
(
ExampleConstraint
);
41
42
private
:
43
// Serialization support
44
friend
class
cereal::access;
45
template
<
class
Archive>
void
serialize(Archive &ar) {
46
ar(cereal::base_class<Constraint>(
this
), p_);
47
// There is no need to serialize the IntKey - just recreate it on load:
48
if
(std::is_base_of<cereal::detail::InputArchiveBase, Archive>::value) {
49
k_ = get_key();
50
}
51
}
52
IMP_OBJECT_SERIALIZE_DECL
(ExampleConstraint);
53
};
54
55
IMPEXAMPLE_END_NAMESPACE
56
57
#endif
/* IMPEXAMPLE_EXAMPLE_CONSTRAINT_H */
IMP_OBJECT_METHODS
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition:
object_macros.h:25
IMP::Index< ParticleIndexTag >
IMP::Vector
A more IMP-like version of the std::vector.
Definition:
Vector.h:50
IMP::Constraint
Implement a constraint on the Model.
Definition:
Constraint.h:49
PairContainer.h
A container for Pairs.
IMP::domino::get_index
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
PairScore.h
Define PairScore.
IMP_OBJECT_SERIALIZE_DECL
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
Definition:
object_macros.h:95
IMP::Key< 1 >
Constraint.h
A base class for constraints.
SingletonScore.h
Define SingletonScore.
IMP::ModelObject::do_get_outputs
virtual ModelObjectsTemp do_get_outputs() const =0
IMP::Particle
Class to handle individual particles of a Model object.
Definition:
Particle.h:45
IMP::example::ExampleConstraint
A trivial constraint that just increments a counter.
Definition:
ExampleConstraint.h:24
IMP::ModelObject::do_get_inputs
virtual ModelObjectsTemp do_get_inputs() const =0
IMP::DerivativeAccumulator
Class for adding derivatives from restraints to the model.
Definition:
DerivativeAccumulator.h:24