8 #ifndef IMPKERNEL_OPTIMIZER_H
9 #define IMPKERNEL_OPTIMIZER_H
11 #include <IMP/kernel_config.h>
23 #include <cereal/access.hpp>
24 #include <cereal/types/base_class.hpp>
26 IMPKERNEL_BEGIN_NAMESPACE
49 bool stop_on_good_score_;
52 friend class cereal::access;
54 template<
class Archive>
void serialize(Archive &ar) {
55 ar(cereal::base_class<ModelObject>(
this), stop_on_good_score_,
56 scoring_function_, mutable_access_optimizer_states());
57 if (std::is_base_of<cereal::detail::InputArchiveBase, Archive>::value) {
58 for (
auto &obj : mutable_access_optimizer_states()) {
59 set_optimizer_state_optimizer(obj,
this);
68 void set_is_optimizing_states(
bool tf)
const;
72 return get_optimizer_state_inputs();
94 double optimize(
unsigned int max_steps);
99 bool get_stop_on_good_score()
const {
return stop_on_good_score_; }
107 if (scoring_function_) {
108 return scoring_function_;
110 IMP_THROW(
"No scoring function was set. "
111 "Use Optimizer::set_scoring_function() to set one.",
125 set_optimizer_state_optimizer(obj,
this);
127 { Optimizer::set_optimizer_state_optimizer(obj,
nullptr); });
138 virtual double do_optimize(
unsigned int ns) = 0;
142 void update_states()
const;
147 IMPKERNEL_END_NAMESPACE
Storage of a model, its restraints, constraints and particles.
A more IMP-like version of the std::vector.
A smart pointer to a reference counted object.
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Class for storing model, its restraints, constraints, and particles.
Base class for objects in a Model that depend on other objects.
Base class for all optimizers.
virtual ModelObjectsTemp do_get_outputs() const override
don't return anything here to avoid pointless dependencies
A class for storing lists of IMP items.
Various general useful functions for IMP.
Base class for objects in a Model that depend on other objects.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
A nullptr-initialized pointer to an IMP Object.
Represents a scoring function on the model.
A shared base class to help in debugging and things.
Shared optimizer state that is invoked upon commitment of new coordinates.
#define IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR(Name)
virtual ModelObjectsTemp do_get_inputs() const override
void set_stop_on_good_score(bool tf)
double get_last_score() const
Return the score found in the last evaluate.
An exception for an invalid value being passed to IMP.
ScoringFunction * get_scoring_function() const
Return the scoring function that is being used.