![]() |
Google OR-Tools v9.12
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, absl::Span< const int > variables, absl::Span< const int64_t > new_lower_bounds, absl::Span< const int64_t > new_upper_bounds) |
void | FixVariablesFromPartialSolution (absl::Span< const int64_t > solution, absl::Span< const 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 (absl::string_view 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 523 of file synchronization.h.
|
explicit |
Fill symmetry data.
Get orbits in term of IntegerVariable.
Fill orbits_.
Fill representative.
Definition at line 832 of file synchronization.cc.
void operations_research::sat::SharedBoundsManager::FixVariablesFromPartialSolution | ( | absl::Span< const int64_t > | solution, |
absl::Span< const 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.
This function shouldn't be called if we has symmetry.
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 970 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.
Now that the mutex is released, we can add all symmetric version if any.
Definition at line 1050 of file synchronization.cc.
|
inline |
If non-empty, we will check that all bounds update contains this solution.
Definition at line 572 of file synchronization.h.
void operations_research::sat::SharedBoundsManager::LogStatistics | ( | SolverLogger * | logger | ) |
Definition at line 1109 of file synchronization.cc.
int operations_research::sat::SharedBoundsManager::NumBoundsExported | ( | absl::string_view | worker_name | ) |
Definition at line 1123 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 1032 of file synchronization.cc.
void operations_research::sat::SharedBoundsManager::ReportPotentialNewBounds | ( | const std::string & | worker_name, |
absl::Span< const int > | variables, | ||
absl::Span< const int64_t > | new_lower_bounds, | ||
absl::Span< const 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.
In the presence of symmetry we only update the representative.
We count -1 so that num_improvements + num_symmetric_improvements corresponds to the number of actual bound improvement.
Definition at line 890 of file synchronization.cc.
|
inline |
Debug only. Set dump prefix for solutions written to file.
Definition at line 577 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 1018 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 1100 of file synchronization.cc.