OR-Tools  8.2
Pack

Detailed Description

Definition at line 5234 of file constraint_solver.h.

Public Member Functions

 Pack (Solver *const s, const std::vector< IntVar * > &vars, int number_of_bins)
 
 ~Pack () override
 
void AddWeightedSumLessOrEqualConstantDimension (const std::vector< int64 > &weights, const std::vector< int64 > &bounds)
 Dimensions are additional constraints than can restrict what is possible with the pack constraint. More...
 
void AddWeightedSumLessOrEqualConstantDimension (Solver::IndexEvaluator1 weights, const std::vector< int64 > &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]'. More...
 
void AddWeightedSumLessOrEqualConstantDimension (Solver::IndexEvaluator2 weights, const std::vector< int64 > &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]'. More...
 
void AddWeightedSumEqualVarDimension (const std::vector< int64 > &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]. More...
 
void 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]. More...
 
void AddSumVariableWeightsLessOrEqualConstantDimension (const std::vector< IntVar * > &usage, const std::vector< int64 > &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. More...
 
void AddWeightedSumOfAssignedDimension (const std::vector< int64 > &weights, IntVar *const cost_var)
 This dimension enforces that cost_var == sum of weights[i] for all objects 'i' assigned to a bin. More...
 
void AddCountUsedBinDimension (IntVar *const count_var)
 This dimension links 'count_var' to the actual number of bins used in the pack. More...
 
void AddCountAssignedItemsDimension (IntVar *const count_var)
 This dimension links 'count_var' to the actual number of items assigned to a bin in the pack. More...
 
void Post () override
 This method is called when the constraint is processed by the solver. More...
 
void ClearAll ()
 
void PropagateDelayed ()
 
void InitialPropagate () override
 This method performs the initial propagation of the constraint. More...
 
void Propagate ()
 
void OneDomain (int var_index)
 
std::string DebugString () const override
 
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 *const visitor) const override
 Accepts the given visitor. More...
 
void PostAndPropagate ()
 Calls Post and then Propagate to initialize the constraints. More...
 
bool IsCastConstraint () const
 Is the constraint created by a cast from expression to integer variable? More...
 
virtual IntVarVar ()
 Creates a Boolean variable representing the status of the constraint (false = constraint is violated, true = constraint is satisfied). More...
 
Solversolver () const
 
void FreezeQueue ()
 This method freezes the propagation queue. More...
 
void UnfreezeQueue ()
 This method unfreezes the propagation queue. More...
 
void EnqueueDelayedDemon (Demon *const d)
 This method pushes the demon onto the propagation queue. More...
 
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. More...
 
void set_variable_to_clean_on_fail (IntVar *v)
 Shortcut for variable cleaner. More...
 
virtual std::string name () const
 Object naming. More...
 
void set_name (const std::string &name)
 
bool HasName () const
 Returns whether the object has been named or not. More...
 
virtual std::string BaseName () const
 Returns a base name for automatic naming. More...
 

Constructor & Destructor Documentation

◆ Pack()

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

Definition at line 107 of file pack.cc.

◆ ~Pack()

~Pack ( )
override

Definition at line 124 of file pack.cc.

Member Function Documentation

◆ Accept()

void Accept ( ModelVisitor *const  visitor) const
overridevirtual

Accepts the given visitor.

Reimplemented from Constraint.

Definition at line 392 of file pack.cc.

◆ AddCountAssignedItemsDimension()

void AddCountAssignedItemsDimension ( IntVar *const  count_var)

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

Definition at line 1604 of file pack.cc.

◆ AddCountUsedBinDimension()

void AddCountUsedBinDimension ( IntVar *const  count_var)

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

Definition at line 1597 of file pack.cc.

◆ AddSumVariableWeightsLessOrEqualConstantDimension()

void AddSumVariableWeightsLessOrEqualConstantDimension ( const std::vector< IntVar * > &  usage,
const std::vector< int64 > &  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 1587 of file pack.cc.

◆ AddWeightedSumEqualVarDimension() [1/2]

void AddWeightedSumEqualVarDimension ( const std::vector< int64 > &  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 1558 of file pack.cc.

◆ AddWeightedSumEqualVarDimension() [2/2]

void 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 1568 of file pack.cc.

◆ AddWeightedSumLessOrEqualConstantDimension() [1/3]

void AddWeightedSumLessOrEqualConstantDimension ( const std::vector< int64 > &  weights,
const std::vector< int64 > &  bounds 
)

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 1528 of file pack.cc.

◆ AddWeightedSumLessOrEqualConstantDimension() [2/3]

void AddWeightedSumLessOrEqualConstantDimension ( Solver::IndexEvaluator1  weights,
const std::vector< int64 > &  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 1538 of file pack.cc.

◆ AddWeightedSumLessOrEqualConstantDimension() [3/3]

void AddWeightedSumLessOrEqualConstantDimension ( Solver::IndexEvaluator2  weights,
const std::vector< int64 > &  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 1548 of file pack.cc.

◆ AddWeightedSumOfAssignedDimension()

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

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

Definition at line 1578 of file pack.cc.

◆ Assign()

void Assign ( int  var_index,
int  bin_index 
)

Definition at line 415 of file pack.cc.

◆ AssignAllPossibleToBin()

void AssignAllPossibleToBin ( int  bin_index)

Definition at line 465 of file pack.cc.

◆ AssignAllRemainingItems()

void AssignAllRemainingItems ( )

Definition at line 482 of file pack.cc.

◆ AssignFirstPossibleToBin()

void AssignFirstPossibleToBin ( int  bin_index)

Definition at line 475 of file pack.cc.

◆ AssignVar()

IntVar * AssignVar ( int  var_index,
int  bin_index 
) const

Definition at line 431 of file pack.cc.

◆ BaseName()

std::string BaseName ( ) const
virtualinherited

Returns a base name for automatic naming.

Reimplemented in BooleanVar.

Definition at line 2515 of file constraint_solver.cc.

◆ ClearAll()

void ClearAll ( )

Definition at line 142 of file pack.cc.

◆ DebugString()

std::string DebugString ( ) const
overridevirtual

Reimplemented from Constraint.

Definition at line 379 of file pack.cc.

◆ EnqueueAll()

void EnqueueAll ( const SimpleRevFIFO< Demon * > &  demons)
inherited

Definition at line 2521 of file constraint_solver.cc.

◆ EnqueueDelayedDemon()

void EnqueueDelayedDemon ( Demon *const  d)
inlineinherited

This method pushes the demon onto the propagation queue.

It will be processed directly if the queue is empty. It will be enqueued according to its priority otherwise.

Definition at line 3192 of file constraint_solver.h.

◆ EnqueueVar()

void EnqueueVar ( Demon *const  d)
inlineinherited

Definition at line 3193 of file constraint_solver.h.

◆ ExecuteAll()

void ExecuteAll ( const SimpleRevFIFO< Demon * > &  demons)
inherited

Definition at line 2517 of file constraint_solver.cc.

◆ FreezeQueue()

void FreezeQueue ( )
inlineinherited

This method freezes the propagation queue.

It is useful when you need to apply multiple modifications at once.

Definition at line 3183 of file constraint_solver.h.

◆ HasName()

bool HasName ( ) const
inherited

Returns whether the object has been named or not.

Definition at line 2513 of file constraint_solver.cc.

◆ InitialPropagate()

void InitialPropagate ( )
overridevirtual

This method performs the initial propagation of the constraint.

It is called just after the post.

Implements Constraint.

Definition at line 189 of file pack.cc.

◆ IsAssignedStatusKnown()

bool IsAssignedStatusKnown ( int  var_index) const

Definition at line 423 of file pack.cc.

◆ IsCastConstraint()

bool IsCastConstraint ( ) const
inherited

Is the constraint created by a cast from expression to integer variable?

Definition at line 3253 of file constraint_solver.cc.

◆ IsPossible()

bool IsPossible ( int  var_index,
int  bin_index 
) const

Definition at line 427 of file pack.cc.

◆ IsUndecided()

bool IsUndecided ( int  var_index,
int  bin_index 
) const

Definition at line 403 of file pack.cc.

◆ name()

std::string name ( ) const
virtualinherited

Object naming.

Reimplemented in PiecewiseLinearExpr.

Definition at line 2505 of file constraint_solver.cc.

◆ OneDomain()

void OneDomain ( int  var_index)

Definition at line 333 of file pack.cc.

◆ Post()

void Post ( )
overridevirtual

This method is called when the constraint is processed by the solver.

Its main usage is to attach demons to variables.

Implements Constraint.

Definition at line 126 of file pack.cc.

◆ PostAndPropagate()

void PostAndPropagate ( )
inherited

Calls Post and then Propagate to initialize the constraints.

This is usually done in the root node.

Definition at line 3239 of file constraint_solver.cc.

◆ Propagate()

void Propagate ( )

Definition at line 274 of file pack.cc.

◆ PropagateDelayed()

void PropagateDelayed ( )

Definition at line 153 of file pack.cc.

◆ RemoveAllPossibleFromBin()

void RemoveAllPossibleFromBin ( int  bin_index)

Definition at line 455 of file pack.cc.

◆ reset_action_on_fail()

void reset_action_on_fail ( )
inlineinherited

This method clears the failure callback.

Definition at line 3206 of file constraint_solver.h.

◆ set_action_on_fail()

void set_action_on_fail ( Solver::Action  a)
inlineinherited

Definition at line 3200 of file constraint_solver.h.

◆ set_name()

void set_name ( const std::string &  name)
inherited

Definition at line 2509 of file constraint_solver.cc.

◆ set_variable_to_clean_on_fail()

void set_variable_to_clean_on_fail ( IntVar v)
inlineinherited

Shortcut for variable cleaner.

Definition at line 3209 of file constraint_solver.h.

◆ SetAssigned()

void SetAssigned ( int  var_index)

Definition at line 435 of file pack.cc.

◆ SetImpossible()

void SetImpossible ( int  var_index,
int  bin_index 
)

Definition at line 407 of file pack.cc.

◆ SetUnassigned()

void SetUnassigned ( int  var_index)

Definition at line 443 of file pack.cc.

◆ solver()

Solver * solver ( ) const
inlineinherited

Definition at line 3179 of file constraint_solver.h.

◆ UnassignAllRemainingItems()

void UnassignAllRemainingItems ( )

Definition at line 492 of file pack.cc.

◆ UnfreezeQueue()

void UnfreezeQueue ( )
inlineinherited

This method unfreezes the propagation queue.

All modifications that happened when the queue was frozen will be processed.

Definition at line 3187 of file constraint_solver.h.

◆ Var()

IntVar * Var ( )
virtualinherited

Creates a Boolean variable representing the status of the constraint (false = constraint is violated, true = constraint is satisfied).

It returns nullptr if the constraint does not support this API.

Definition at line 3257 of file constraint_solver.cc.


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