Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <subsolver.h>
Public Types | |
enum | SubsolverType { FULL_PROBLEM , FIRST_SOLUTION , INCOMPLETE , HELPER } |
Public Member Functions | |
SubSolver (absl::string_view name, SubsolverType type) | |
virtual | ~SubSolver ()=default |
virtual void | Synchronize ()=0 |
virtual bool | IsDone () |
virtual bool | TaskIsAvailable ()=0 |
virtual std::function< void()> | GenerateTask (int64_t task_id)=0 |
double | deterministic_time () const |
std::string | name () const |
Returns the name of this SubSolver. Used in logs. | |
SubsolverType | type () const |
Returns the type of the subsolver. | |
void | AddTaskDuration (double duration_in_seconds) |
void | AddTaskDeterministicDuration (double deterministic_duration) |
std::string | TimingInfo () const |
std::string | DeterministicTimingInfo () const |
The API used for distributing work. Each subsolver can generate tasks and synchronize itself with the rest of the world.
Definition at line 45 of file subsolver.h.
Enumerator | |
---|---|
FULL_PROBLEM | |
FIRST_SOLUTION | |
INCOMPLETE | |
HELPER |
Definition at line 47 of file subsolver.h.
|
inline |
Definition at line 49 of file subsolver.h.
|
virtualdefault |
|
inline |
This one need to be called by the Subclasses. Usually from Synchronize(), or from the task itself it we execute a single task at the same time.
Definition at line 109 of file subsolver.h.
|
inline |
Definition at line 103 of file subsolver.h.
|
inline |
Returns the total deterministic time spend by the completed tasks before the last Synchronize() call.
Definition at line 93 of file subsolver.h.
|
inline |
Definition at line 123 of file subsolver.h.
|
pure virtual |
Returns a task to run. The task_id is just an ever increasing counter that correspond to the number of total calls to GenerateTask().
This is only called by the main thread.
Implemented in operations_research::sat::FeasibilityJumpSolver, operations_research::sat::NeighborhoodGeneratorHelper, operations_research::sat::ObjectiveShavingSolver, operations_research::sat::SynchronizationPoint, and operations_research::sat::VariablesShavingSolver.
|
inlinevirtual |
Returns true if this SubSolver is done and its memory can be freed. Note that the *Loop(subsolvers) functions below takes a reference in order to be able to clear the memory of a SubSolver as soon as it is done. Once this is true, the subsolver in question will be deleted and never used again.
This is needed since some subsolve can be done before the overal Solve() is finished. This is the case for first solution subsolvers for instances.
This is only called by the main thread in a sequential fashion. Important: This is only called when there is currently no task from that SubSolver in flight.
Reimplemented in operations_research::sat::FeasibilityJumpSolver.
Definition at line 75 of file subsolver.h.
|
inline |
Returns the name of this SubSolver. Used in logs.
Definition at line 96 of file subsolver.h.
|
pure virtual |
Synchronizes with the external world from this SubSolver point of view. Also incorporate the results of the latest completed tasks if any.
Note(user): The intended implementation for determinism is that tasks update asynchronously (and so non-deterministically) global "shared" classes, but this global state is incorporated by the Subsolver only when Synchronize() is called.
This is only called by the main thread in Subsolver creation order.
Implemented in operations_research::sat::FeasibilityJumpSolver, operations_research::sat::NeighborhoodGeneratorHelper, operations_research::sat::ObjectiveShavingSolver, operations_research::sat::SynchronizationPoint, and operations_research::sat::VariablesShavingSolver.
|
pure virtual |
Returns true iff GenerateTask() can be called. This is only called by the main thread in a sequential fashion.
Implemented in operations_research::sat::FeasibilityJumpSolver, operations_research::sat::NeighborhoodGeneratorHelper, operations_research::sat::ObjectiveShavingSolver, operations_research::sat::SynchronizationPoint, and operations_research::sat::VariablesShavingSolver.
|
inline |
Definition at line 115 of file subsolver.h.
|
inline |
Returns the type of the subsolver.
Definition at line 99 of file subsolver.h.