Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::sat::SharedBoundsManager Class Referenceabstract

#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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SharedBoundsManager()

operations_research::sat::SharedBoundsManager::SharedBoundsManager ( const CpModelProto & model_proto)
explicit

Definition at line 828 of file synchronization.cc.

Member Function Documentation

◆ FixVariablesFromPartialSolution()

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.

Note
because there can be more than one optimal solution on an independent subproblem, it is important to do that in a locked fashion, and reject future incompatible fixing.
Todo
(user): Because we look at the non-synchronized and up to date bounds, this break determinism if two solution for the same subpart comes at the same time.

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.

◆ GetChangedBounds()

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.

◆ LoadDebugSolution()

void operations_research::sat::SharedBoundsManager::LoadDebugSolution ( absl::Span< const int64_t > solution)
inline

If non-empty, we will check that all bounds update contains this solution.

Note
this might fail once we reach optimality and we might have wrong bounds, but if it fail before that it can help find bugs.

Definition at line 537 of file synchronization.h.

◆ LogStatistics()

void operations_research::sat::SharedBoundsManager::LogStatistics ( SolverLogger * logger)

Definition at line 1018 of file synchronization.cc.

◆ NumBoundsExported()

int operations_research::sat::SharedBoundsManager::NumBoundsExported ( const std::string & worker_name)

Definition at line 1030 of file synchronization.cc.

◆ RegisterNewId()

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.

◆ ReportPotentialNewBounds()

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.

◆ set_dump_prefix()

void operations_research::sat::SharedBoundsManager::set_dump_prefix ( absl::string_view dump_prefix)
inline

Debug only. Set dump prefix for solutions written to file.

Definition at line 542 of file synchronization.h.

◆ Synchronize()

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.

◆ UpdateDomains()

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.


The documentation for this class was generated from the following files: