Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <bop_portfolio.h>
Public Member Functions | |
OptimizerSelector (const util_intops::StrongVector< OptimizerIndex, BopOptimizerBase * > &optimizers) | |
OptimizerIndex | SelectOptimizer () |
void | UpdateScore (int64_t gain, double time_spent) |
void | TemporarilyMarkOptimizerAsUnselectable (OptimizerIndex optimizer_index) |
void | SetOptimizerRunnability (OptimizerIndex optimizer_index, bool runnable) |
std::string | PrintStats (OptimizerIndex optimizer_index) const |
Returns statistics about the given optimizer. | |
int | NumCallsForOptimizer (OptimizerIndex optimizer_index) const |
void | DebugPrint () const |
Prints some debug information. Should not be used in production. | |
This class is providing an adaptative selector for optimizers based on their past successes and deterministic time spent.
Definition at line 108 of file bop_portfolio.h.
|
explicit |
Definition at line 359 of file bop_portfolio.cc.
void operations_research::bop::OptimizerSelector::DebugPrint | ( | ) | const |
Prints some debug information. Should not be used in production.
Definition at line 461 of file bop_portfolio.cc.
int operations_research::bop::OptimizerSelector::NumCallsForOptimizer | ( | OptimizerIndex | optimizer_index | ) | const |
Definition at line 455 of file bop_portfolio.cc.
std::string operations_research::bop::OptimizerSelector::PrintStats | ( | OptimizerIndex | optimizer_index | ) | const |
Returns statistics about the given optimizer.
Definition at line 444 of file bop_portfolio.cc.
OptimizerIndex operations_research::bop::OptimizerSelector::SelectOptimizer | ( | ) |
Selects the next optimizer to run based on the user defined order and history of success. Returns kInvalidOptimizerIndex if no optimizer is selectable and runnable (see the functions below).
The optimizer is selected using the following algorithm (L being the sorted list of optimizers, and l the position of the last selected optimizer): a- If a new solution has been found by optimizer l, select the first optimizer l' in L, l' >= 0, that can run. b- If optimizer l didn't find a new solution, select the first optimizer l', with l' > l, such that its deterministic time spent since last solution is smaller than the deterministic time spent by any runnable optimizer in 1..l since last solution. If no such optimizer is available, go to option a.
Select the first possible optimizer.
Select the next possible optimizer. If none, select the first one. Check that the time is smaller than all previous optimizers which are runnable.
Select the optimizer.
Definition at line 369 of file bop_portfolio.cc.
void operations_research::bop::OptimizerSelector::SetOptimizerRunnability | ( | OptimizerIndex | optimizer_index, |
bool | runnable ) |
Sets whether or not an optimizer is "runnable". Like a non-selectable one, a non-runnable optimizer will never be returned by SelectOptimizer().
Definition at line 439 of file bop_portfolio.cc.
void operations_research::bop::OptimizerSelector::TemporarilyMarkOptimizerAsUnselectable | ( | OptimizerIndex | optimizer_index | ) |
Marks the given optimizer as not selectable until UpdateScore() is called with a positive gain. In which case, all optimizer will become selectable again.
Definition at line 434 of file bop_portfolio.cc.
void operations_research::bop::OptimizerSelector::UpdateScore | ( | int64_t | gain, |
double | time_spent ) |
Updates the internal metrics to decide which optimizer to select. This method should be called each time the selected optimizer is run.
The gain corresponds to the reward to assign to the solver; It could for instance be the difference in cost between the last and the current solution.
The time spent corresponds to the time the optimizer spent; To make the behavior deterministic, it is recommended to use the deterministic time instead of the elapsed time.
The optimizers are sorted based on their score each time a new solution is found.
Definition at line 414 of file bop_portfolio.cc.