8 #ifndef IMPKERNEL_OPTIMIZER_H
9 #define IMPKERNEL_OPTIMIZER_H
11 #include <IMP/kernel/kernel_config.h>
24 IMPKERNEL_BEGIN_NAMESPACE
62 double optimize(
unsigned int max_steps);
71 void set_score_threshold(
double s) {min_score_=s;}
72 double get_score_threshold()
const {
return min_score_;}
79 stop_on_good_score_=tf;
81 bool get_stop_on_good_score()
const {
82 return stop_on_good_score_;
86 return cache_->get_last_score();
106 void set_model(
Model *m);
110 virtual void show(std::ostream &out= std::cout)
const {
111 out <<
"Some optimizer" << std::endl;
125 set_optimizer_state_optimizer(obj,
this);
126 obj->set_was_used(
true);
128 {Optimizer::set_optimizer_state_optimizer(obj,
nullptr);});
134 virtual void set_scoring_function(ScoringFunctionAdaptor sf);
137 void set_restraints(
const RestraintsTemp &rs);
144 virtual double do_optimize(
unsigned int ns) =0;
148 void update_states()
const;
160 return get_model()->get_optimized_attributes();
163 get_model()->set_attribute(fi.get_key(), fi.get_particle(), v);
167 return get_model()->get_attribute(fi.get_key(), fi.get_particle());
171 return get_model()->get_derivative(fi.get_key(), fi.get_particle());
177 if (widths_.size() <=k.get_index() || widths_[k.get_index()]==0) {
179 double wid=
static_cast<double>(w.second)- w.first;
180 widths_.resize(std::max(widths_.size(), size_t(k.get_index()+1)), 0.0);
183 widths_[k.get_index()]= wid;
185 widths_[k.get_index()]= 1.0;
188 return widths_[k.get_index()];
201 double wid = width(fi.get_key());
202 set_value(fi, v*wid);
207 double uv= get_value(fi);
208 double wid = width(fi.get_key());
214 double uv=get_derivative(fi);
215 double wid= width(fi.get_key());
232 void set_is_optimizing_states(
bool tf)
const;
235 Pointer<Model> model_;
237 bool stop_on_good_score_;
238 Pointer<ScoringFunction> cache_;
244 IMPKERNEL_END_NAMESPACE