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

#include <constraint_solver.h>

Inheritance diagram for operations_research::Pack:
operations_research::Constraint operations_research::PropagationBaseObject operations_research::BaseObject

Public Member Functions

 Pack (Solver *s, const std::vector< IntVar * > &vars, int number_of_bins)
 --— Pack --—
 
 ~Pack () override
 
void AddWeightedSumLessOrEqualConstantDimension (const std::vector< int64_t > &weights, const std::vector< int64_t > &bounds)
 -------— API -------—
 
void AddWeightedSumLessOrEqualConstantDimension (Solver::IndexEvaluator1 weights, const std::vector< int64_t > &bounds)
 
void AddWeightedSumLessOrEqualConstantDimension (Solver::IndexEvaluator2 weights, const std::vector< int64_t > &bounds)
 
void AddWeightedSumEqualVarDimension (const std::vector< int64_t > &weights, const std::vector< IntVar * > &loads)
 
void AddWeightedSumEqualVarDimension (Solver::IndexEvaluator2 weights, const std::vector< IntVar * > &loads)
 
void AddSumVariableWeightsLessOrEqualConstantDimension (const std::vector< IntVar * > &usage, const std::vector< int64_t > &capacity)
 
void AddWeightedSumOfAssignedDimension (const std::vector< int64_t > &weights, IntVar *cost_var)
 
void AddCountUsedBinDimension (IntVar *count_var)
 
void AddCountAssignedItemsDimension (IntVar *count_var)
 
void Post () override
 
void ClearAll ()
 
void PropagateDelayed ()
 
void InitialPropagate () override
 
void Propagate ()
 
void OneDomain (int var_index)
 
std::string DebugString () const override
 --------------— Constraint class ----------------—
 
bool IsUndecided (int var_index, int bin_index) const
 
void SetImpossible (int var_index, int bin_index)
 
void Assign (int var_index, int bin_index)
 
bool IsAssignedStatusKnown (int var_index) const
 
bool IsPossible (int var_index, int bin_index) const
 
IntVarAssignVar (int var_index, int bin_index) const
 
void SetAssigned (int var_index)
 
void SetUnassigned (int var_index)
 
void RemoveAllPossibleFromBin (int bin_index)
 
void AssignAllPossibleToBin (int bin_index)
 
void AssignFirstPossibleToBin (int bin_index)
 
void AssignAllRemainingItems ()
 
void UnassignAllRemainingItems ()
 
void Accept (ModelVisitor *visitor) const override
 Accepts the given visitor.
 
- Public Member Functions inherited from operations_research::Constraint
 Constraint (Solver *const solver)
 
 Constraint (const Constraint &)=delete
 This type is neither copyable nor movable.
 
Constraintoperator= (const Constraint &)=delete
 
 ~Constraint () override
 
void PostAndPropagate ()
 
bool IsCastConstraint () const
 Is the constraint created by a cast from expression to integer variable?
 
virtual IntVarVar ()
 
- Public Member Functions inherited from operations_research::PropagationBaseObject
 PropagationBaseObject (Solver *const s)
 
 PropagationBaseObject (const PropagationBaseObject &)=delete
 This type is neither copyable nor movable.
 
PropagationBaseObjectoperator= (const PropagationBaseObject &)=delete
 
 ~PropagationBaseObject () override
 
std::string DebugString () const override
 
Solversolver () const
 
void FreezeQueue ()
 
void UnfreezeQueue ()
 
void EnqueueDelayedDemon (Demon *const d)
 
void EnqueueVar (Demon *const d)
 
void ExecuteAll (const SimpleRevFIFO< Demon * > &demons)
 
void EnqueueAll (const SimpleRevFIFO< Demon * > &demons)
 
void set_action_on_fail (Solver::Action a)
 
void reset_action_on_fail ()
 This method clears the failure callback.
 
void set_variable_to_clean_on_fail (IntVar *v)
 Shortcut for variable cleaner.
 
virtual std::string name () const
 Object naming.
 
void set_name (absl::string_view name)
 
bool HasName () const
 Returns whether the object has been named or not.
 
virtual std::string BaseName () const
 Returns a base name for automatic naming.
 
- Public Member Functions inherited from operations_research::BaseObject
 BaseObject ()
 
 BaseObject (const BaseObject &)=delete
 This type is neither copyable nor movable.
 
BaseObjectoperator= (const BaseObject &)=delete
 
virtual ~BaseObject ()
 

Detailed Description

Definition at line 5705 of file constraint_solver.h.

Constructor & Destructor Documentation

◆ Pack()

operations_research::Pack::Pack ( Solver * s,
const std::vector< IntVar * > & vars,
int number_of_bins )

--— Pack --—

Definition at line 108 of file pack.cc.

◆ ~Pack()

operations_research::Pack::~Pack ( )
override

Definition at line 125 of file pack.cc.

Member Function Documentation

◆ Accept()

void operations_research::Pack::Accept ( ModelVisitor * visitor) const
overridevirtual

Accepts the given visitor.

Reimplemented from operations_research::Constraint.

Definition at line 393 of file pack.cc.

◆ AddCountAssignedItemsDimension()

void operations_research::Pack::AddCountAssignedItemsDimension ( IntVar * count_var)

This dimension links 'count_var' to the actual number of items assigned to a bin in the pack.

Definition at line 1605 of file pack.cc.

◆ AddCountUsedBinDimension()

void operations_research::Pack::AddCountUsedBinDimension ( IntVar * count_var)

This dimension links 'count_var' to the actual number of bins used in the pack.

Definition at line 1598 of file pack.cc.

◆ AddSumVariableWeightsLessOrEqualConstantDimension()

void operations_research::Pack::AddSumVariableWeightsLessOrEqualConstantDimension ( const std::vector< IntVar * > & usage,
const std::vector< int64_t > & capacity )

This dimension imposes: forall b in bins, sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b] where is_assigned(i, b) is true if and only if item i is assigned to the bin b. This can be used to model shapes of items by linking variables of the same item on parallel dimensions with an allowed assignment constraint.

Definition at line 1588 of file pack.cc.

◆ AddWeightedSumEqualVarDimension() [1/2]

void operations_research::Pack::AddWeightedSumEqualVarDimension ( const std::vector< int64_t > & weights,
const std::vector< IntVar * > & loads )

This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is equal to loads[b].

Definition at line 1559 of file pack.cc.

◆ AddWeightedSumEqualVarDimension() [2/2]

void operations_research::Pack::AddWeightedSumEqualVarDimension ( Solver::IndexEvaluator2 weights,
const std::vector< IntVar * > & loads )

This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b)) of all objects i assigned to 'b' is equal to loads[b].

Definition at line 1569 of file pack.cc.

◆ AddWeightedSumLessOrEqualConstantDimension() [1/3]

void operations_research::Pack::AddWeightedSumLessOrEqualConstantDimension ( const std::vector< int64_t > & weights,
const std::vector< int64_t > & bounds )

-------— API -------—

Dimensions are additional constraints than can restrict what is possible with the pack constraint. It can be used to set capacity limits, to count objects per bin, to compute unassigned penalties... This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is less or equal 'bounds[b]'.

Definition at line 1529 of file pack.cc.

◆ AddWeightedSumLessOrEqualConstantDimension() [2/3]

void operations_research::Pack::AddWeightedSumLessOrEqualConstantDimension ( Solver::IndexEvaluator1 weights,
const std::vector< int64_t > & bounds )

This dimension imposes that for all bins b, the weighted sum (weights->Run(i)) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint.

Definition at line 1539 of file pack.cc.

◆ AddWeightedSumLessOrEqualConstantDimension() [3/3]

void operations_research::Pack::AddWeightedSumLessOrEqualConstantDimension ( Solver::IndexEvaluator2 weights,
const std::vector< int64_t > & bounds )

This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint.

Definition at line 1549 of file pack.cc.

◆ AddWeightedSumOfAssignedDimension()

void operations_research::Pack::AddWeightedSumOfAssignedDimension ( const std::vector< int64_t > & weights,
IntVar * cost_var )

This dimension enforces that cost_var == sum of weights[i] for all objects 'i' assigned to a bin.

Definition at line 1579 of file pack.cc.

◆ Assign()

void operations_research::Pack::Assign ( int var_index,
int bin_index )

Definition at line 416 of file pack.cc.

◆ AssignAllPossibleToBin()

void operations_research::Pack::AssignAllPossibleToBin ( int bin_index)

Definition at line 466 of file pack.cc.

◆ AssignAllRemainingItems()

void operations_research::Pack::AssignAllRemainingItems ( )

Definition at line 483 of file pack.cc.

◆ AssignFirstPossibleToBin()

void operations_research::Pack::AssignFirstPossibleToBin ( int bin_index)

Definition at line 476 of file pack.cc.

◆ AssignVar()

IntVar * operations_research::Pack::AssignVar ( int var_index,
int bin_index ) const

Definition at line 432 of file pack.cc.

◆ ClearAll()

void operations_research::Pack::ClearAll ( )

Definition at line 143 of file pack.cc.

◆ DebugString()

std::string operations_research::Pack::DebugString ( ) const
overridevirtual

--------------— Constraint class ----------------—

Reimplemented from operations_research::Constraint.

Definition at line 380 of file pack.cc.

◆ InitialPropagate()

void operations_research::Pack::InitialPropagate ( )
overridevirtual

This method performs the initial propagation of the constraint. It is called just after the post.

Implements operations_research::Constraint.

Definition at line 190 of file pack.cc.

◆ IsAssignedStatusKnown()

bool operations_research::Pack::IsAssignedStatusKnown ( int var_index) const

Definition at line 424 of file pack.cc.

◆ IsPossible()

bool operations_research::Pack::IsPossible ( int var_index,
int bin_index ) const

Definition at line 428 of file pack.cc.

◆ IsUndecided()

bool operations_research::Pack::IsUndecided ( int var_index,
int bin_index ) const

Definition at line 404 of file pack.cc.

◆ OneDomain()

void operations_research::Pack::OneDomain ( int var_index)
Todo
(user): We know var ranges from 0 to bins_. There are lots of simplifications possible.

Definition at line 334 of file pack.cc.

◆ Post()

void operations_research::Pack::Post ( )
overridevirtual

This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.

Implements operations_research::Constraint.

Definition at line 127 of file pack.cc.

◆ Propagate()

void operations_research::Pack::Propagate ( )

Definition at line 275 of file pack.cc.

◆ PropagateDelayed()

void operations_research::Pack::PropagateDelayed ( )

Definition at line 154 of file pack.cc.

◆ RemoveAllPossibleFromBin()

void operations_research::Pack::RemoveAllPossibleFromBin ( int bin_index)

Definition at line 456 of file pack.cc.

◆ SetAssigned()

void operations_research::Pack::SetAssigned ( int var_index)

Definition at line 436 of file pack.cc.

◆ SetImpossible()

void operations_research::Pack::SetImpossible ( int var_index,
int bin_index )

Definition at line 408 of file pack.cc.

◆ SetUnassigned()

void operations_research::Pack::SetUnassigned ( int var_index)

Definition at line 444 of file pack.cc.

◆ UnassignAllRemainingItems()

void operations_research::Pack::UnassignAllRemainingItems ( )

Definition at line 493 of file pack.cc.


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