Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <time_limit.h>
Public Member Functions | |
NestedTimeLimit (TimeLimit *base_time_limit, double limit_in_seconds, double deterministic_limit) | |
NestedTimeLimit (const NestedTimeLimit &)=delete | |
This type is neither copyable nor movable. | |
NestedTimeLimit & | operator= (const NestedTimeLimit &)=delete |
~NestedTimeLimit () | |
TimeLimit * | GetTimeLimit () |
Static Public Member Functions | |
template<typename Parameters > | |
static std::unique_ptr< NestedTimeLimit > | FromBaseTimeLimitAndParameters (TimeLimit *time_limit, const Parameters ¶meters) |
Provides a way to nest time limits for algorithms where a certain part of the computation is bounded not just by the overall time limit, but also by a stricter time limit specific just for this particular part.
This class takes a base time limit object (the overall time limit) and the part-specific time limit, and creates a new time limit object for the part. This new time limit object will expire when either the overall time limit expires or when the part-specific time limit expires.
Example usage:
Note that remaining wall time in the base time limit is decreasing "automatically", but the deterministic time needs to be updated manually. This update is done only once, during the destruction of the nested time limit object. To track the deterministic time properly, the user must avoid modifying the base time limit object when a nested time limit exists.
The nested time limits supports the external time limit condition in the sense, that if the overall time limit has an external boolean registered, the nested time limit object will use the same boolean value as an external time limit too.
Definition at line 410 of file time_limit.h.
operations_research::NestedTimeLimit::NestedTimeLimit | ( | TimeLimit * | base_time_limit, |
double | limit_in_seconds, | ||
double | deterministic_limit ) |
Creates the nested time limit. Note that 'base_time_limit' must remain valid for the whole lifetime of the nested time limit object.
Definition at line 50 of file time_limit.cc.
|
delete |
This type is neither copyable nor movable.
operations_research::NestedTimeLimit::~NestedTimeLimit | ( | ) |
Updates elapsed deterministic time in the base time limit object.
Definition at line 63 of file time_limit.cc.
|
inlinestatic |
Creates a time limit object initialized from a base time limit and an object that provides methods max_time_in_seconds() and max_deterministic_time(). This method is designed specifically to work with solver parameter protos, e.g. BopParameters, MipParameters and SatParameters.
Definition at line 436 of file time_limit.h.
|
inline |
Returns a time limit object that represents the combination of the overall time limit and the part-specific time limit. The returned time limit object is owned by the nested time limit object that returns it, and it will remain valid until the nested time limit object is destroyed.
Definition at line 449 of file time_limit.h.
|
delete |