9 #ifndef IMPKERNEL_ATTRIBUTE_OPTIMIZER_H
10 #define IMPKERNEL_ATTRIBUTE_OPTIMIZER_H
12 #include <IMP/kernel_config.h>
14 #include <cereal/access.hpp>
15 #include <cereal/types/base_class.hpp>
17 IMPKERNEL_BEGIN_NAMESPACE
40 Model *m = get_model();
41 return m->get_optimized_attributes()
42 + m->internal::Vector3DDerivAttributeTable::get_optimized_vector_attributes()
43 + m->internal::Vector4DDerivAttributeTable::get_optimized_vector_attributes();
45 void set_value(
FloatIndex fi,
double v)
const {
46 fi.set_value(get_model(), v);
50 return fi.get_value(get_model());
54 return fi.get_derivative(get_model());
60 if (widths_.size() <= k.get_index() || widths_[k.get_index()] == 0) {
62 double wid =
static_cast<double>(w.second) - w.first;
63 widths_.resize(std::max(widths_.size(), size_t(k.get_index() + 1)), 0.0);
66 widths_[k.get_index()] = wid;
68 widths_[k.get_index()] = 1.0;
71 return widths_[k.get_index()];
88 double wid = get_width(k);
89 set_value(fi, v * wid);
94 double uv = get_value(fi);
99 double wid = get_width(fi.get_float_key());
104 double get_scaled_derivative(
FloatIndex fi)
const {
105 double uv = get_derivative(fi);
110 double wid = get_width(fi.get_float_key());
122 friend class cereal::access;
124 template<
class Archive>
void serialize(Archive &ar) {
125 ar(cereal::base_class<Optimizer>(
this));
126 if (std::is_base_of<cereal::detail::InputArchiveBase, Archive>::value) {
134 IMPKERNEL_END_NAMESPACE
Key< 0 > FloatKey
The type used to identify float attributes in the Particles.
std::pair< Float, Float > FloatRange
A pair representing the allowed range for a Float attribute.
Base class for all optimizers.
Class for storing model, its restraints, constraints, and particles.
Base class for all optimizers.
A FloatIndex identifies an optimized attribute in a model.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Base class for optimizers that act on individual attributes.
double Float
Basic floating-point value (could be float, double...)
void clear_range_cache()
Clear the cache of range information. Do this at the start of.