OR-Tools  8.2
PresolveContext

Detailed Description

Definition at line 68 of file presolve_context.h.

Public Member Functions

 PresolveContext (bool log_info, Model *model, CpModelProto *cp_model, CpModelProto *mapping)
 
int NewIntVar (const Domain &domain)
 
int NewBoolVar ()
 
int GetOrCreateConstantVar (int64 cst)
 
void AddImplication (int a, int b)
 
void AddImplyInDomain (int b, int x, const Domain &domain)
 
bool DomainIsEmpty (int ref) const
 
bool IsFixed (int ref) const
 
bool CanBeUsedAsLiteral (int ref) const
 
bool LiteralIsTrue (int lit) const
 
bool LiteralIsFalse (int lit) const
 
int64 MinOf (int ref) const
 
int64 MaxOf (int ref) const
 
bool DomainContains (int ref, int64 value) const
 
Domain DomainOf (int ref) const
 
int64 MinOf (const LinearExpressionProto &expr) const
 
int64 MaxOf (const LinearExpressionProto &expr) const
 
bool DomainOfVarIsIncludedIn (int var, const Domain &domain)
 
bool VariableIsUniqueAndRemovable (int ref) const
 
bool VariableIsNotUsedAnymore (int ref) const
 
void MarkVariableAsRemoved (int ref)
 
bool VariableWasRemoved (int ref) const
 
bool VariableWithCostIsUniqueAndRemovable (int ref) const
 
bool VariableIsOnlyUsedInEncoding (int ref) const
 
ABSL_MUST_USE_RESULT bool IntersectDomainWith (int ref, const Domain &domain, bool *domain_modified=nullptr)
 
ABSL_MUST_USE_RESULT bool SetLiteralToFalse (int lit)
 
ABSL_MUST_USE_RESULT bool SetLiteralToTrue (int lit)
 
ABSL_MUST_USE_RESULT bool NotifyThatModelIsUnsat (const std::string &message="")
 
bool ModelIsUnsat () const
 
void UpdateRuleStats (const std::string &name, int num_times=1)
 
void UpdateConstraintVariableUsage (int c)
 
bool ConstraintVariableGraphIsUpToDate () const
 
void UpdateNewConstraintsVariableUsage ()
 
bool ConstraintVariableUsageIsConsistent ()
 
void ExploitFixedDomain (int var)
 
bool StoreAffineRelation (int ref_x, int ref_y, int64 coeff, int64 offset)
 
void StoreBooleanEqualityRelation (int ref_a, int ref_b)
 
bool StoreAbsRelation (int target_ref, int ref)
 
bool GetAbsRelation (int target_ref, int *ref)
 
int GetLiteralRepresentative (int ref) const
 
int GetVariableRepresentative (int ref) const
 
int NumAffineRelations () const
 
int NumEquivRelations () const
 
AffineRelation::Relation GetAffineRelation (int ref) const
 
std::string RefDebugString (int ref) const
 
std::string AffineRelationDebugString (int ref) const
 
bool PropagateAffineRelation (int ref)
 
void InitializeNewDomains ()
 
void ClearStats ()
 
void InsertVarValueEncoding (int literal, int ref, int64 value)
 
int GetOrCreateVarValueEncoding (int ref, int64 value)
 
void CanonicalizeDomainOfSizeTwo (int var)
 
bool HasVarValueEncoding (int ref, int64 value, int *literal=nullptr)
 
bool StoreLiteralImpliesVarEqValue (int literal, int var, int64 value)
 
bool StoreLiteralImpliesVarNEqValue (int literal, int var, int64 value)
 
void ReadObjectiveFromProto ()
 
ABSL_MUST_USE_RESULT bool CanonicalizeObjective ()
 
void WriteObjectiveToProto () const
 
bool SubstituteVariableInObjective (int var_in_equality, int64 coeff_in_equality, const ConstraintProto &equality, std::vector< int > *new_vars_in_objective=nullptr)
 
const DomainObjectiveDomain () const
 
const absl::flat_hash_map< int, int64 > & ObjectiveMap () const
 
bool ObjectiveDomainIsConstraining () const
 
void RemoveVariableFromAffineRelation (int var)
 
void RemoveAllVariablesFromAffineRelationConstraint ()
 
const std::vector< int > & ConstraintToVars (int c) const
 
const absl::flat_hash_set< int > & VarToConstraints (int var) const
 
int IntervalUsage (int c) const
 
void RegisterVariablesUsedInAssumptions ()
 
int GetOrCreateReifiedPrecedenceLiteral (int time_i, int time_j, int active_i, int active_j)
 
void ClearPrecedenceCache ()
 
bool log_info () const
 
const SatParameters & params () const
 
TimeLimittime_limit ()
 
ModelRandomGeneratorrandom ()
 

Public Attributes

std::vector< absl::flat_hash_set< int > > var_to_ub_only_constraints
 
std::vector< absl::flat_hash_set< int > > var_to_lb_only_constraints
 
CpModelProto * working_model = nullptr
 
CpModelProto * mapping_model = nullptr
 
bool keep_all_feasible_solutions = false
 
bool enable_stats = true
 
absl::flat_hash_map< std::string, int > stats_by_rule_name
 
int64 num_presolve_operations = 0
 
std::vector< int > tmp_literals
 
std::vector< Domaintmp_term_domains
 
std::vector< Domaintmp_left_domains
 
absl::flat_hash_set< int > tmp_literal_set
 
SparseBitset< int64modified_domains
 
DomainDeductions deductions
 

Constructor & Destructor Documentation

◆ PresolveContext()

PresolveContext ( bool  log_info,
Model model,
CpModelProto *  cp_model,
CpModelProto *  mapping 
)
inlineexplicit

Definition at line 70 of file presolve_context.h.

Member Function Documentation

◆ AddImplication()

void AddImplication ( int  a,
int  b 
)

Definition at line 55 of file presolve_context.cc.

◆ AddImplyInDomain()

void AddImplyInDomain ( int  b,
int  x,
const Domain domain 
)

Definition at line 62 of file presolve_context.cc.

◆ AffineRelationDebugString()

std::string AffineRelationDebugString ( int  ref) const

Definition at line 760 of file presolve_context.cc.

◆ CanBeUsedAsLiteral()

bool CanBeUsedAsLiteral ( int  ref) const

Definition at line 84 of file presolve_context.cc.

◆ CanonicalizeDomainOfSizeTwo()

void CanonicalizeDomainOfSizeTwo ( int  var)

Definition at line 865 of file presolve_context.cc.

◆ CanonicalizeObjective()

bool CanonicalizeObjective ( )

Definition at line 1180 of file presolve_context.cc.

◆ ClearPrecedenceCache()

void ClearPrecedenceCache ( )

Definition at line 1466 of file presolve_context.cc.

◆ ClearStats()

void ClearStats ( )

Definition at line 32 of file presolve_context.cc.

◆ ConstraintToVars()

const std::vector< int > & ConstraintToVars ( int  c) const
inline

Definition at line 324 of file presolve_context.h.

◆ ConstraintVariableGraphIsUpToDate()

bool ConstraintVariableGraphIsUpToDate ( ) const

Definition at line 352 of file presolve_context.cc.

◆ ConstraintVariableUsageIsConsistent()

bool ConstraintVariableUsageIsConsistent ( )

Definition at line 371 of file presolve_context.cc.

◆ DomainContains()

bool DomainContains ( int  ref,
int64  value 
) const

Definition at line 231 of file presolve_context.cc.

◆ DomainIsEmpty()

bool DomainIsEmpty ( int  ref) const

Definition at line 74 of file presolve_context.cc.

◆ DomainOf()

Domain DomainOf ( int  ref) const

Definition at line 221 of file presolve_context.cc.

◆ DomainOfVarIsIncludedIn()

bool DomainOfVarIsIncludedIn ( int  var,
const Domain domain 
)
inline

Definition at line 108 of file presolve_context.h.

◆ ExploitFixedDomain()

void ExploitFixedDomain ( int  var)

Definition at line 447 of file presolve_context.cc.

◆ GetAbsRelation()

bool GetAbsRelation ( int  target_ref,
int *  ref 
)

Definition at line 686 of file presolve_context.cc.

◆ GetAffineRelation()

AffineRelation::Relation GetAffineRelation ( int  ref) const

Definition at line 743 of file presolve_context.cc.

◆ GetLiteralRepresentative()

int GetLiteralRepresentative ( int  ref) const

Definition at line 704 of file presolve_context.cc.

◆ GetOrCreateConstantVar()

int GetOrCreateConstantVar ( int64  cst)

Definition at line 43 of file presolve_context.cc.

◆ GetOrCreateReifiedPrecedenceLiteral()

int GetOrCreateReifiedPrecedenceLiteral ( int  time_i,
int  time_j,
int  active_i,
int  active_j 
)

Definition at line 1404 of file presolve_context.cc.

◆ GetOrCreateVarValueEncoding()

int GetOrCreateVarValueEncoding ( int  ref,
int64  value 
)

Definition at line 1078 of file presolve_context.cc.

◆ GetVariableRepresentative()

int GetVariableRepresentative ( int  ref) const

Definition at line 733 of file presolve_context.cc.

◆ HasVarValueEncoding()

bool HasVarValueEncoding ( int  ref,
int64  value,
int *  literal = nullptr 
)

Definition at line 1064 of file presolve_context.cc.

◆ InitializeNewDomains()

void InitializeNewDomains ( )

Definition at line 767 of file presolve_context.cc.

◆ InsertVarValueEncoding()

void InsertVarValueEncoding ( int  literal,
int  ref,
int64  value 
)

Definition at line 1040 of file presolve_context.cc.

◆ IntersectDomainWith()

ABSL_MUST_USE_RESULT bool IntersectDomainWith ( int  ref,
const Domain domain,
bool *  domain_modified = nullptr 
)

Definition at line 238 of file presolve_context.cc.

◆ IntervalUsage()

int IntervalUsage ( int  c) const
inline

Definition at line 332 of file presolve_context.h.

◆ IsFixed()

bool IsFixed ( int  ref) const

Definition at line 78 of file presolve_context.cc.

◆ LiteralIsFalse()

bool LiteralIsFalse ( int  lit) const

Definition at line 98 of file presolve_context.cc.

◆ LiteralIsTrue()

bool LiteralIsTrue ( int  lit) const

Definition at line 89 of file presolve_context.cc.

◆ log_info()

bool log_info ( ) const
inline

Definition at line 358 of file presolve_context.h.

◆ MarkVariableAsRemoved()

void MarkVariableAsRemoved ( int  ref)

Definition at line 190 of file presolve_context.cc.

◆ MaxOf() [1/2]

int64 MaxOf ( const LinearExpressionProto &  expr) const

Definition at line 132 of file presolve_context.cc.

◆ MaxOf() [2/2]

int64 MaxOf ( int  ref) const

Definition at line 113 of file presolve_context.cc.

◆ MinOf() [1/2]

int64 MinOf ( const LinearExpressionProto &  expr) const

Definition at line 119 of file presolve_context.cc.

◆ MinOf() [2/2]

int64 MinOf ( int  ref) const

Definition at line 107 of file presolve_context.cc.

◆ ModelIsUnsat()

bool ModelIsUnsat ( ) const
inline

Definition at line 152 of file presolve_context.h.

◆ NewBoolVar()

int NewBoolVar ( )

Definition at line 41 of file presolve_context.cc.

◆ NewIntVar()

int NewIntVar ( const Domain domain)

Definition at line 34 of file presolve_context.cc.

◆ NotifyThatModelIsUnsat()

ABSL_MUST_USE_RESULT bool NotifyThatModelIsUnsat ( const std::string &  message = "")
inline

Definition at line 144 of file presolve_context.h.

◆ NumAffineRelations()

int NumAffineRelations ( ) const
inline

Definition at line 212 of file presolve_context.h.

◆ NumEquivRelations()

int NumEquivRelations ( ) const
inline

Definition at line 213 of file presolve_context.h.

◆ ObjectiveDomain()

const Domain & ObjectiveDomain ( ) const
inline

Definition at line 305 of file presolve_context.h.

◆ ObjectiveDomainIsConstraining()

bool ObjectiveDomainIsConstraining ( ) const
inline

Definition at line 309 of file presolve_context.h.

◆ ObjectiveMap()

const absl::flat_hash_map< int, int64 > & ObjectiveMap ( ) const
inline

Definition at line 306 of file presolve_context.h.

◆ params()

const SatParameters & params ( ) const
inline

Definition at line 359 of file presolve_context.h.

◆ PropagateAffineRelation()

bool PropagateAffineRelation ( int  ref)

Definition at line 471 of file presolve_context.cc.

◆ random()

ModelRandomGenerator * random ( )
inline

Definition at line 361 of file presolve_context.h.

◆ ReadObjectiveFromProto()

void ReadObjectiveFromProto ( )

Definition at line 1137 of file presolve_context.cc.

◆ RefDebugString()

std::string RefDebugString ( int  ref) const

Definition at line 755 of file presolve_context.cc.

◆ RegisterVariablesUsedInAssumptions()

void RegisterVariablesUsedInAssumptions ( )
inline

Definition at line 339 of file presolve_context.h.

◆ RemoveAllVariablesFromAffineRelationConstraint()

void RemoveAllVariablesFromAffineRelationConstraint ( )

Definition at line 493 of file presolve_context.cc.

◆ RemoveVariableFromAffineRelation()

void RemoveVariableFromAffineRelation ( int  var)

Definition at line 502 of file presolve_context.cc.

◆ SetLiteralToFalse()

ABSL_MUST_USE_RESULT bool SetLiteralToFalse ( int  lit)

Definition at line 275 of file presolve_context.cc.

◆ SetLiteralToTrue()

ABSL_MUST_USE_RESULT bool SetLiteralToTrue ( int  lit)

Definition at line 281 of file presolve_context.cc.

◆ StoreAbsRelation()

bool StoreAbsRelation ( int  target_ref,
int  ref 
)

Definition at line 671 of file presolve_context.cc.

◆ StoreAffineRelation()

bool StoreAffineRelation ( int  ref_x,
int  ref_y,
int64  coeff,
int64  offset 
)

Definition at line 530 of file presolve_context.cc.

◆ StoreBooleanEqualityRelation()

void StoreBooleanEqualityRelation ( int  ref_a,
int  ref_b 
)

Definition at line 645 of file presolve_context.cc.

◆ StoreLiteralImpliesVarEqValue()

bool StoreLiteralImpliesVarEqValue ( int  literal,
int  var,
int64  value 
)

Definition at line 1048 of file presolve_context.cc.

◆ StoreLiteralImpliesVarNEqValue()

bool StoreLiteralImpliesVarNEqValue ( int  literal,
int  var,
int64  value 
)

Definition at line 1056 of file presolve_context.cc.

◆ SubstituteVariableInObjective()

bool SubstituteVariableInObjective ( int  var_in_equality,
int64  coeff_in_equality,
const ConstraintProto &  equality,
std::vector< int > *  new_vars_in_objective = nullptr 
)

Definition at line 1301 of file presolve_context.cc.

◆ time_limit()

TimeLimit * time_limit ( )
inline

Definition at line 360 of file presolve_context.h.

◆ UpdateConstraintVariableUsage()

void UpdateConstraintVariableUsage ( int  c)

Definition at line 318 of file presolve_context.cc.

◆ UpdateNewConstraintsVariableUsage()

void UpdateNewConstraintsVariableUsage ( )

Definition at line 356 of file presolve_context.cc.

◆ UpdateRuleStats()

void UpdateRuleStats ( const std::string &  name,
int  num_times = 1 
)

Definition at line 285 of file presolve_context.cc.

◆ VariableIsNotUsedAnymore()

bool VariableIsNotUsedAnymore ( int  ref) const

Definition at line 185 of file presolve_context.cc.

◆ VariableIsOnlyUsedInEncoding()

bool VariableIsOnlyUsedInEncoding ( int  ref) const

Definition at line 215 of file presolve_context.cc.

◆ VariableIsUniqueAndRemovable()

bool VariableIsUniqueAndRemovable ( int  ref) const

Definition at line 165 of file presolve_context.cc.

◆ VariableWasRemoved()

bool VariableWasRemoved ( int  ref) const

Definition at line 197 of file presolve_context.cc.

◆ VariableWithCostIsUniqueAndRemovable()

bool VariableWithCostIsUniqueAndRemovable ( int  ref) const

Definition at line 174 of file presolve_context.cc.

◆ VarToConstraints()

const absl::flat_hash_set< int > & VarToConstraints ( int  var) const
inline

Definition at line 328 of file presolve_context.h.

◆ WriteObjectiveToProto()

void WriteObjectiveToProto ( ) const

Definition at line 1384 of file presolve_context.cc.

Member Data Documentation

◆ deductions

DomainDeductions deductions

Definition at line 408 of file presolve_context.h.

◆ enable_stats

bool enable_stats = true

Definition at line 386 of file presolve_context.h.

◆ keep_all_feasible_solutions

bool keep_all_feasible_solutions = false

Definition at line 382 of file presolve_context.h.

◆ mapping_model

CpModelProto* mapping_model = nullptr

Definition at line 375 of file presolve_context.h.

◆ modified_domains

SparseBitset<int64> modified_domains

Definition at line 405 of file presolve_context.h.

◆ num_presolve_operations

int64 num_presolve_operations = 0

Definition at line 396 of file presolve_context.h.

◆ stats_by_rule_name

absl::flat_hash_map<std::string, int> stats_by_rule_name

Definition at line 389 of file presolve_context.h.

◆ tmp_left_domains

std::vector<Domain> tmp_left_domains

Definition at line 401 of file presolve_context.h.

◆ tmp_literal_set

absl::flat_hash_set<int> tmp_literal_set

Definition at line 402 of file presolve_context.h.

◆ tmp_literals

std::vector<int> tmp_literals

Definition at line 399 of file presolve_context.h.

◆ tmp_term_domains

std::vector<Domain> tmp_term_domains

Definition at line 400 of file presolve_context.h.

◆ var_to_lb_only_constraints

std::vector<absl::flat_hash_set<int> > var_to_lb_only_constraints

Definition at line 372 of file presolve_context.h.

◆ var_to_ub_only_constraints

std::vector<absl::flat_hash_set<int> > var_to_ub_only_constraints

Definition at line 371 of file presolve_context.h.

◆ working_model

CpModelProto* working_model = nullptr

Definition at line 374 of file presolve_context.h.


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