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 return get_model()->get_optimized_attributes();
42 void set_value(
FloatIndex fi,
double v)
const {
43 get_model()->set_attribute(fi.get_key(), fi.get_particle(), v);
47 return get_model()->get_attribute(fi.get_key(), fi.get_particle());
51 return get_model()->get_derivative(fi.get_key(), fi.get_particle());
57 if (widths_.size() <= k.get_index() || widths_[k.get_index()] == 0) {
59 double wid =
static_cast<double>(w.second) - w.first;
60 widths_.resize(std::max(widths_.size(), size_t(k.get_index() + 1)), 0.0);
63 widths_[k.get_index()] = wid;
65 widths_[k.get_index()] = 1.0;
68 return widths_[k.get_index()];
79 double wid = get_width(fi.get_key());
80 set_value(fi, v * wid);
84 double uv = get_value(fi);
85 double wid = get_width(fi.get_key());
89 double get_scaled_derivative(
FloatIndex fi)
const {
90 double uv = get_derivative(fi);
91 double wid = get_width(fi.get_key());
102 friend class cereal::access;
104 template<
class Archive>
void serialize(Archive &ar) {
105 ar(cereal::base_class<Optimizer>(
this));
106 if (std::is_base_of<cereal::detail::InputArchiveBase, Archive>::value) {
114 IMPKERNEL_END_NAMESPACE
A FloatIndex identifies an optimized attribute in a model.
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.
#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.