idol
A C++ Framework for Optimization
|
#include <BranchAndBound.h>
Public Types | |
template<class ReturnT , class T > | |
using | only_if_has_Strategy = typename std::pair< typename T::template Strategy< NodeT >, ReturnT >::second_type |
Public Member Functions | |
BranchAndBound ()=default | |
BranchAndBound (const BranchAndBound &t_rhs) | |
BranchAndBound< NodeT > & | with_node_optimizer (const OptimizerFactory &t_node_optimizer) |
void | set_node_optimizer (const OptimizerFactory &t_node_optimizer) |
BranchAndBound< NodeT > & | operator+= (const OptimizerFactory &t_node_optimizer) |
BranchAndBound< NodeT > & | with_branching_rule (const BranchingRuleFactory< NodeT > &t_branching_rule) |
template<class BranchingRuleFactoryT > | |
only_if_has_Strategy< BranchAndBound< NodeT > &, BranchingRuleFactoryT > | with_branching_rule (const BranchingRuleFactoryT &t_branching_rule) |
BranchAndBound< NodeT > & | with_node_selection_rule (const NodeSelectionRuleFactory< NodeT > &t_node_selection) |
template<class NodeSelectionRuleFactoryT > | |
only_if_has_Strategy< BranchAndBound< NodeT > &, NodeSelectionRuleFactoryT > | with_node_selection_rule (const NodeSelectionRuleFactoryT &t_node_selection_rule) |
BranchAndBound (BranchAndBound &&) noexcept=default | |
BranchAndBound & | operator= (const BranchAndBound &)=delete |
BranchAndBound & | operator= (BranchAndBound &&) noexcept=delete |
Optimizer * | operator() (const Model &t_model) const override |
OptimizerFactory * | clone () const override |
BranchAndBound< NodeT > & | with_subtree_depth (unsigned int t_depth) |
BranchAndBound< NodeT > & | with_logger (const Logs::BranchAndBound::Factory< NodeT > &t_log_factory) |
BranchAndBound< NodeT > & | add_callback (const BranchAndBoundCallbackFactory< NodeT > &t_callback) |
BranchAndBound< NodeT > & | add_callback (const CallbackFactory &t_callback) |
template<class NodeSelectionRuleFactoryT > | |
idol::BranchAndBound< NodeT >::template only_if_has_Strategy< idol::BranchAndBound< NodeT > &, NodeSelectionRuleFactoryT > | with_node_selection_rule (const NodeSelectionRuleFactoryT &t_node_selection_rule) |
template<class BranchingRuleFactoryT > | |
idol::BranchAndBound< NodeT >::template only_if_has_Strategy< idol::BranchAndBound< NodeT > &, BranchingRuleFactoryT > | with_branching_rule (const BranchingRuleFactoryT &t_branching_rule) |
CRTP & | with_logs (bool t_value) |
CRTP & | with_time_limit (double t_time_limit) |
CRTP & | with_thread_limit (unsigned int t_max_n_threads) |
CRTP & | with_iteration_limit (unsigned int t_iteration_count_limit) |
CRTP & | with_best_bound_stop (double t_best_bound_stop) |
CRTP & | with_best_obj_stop (double t_user_best_obj) |
CRTP & | with_relative_gap_tolerance (double t_relative_gap_tolerance) |
CRTP & | with_absolute_gap_tolerance (double t_absolute_gap_tolerance) |
CRTP & | with_presolve (bool t_value) |
CRTP & | with_infeasible_or_unbounded_info (bool t_value) |
CRTP & | conditional (bool t_conditional_value, const std::function< void(CRTP &)> &t_if) |
CRTP & | conditional (bool t_conditional_value, const std::function< void(CRTP &)> &t_if, const std::function< void(CRTP &)> &t_else) |
template<class T > | |
T & | as () |
template<class T > | |
const T & | as () const |
template<class T > | |
bool | is () const |
Protected Member Functions | |
CRTP & | crtp () |
const CRTP & | crtp () const |
void | handle_default_parameters (Optimizer *t_optimizer) const |
NodeT | the class used to store nodes information. It is strongly advised to inherit from NodeVarInfo in order to create your own node type. |
Definition at line 29 of file BranchAndBound.h.
using idol::BranchAndBound< NodeT >::only_if_has_Strategy = typename std::pair<typename T::template Strategy<NodeT>, ReturnT>::second_type |
This type is used to exploit SFINAE in order to identify classes having a sub-class named Strategy<NodeInfoT>
. This is used to make calls like .with_node_selection_rule(DepthFirst());
which will actually call .with_node_selection_rule(DepthFirst::Strategy<NodeInfoT>())
.
Definition at line 46 of file BranchAndBound.h.
|
default |
Creates a new branch-and-bound algorithm.
Example:
idol::BranchAndBound< NodeT >::BranchAndBound | ( | const BranchAndBound< NodeT > & | t_rhs | ) |
Copy constructor
t_rhs | the object to copy |
Definition at line 310 of file BranchAndBound.h.
idol::BranchAndBound< NodeT > & idol::BranchAndBound< NodeT >::add_callback | ( | const BranchAndBoundCallbackFactory< NodeT > & | t_callback | ) |
Adds a callback which will be called by the optimizer.
Note that this method can be called multiple times so that multiple callbacks can be added.
t_callback | the callback factory |
Definition at line 239 of file BranchAndBound.h.
idol::BranchAndBound< NodeT > & idol::BranchAndBound< NodeT >::add_callback | ( | const CallbackFactory & | t_callback | ) |
Adds a (solver independent) callback which will be called by the optimizer.
Note that this method can be called multiple times so that multiple callbacks can be added.
Here, the Callback
is automatically converted into a BranchAndBoundCallback<NodeInfoT>
.
t_callback | the callback factory |
Definition at line 234 of file BranchAndBound.h.
|
inlineinherited |
Definition at line 44 of file OptimizerFactory.h.
|
inlineinherited |
Definition at line 52 of file OptimizerFactory.h.
|
overridevirtual |
Creates and return a copy of the optimizer factory. This is used for polymorphism.
Implements idol::OptimizerFactory.
Definition at line 366 of file BranchAndBound.h.
|
inherited |
Executes the lambda function given as second parameter if and only if its first argument is true. This function can be used to build different optimizer factories depending on some external variable.
Example:
t_conditional_value | if true, the t_if lambda function is executed, if false, nothing happens. |
t_if | lambda function to execute in case t_conditional_value is true |
Definition at line 273 of file OptimizerFactory.h.
|
inherited |
Executes the lambda function given as second parameter if and only if its first argument is true. This function can be used to build different optimizer factories depending on some external variable.
Example:
t_conditional_value | if true, the t_if lambda function is executed, if false, the t_else lambda function is. |
t_if | lambda function to execute in case t_conditional_value is true |
t_else | lambda function to execute in case t_conditional_value is false |
Definition at line 266 of file OptimizerFactory.h.
|
inlineprotectedinherited |
Definition at line 78 of file OptimizerFactory.h.
|
inlineprotectedinherited |
Definition at line 79 of file OptimizerFactory.h.
|
protectedinherited |
Definition at line 398 of file OptimizerFactory.h.
|
inlineinherited |
Definition at line 60 of file OptimizerFactory.h.
|
overridevirtual |
Creates and returns a new optimizer to solve the model given as parameter.
t_model | The model which the optimizer will solve |
Implements idol::OptimizerFactory.
Definition at line 326 of file BranchAndBound.h.
idol::BranchAndBound< NodeT > & idol::BranchAndBound< NodeT >::operator+= | ( | const OptimizerFactory & | t_node_optimizer | ) |
Definition at line 228 of file BranchAndBound.h.
void idol::BranchAndBound< NodeT >::set_node_optimizer | ( | const OptimizerFactory & | t_node_optimizer | ) |
Definition at line 210 of file BranchAndBound.h.
|
inherited |
Sets the absolute gap tolerance for the optimizer. When the optimizer proves that the absolute optimality gap is less than this threshold, the optimizer stops.
Example:
t_absolute_gap_tolerance | the absolute gap tolerance |
Definition at line 302 of file OptimizerFactory.h.
|
inherited |
Sets a threshold on the best bound for stopping the optimizer. When the optimizer have found a best bound which is greater than this threshold, the optimizer stops.
Example:
t_best_bound_stop | the threshold |
Definition at line 338 of file OptimizerFactory.h.
|
inherited |
Sets a threshold on the best objective value for stopping the optimizer. When the optimizer have found a best objective value which is less than this threshold, the optimizer stops.
Example:
t_user_best_obj | the threshold |
Definition at line 326 of file OptimizerFactory.h.
idol::BranchAndBound< NodeT > & idol::BranchAndBound< NodeT >::with_branching_rule | ( | const BranchingRuleFactory< NodeT > & | t_branching_rule | ) |
Sets the branching rule used to create child nodes
Example:
t_branching_rule | the branching rule |
Definition at line 286 of file BranchAndBound.h.
only_if_has_Strategy< BranchAndBound< NodeT > &, BranchingRuleFactoryT > idol::BranchAndBound< NodeT >::with_branching_rule | ( | const BranchingRuleFactoryT & | t_branching_rule | ) |
Sets the branching rule used to create child nodes.
Here, the function is called only when BranchingRuleFactoryT
has a nested template class named Strategy<NodeInfoT>
. In such a case, the branching rule is created by calling BranchingRuleFactoryT::Strategy<NodeInfoT>(t_branching_rule)
. This is used to avoid the user repeating the node type NodeInfoT
being used.
Example:
BranchingRuleFactoryT | the class containing a nested template class named Strategy |
t_branching_rule | the branching rule |
idol::BranchAndBound< NodeT >::template only_if_has_Strategy< idol::BranchAndBound< NodeT > &, BranchingRuleFactoryT > idol::BranchAndBound< NodeT >::with_branching_rule | ( | const BranchingRuleFactoryT & | t_branching_rule | ) |
Definition at line 281 of file BranchAndBound.h.
|
inherited |
Sets the behaviour of the optimizer when a model is shown to be infeasible or unbounded. When set to true, the optimizer is forced to prove feasibility or unboundedness by providing a certificate.
Example:
t_value | the activation level |
Definition at line 278 of file OptimizerFactory.h.
|
inherited |
Sets the maximum number of iterations which the optimizer go through
Example:
t_iteration_count_limit | the maximum number of iterations |
Definition at line 350 of file OptimizerFactory.h.
idol::BranchAndBound< NodeT > & idol::BranchAndBound< NodeT >::with_logger | ( | const Logs::BranchAndBound< NodeT >::Factory< NodeT > & | t_log_factory | ) |
Definition at line 216 of file BranchAndBound.h.
|
inherited |
Sets the log_master level and color for the optimizer
Example:
t_log_level | the log_master level |
t_log_color | the output color |
Definition at line 386 of file OptimizerFactory.h.
idol::BranchAndBound< NodeT > & idol::BranchAndBound< NodeT >::with_node_optimizer | ( | const OptimizerFactory & | t_node_optimizer | ) |
Sets the optimizer for solving each of the branch-and-bound tree nodes
Example:
t_node_optimizer | the optimizer factory the node problems |
Definition at line 298 of file BranchAndBound.h.
idol::BranchAndBound< NodeT > & idol::BranchAndBound< NodeT >::with_node_selection_rule | ( | const NodeSelectionRuleFactory< NodeT > & | t_node_selection | ) |
Sets the node selection rule to explore the branch and bound tree.
t_node_selection | the node selection rule |
Definition at line 267 of file BranchAndBound.h.
only_if_has_Strategy< BranchAndBound< NodeT > &, NodeSelectionRuleFactoryT > idol::BranchAndBound< NodeT >::with_node_selection_rule | ( | const NodeSelectionRuleFactoryT & | t_node_selection_rule | ) |
Sets the node selection rule to explore the branch and bound tree.
Here, the function is called only when NodeSelectionRuleFactoryT
has a nested template class named Strategy<NodeInfoT>
. In such a case, the node selection rule is created by calling NodeSelectionRuleFactoryT::Strategy<NodeInfoT>(t_node_selection_rule)
. This is used to avoid the user repeating the node type NodeInfoT
being used.
Example:
NodeSelectionRuleFactoryT | the class containing a nested template class named Strategy |
t_node_selection_rule | the node selection rule |
idol::BranchAndBound< NodeT >::template only_if_has_Strategy< idol::BranchAndBound< NodeT > &, NodeSelectionRuleFactoryT > idol::BranchAndBound< NodeT >::with_node_selection_rule | ( | const NodeSelectionRuleFactoryT & | t_node_selection_rule | ) |
Definition at line 261 of file BranchAndBound.h.
|
inherited |
Sets the get_param_presolve activation for the optimizer.
Example:
t_value | the activation level for the optimizer's get_param_presolve (0 for disabling, 1 for enabling) |
Definition at line 290 of file OptimizerFactory.h.
|
inherited |
Sets the relative gap tolerance for the optimizer. When the optimizer proves that the relative optimality gap is less than this threshold, the optimizer stops.
Example:
t_relative_gap_tolerance | the relative gap tolerance |
Definition at line 314 of file OptimizerFactory.h.
idol::BranchAndBound< NodeT > & idol::BranchAndBound< NodeT >::with_subtree_depth | ( | unsigned int | t_depth | ) |
Sets the depth for sub-tree exploration.
When a node is selected for branching, each of its children is explored. This exploration takes the form of a sub-tree exploration. When this parameter is set to 0, only the root node of this sub-tree is solved. Thus every child node are solved and the branch-and-bound algorithm is continued.
For strictly greater values of this parameter, the sub-tree is explored with a maximum depth equal to the value of this parameter.
For example, with a value of 1, each child node is solved along with its child nodes.
Example:
t_depth | the maximum sub-tree exploration depth |
Definition at line 247 of file BranchAndBound.h.
|
inherited |
Sets the maximum number of threads which the optimizer can use
Example:
t_max_n_threads | the number of threads which can be used |
Definition at line 362 of file OptimizerFactory.h.
|
inherited |
Sets the time limit for the optimizer
Example:
t_time_limit | the time limit (in seconds) |
Definition at line 374 of file OptimizerFactory.h.