Annotation¶
Annotations are additional information associated to an optimization object (e.g., a constraint or a variable).
The Annotation class takes one template arguments which is the value type. For instance, we
can create an annotation of type unsigned int
as follows.
Env env;
const unsigned int default_value = 0;
Annotation<unsigned int> annotation(env, "my_annotation", default_value);
Annotations are global, i.e., they do not relate to a given optimization model and can, therefore, be accessed
anywhere in the code. Thus, given a constraint called constraint
, the value of the annotation can be accessed
by calling the Ctr::get
method.
std::cout << "My annotation is " << constraint.get(annotation) << std::endl; // "0", i.e., the default_value value
Annotations are, in particular, used to give decomposition instructions to idol when designing a Branch-and-Price algorithm. To learn more, check our Branch-and-Price tutorials.
Doxygen¶
-
template<class ValueT = unsigned int>
class Annotation : public idol::impl::Annotation¶ Public Functions
-
inline unsigned int id() const¶
Returns the id of the annotation.
The id is unique within the environment.
- Returns:
The id of the annotation
-
inline const std::string &name() const¶
Returns the given name of the annotation.
- Returns:
The given name of the annotation
-
inline bool has_default() const¶
Returns true if the annotation has a default value, false otherwise.
- Returns:
true if the annotation has a default value, false otherwise
-
void free()¶
Frees the memory kept for the annotation in the environment.
Public Static Functions
-
template<class ...ArgsT>
static inline Annotation<ValueT> make_with_default_value(Env &t_env, std::string t_name, ArgsT&&... t_args)¶
-
inline unsigned int id() const¶