Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <synchronization.h>
Public Member Functions | |
SharedBoundsManager (const CpModelProto &model_proto) | |
void | ReportPotentialNewBounds (const std::string &worker_name, const std::vector< int > &variables, const std::vector< int64_t > &new_lower_bounds, const std::vector< int64_t > &new_upper_bounds) |
void | FixVariablesFromPartialSolution (const std::vector< int64_t > &solution, const std::vector< int > &variables_to_fix) |
int | RegisterNewId () |
void | GetChangedBounds (int id, std::vector< int > *variables, std::vector< int64_t > *new_lower_bounds, std::vector< int64_t > *new_upper_bounds) |
void | UpdateDomains (std::vector< Domain > *domains) |
void | Synchronize () |
void | LogStatistics (SolverLogger *logger) |
int | NumBoundsExported (const std::string &worker_name) |
void | LoadDebugSolution (absl::Span< const int64_t > solution) |
void | set_dump_prefix (absl::string_view dump_prefix) |
Debug only. Set dump prefix for solutions written to file. | |
This class manages a pool of lower and upper bounds on a set of variables in a parallel context.
Definition at line 490 of file synchronization.h.
|
explicit |
Definition at line 828 of file synchronization.cc.
void operations_research::sat::SharedBoundsManager::FixVariablesFromPartialSolution | ( | const std::vector< int64_t > & | solution, |
const std::vector< int > & | variables_to_fix ) |
If we solved a small independent component of the full problem, then we can in most situation fix the solution on this subspace.
Abort if incompatible. Note that we only check the position that we are about to fix. This should be enough. Otherwise we might never accept any solution because the base LNS solution was not the same in some of the variables that we fixed here.
Fix the variables.
This is problematic as we might find a different partial solution. To allow for further investigation, we currently fix it to the debug solution instead.
Definition at line 910 of file synchronization.cc.
void operations_research::sat::SharedBoundsManager::GetChangedBounds | ( | int | id, |
std::vector< int > * | variables, | ||
std::vector< int64_t > * | new_lower_bounds, | ||
std::vector< int64_t > * | new_upper_bounds ) |
When called, returns the set of bounds improvements since the last time this method was called with the same id.
We need to report the bounds in a deterministic order as it is difficult to guarantee that nothing depend on the order in which the new bounds are processed.
Definition at line 986 of file synchronization.cc.
|
inline |
If non-empty, we will check that all bounds update contains this solution.
Definition at line 537 of file synchronization.h.
void operations_research::sat::SharedBoundsManager::LogStatistics | ( | SolverLogger * | logger | ) |
Definition at line 1018 of file synchronization.cc.
int operations_research::sat::SharedBoundsManager::NumBoundsExported | ( | const std::string & | worker_name | ) |
Definition at line 1030 of file synchronization.cc.
int operations_research::sat::SharedBoundsManager::RegisterNewId | ( | ) |
Returns a new id to be used in GetChangedBounds(). This is just an ever increasing sequence starting from zero. Note that the class is not designed to have too many of these.
Definition at line 969 of file synchronization.cc.
void operations_research::sat::SharedBoundsManager::ReportPotentialNewBounds | ( | const std::string & | worker_name, |
const std::vector< int > & | variables, | ||
const std::vector< int64_t > & | new_lower_bounds, | ||
const std::vector< int64_t > & | new_upper_bounds ) |
Reports a set of locally improved variable bounds to the shared bounds manager. The manager will compare these bounds changes against its global state, and incorporate the improving ones.
Definition at line 847 of file synchronization.cc.
|
inline |
Debug only. Set dump prefix for solutions written to file.
Definition at line 542 of file synchronization.h.
void operations_research::sat::SharedBoundsManager::Synchronize | ( | ) |
Publishes any new bounds so that GetChangedBounds() will reflect the latest state.
Definition at line 956 of file synchronization.cc.
void operations_research::sat::SharedBoundsManager::UpdateDomains | ( | std::vector< Domain > * | domains | ) |
This should not be called too often as it lock the class for O(num_variables) time.
Definition at line 1009 of file synchronization.cc.