IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
LogWrapper.h
Go to the documentation of this file.
1/**
2 * \file IMP/isd/LogWrapper.h
3 * \brief Calculate the -Log of a list of restraints.
4 *
5 * Copyright 2007-2023 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPISD_LOG_WRAPPER_H
10#define IMPISD_LOG_WRAPPER_H
11
12#include <IMP/isd/isd_config.h>
14#include <IMP/RestraintSet.h>
15#include <cereal/access.hpp>
16#include <cereal/types/base_class.hpp>
17
18
19IMPISD_BEGIN_NAMESPACE
20
21//! Calculate the -Log of a list of restraints.
22/** This is intended to be used with restraints where their score represents
23 the probability (from 0 to 1) of being satisfied.
24 \note Any weights of the wrapped restraints are ignored.
25 */
26class IMPISDEXPORT LogWrapper : public RestraintSet {
27
28 friend class cereal::access;
29 template<class Archive> void serialize(Archive &ar) {
30 ar(cereal::base_class<RestraintSet>(this));
31 }
33
34 void show_it(std::ostream &out) const;
35
36 public:
37 //! Create an empty set that is registered with the model
38 LogWrapper(Model *m, double weight, const std::string &name = "LogWrapper %1%");
39 //! Create an empty set that is registered with the model
40 LogWrapper(Model *m, const std::string &name = "LogWrapper %1%");
41 //! Create a set that is registered with the model
42 LogWrapper(const RestraintsTemp &rs, double weight,
43 const std::string &name = "LogWrapper %1%");
44 LogWrapper() {}
45
46 virtual double unprotected_evaluate(
47 IMP::DerivativeAccumulator* accum) const override;
49 IMP::DerivativeAccumulator* accum, const ParticleIndexes &moved_pis,
50 const ParticleIndexes &reset_pis) const override;
52 void do_add_score_and_derivatives_moved(
53 ScoreAccumulator sa, const ParticleIndexes &moved_pis,
54 const ParticleIndexes &reset_pis) const override;
55
57
58};
59
60IMPISD_END_NAMESPACE
61
62#endif /* IMPISD_LOG_WRAPPER_H */
Used to hold a set of related restraints.
Class for adding derivatives from restraints to the model.
RestraintSet(Model *m, double weight, const std::string &name="RestraintSet %1%")
Create an empty set that is registered with the model.
Class for adding up scores during ScoringFunction evaluation.
LogWrapper(Model *m, const std::string &name="LogWrapper %1%")
Create an empty set that is registered with the model.
LogWrapper(const RestraintsTemp &rs, double weight, const std::string &name="LogWrapper %1%")
Create a set that is registered with the model.
void do_add_score_and_derivatives(ScoreAccumulator sa) const override
Add the score and (if requested) derivatives to the accumulator.
LogWrapper(Model *m, double weight, const std::string &name="LogWrapper %1%")
Create an empty set that is registered with the model.
virtual double unprotected_evaluate_moved(IMP::DerivativeAccumulator *accum, const ParticleIndexes &moved_pis, const ParticleIndexes &reset_pis) const override
Return the unweighted score, taking moving particles into account.
virtual double unprotected_evaluate(IMP::DerivativeAccumulator *accum) const override
Return the unweighted score for the restraint.
Macros to define containers of objects.
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Definition base_types.h:199
IMP::Vector< IMP::WeakPointer< Restraint > > RestraintsTemp
Definition base_types.h:120
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.