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

#include <constraint_solveri.h>

Classes

class  Variable
 

Public Member Functions

 DEFINE_STRONG_INT_TYPE (VariableDomainId, int)
 
 DEFINE_STRONG_INT_TYPE (ConstraintId, int)
 
VariableDomainId AddVariableDomain (int64_t relaxed_min, int64_t relaxed_max)
 Adds a variable domain to this state, returns a handler to the new domain.
 
void RelaxVariableDomain (VariableDomainId domain_id)
 
bool TightenVariableDomainMin (VariableDomainId domain_id, int64_t value)
 
bool TightenVariableDomainMax (VariableDomainId domain_id, int64_t value)
 
int64_t VariableDomainMin (VariableDomainId domain_id) const
 
int64_t VariableDomainMax (VariableDomainId domain_id) const
 
void ChangeRelaxedVariableDomain (VariableDomainId domain_id, int64_t min, int64_t max)
 
void PropagateRelax (VariableDomainId domain_id)
 Propagation of all events.
 
bool PropagateTighten (VariableDomainId domain_id)
 
Variable MakeVariable (VariableDomainId domain_id)
 
void Commit ()
 
void Revert ()
 
bool StateIsFeasible () const
 
void AddWeightedSumConstraint (const std::vector< VariableDomainId > &input_domain_ids, const std::vector< int64_t > &input_weights, int64_t input_offset, VariableDomainId output_domain_id)
 Adds a constraint that output = input_offset + sum_i weight_i * input_i.
 
void CompileConstraints ()
 

Detailed Description

A LocalSearchState is a container for variables with domains that can be relaxed and tightened, saved and restored. It represents the solution state of a local search engine, and allows it to go from solution to solution by relaxing some variables to form a new subproblem, then tightening those variables to move to a new solution representation. That state may be saved to an internal copy, or reverted to the last saved internal copy. Relaxing a variable returns its bounds to their initial state. Tightening a variable's bounds may make its min larger than its max, in that case, the tightening function will return false, and the state will be marked as invalid. No other operations than Revert() can be called on an invalid state: in particular, an invalid state cannot be saved.

Definition at line 1808 of file constraint_solveri.h.

Member Function Documentation

◆ AddVariableDomain()

VariableDomainId operations_research::LocalSearchState::AddVariableDomain ( int64_t relaxed_min,
int64_t relaxed_max )

Adds a variable domain to this state, returns a handler to the new domain.

Definition at line 3868 of file local_search.cc.

◆ AddWeightedSumConstraint()

void operations_research::LocalSearchState::AddWeightedSumConstraint ( const std::vector< VariableDomainId > & input_domain_ids,
const std::vector< int64_t > & input_weights,
int64_t input_offset,
VariableDomainId output_domain_id )

Adds a constraint that output = input_offset + sum_i weight_i * input_i.

Store domain/constraint dependencies.

Store constraint.

Definition at line 4045 of file local_search.cc.

◆ ChangeRelaxedVariableDomain()

void operations_research::LocalSearchState::ChangeRelaxedVariableDomain ( VariableDomainId domain_id,
int64_t min,
int64_t max )

Definition at line 3935 of file local_search.cc.

◆ Commit()

void operations_research::LocalSearchState::Commit ( )
Todo
(user): When the class has more users, find a threshold ratio of saved/total domains under which a sparse clear would be more efficient for both Commit() and Revert().

Clear domains trail.

Clear constraint trail.

Definition at line 3955 of file local_search.cc.

◆ CompileConstraints()

void operations_research::LocalSearchState::CompileConstraints ( )

Precomputes which domain change triggers which constraint(s). Should be run after adding all constraints, before any Relax()/Tighten().

Definition at line 4071 of file local_search.cc.

◆ DEFINE_STRONG_INT_TYPE() [1/2]

operations_research::LocalSearchState::DEFINE_STRONG_INT_TYPE ( ConstraintId ,
int  )

◆ DEFINE_STRONG_INT_TYPE() [2/2]

operations_research::LocalSearchState::DEFINE_STRONG_INT_TYPE ( VariableDomainId ,
int  )

◆ MakeVariable()

LocalSearchState::Variable operations_research::LocalSearchState::MakeVariable ( VariableDomainId domain_id)

Makes a variable, an object with restricted operations on the underlying domain identified by domain_id: only Relax, Tighten and Min/Max read operations are available.

Definition at line 3878 of file local_search.cc.

◆ PropagateRelax()

void operations_research::LocalSearchState::PropagateRelax ( VariableDomainId domain_id)

Propagation of all events.

Definition at line 4246 of file local_search.cc.

◆ PropagateTighten()

bool operations_research::LocalSearchState::PropagateTighten ( VariableDomainId domain_id)

Definition at line 4256 of file local_search.cc.

◆ RelaxVariableDomain()

void operations_research::LocalSearchState::RelaxVariableDomain ( VariableDomainId domain_id)

Definition at line 3883 of file local_search.cc.

◆ Revert()

void operations_research::LocalSearchState::Revert ( )

Revert trailed domains.

Revert trailed constraints.

Definition at line 3968 of file local_search.cc.

◆ StateIsFeasible()

bool operations_research::LocalSearchState::StateIsFeasible ( ) const
inline

Definition at line 1832 of file constraint_solveri.h.

◆ TightenVariableDomainMax()

bool operations_research::LocalSearchState::TightenVariableDomainMax ( VariableDomainId domain_id,
int64_t value )

Definition at line 3923 of file local_search.cc.

◆ TightenVariableDomainMin()

bool operations_research::LocalSearchState::TightenVariableDomainMin ( VariableDomainId domain_id,
int64_t value )

Definition at line 3911 of file local_search.cc.

◆ VariableDomainMax()

int64_t operations_research::LocalSearchState::VariableDomainMax ( VariableDomainId domain_id) const

Definition at line 3906 of file local_search.cc.

◆ VariableDomainMin()

int64_t operations_research::LocalSearchState::VariableDomainMin ( VariableDomainId domain_id) const

Definition at line 3901 of file local_search.cc.


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