OR-Tools  9.3
Pack

Detailed Description

Definition at line 5277 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_t > &weights, const std::vector< int64_t > &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_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]'. More...
 
void 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]'. More...
 
void 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]. 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_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. More...
 
void AddWeightedSumOfAssignedDimension (const std::vector< int64_t > &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 108 of file pack.cc.

◆ ~Pack()

~Pack ( )
override

Definition at line 125 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 393 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 1605 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 1598 of file pack.cc.

◆ AddSumVariableWeightsLessOrEqualConstantDimension()

void 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 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 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 AddWeightedSumLessOrEqualConstantDimension ( const std::vector< int64_t > &  weights,
const std::vector< int64_t > &  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 1529 of file pack.cc.

◆ AddWeightedSumLessOrEqualConstantDimension() [2/3]

void 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 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 AddWeightedSumOfAssignedDimension ( const std::vector< int64_t > &  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 1579 of file pack.cc.

◆ Assign()

void Assign ( int  var_index,
int  bin_index 
)

Definition at line 416 of file pack.cc.

◆ AssignAllPossibleToBin()

void AssignAllPossibleToBin ( int  bin_index)

Definition at line 466 of file pack.cc.

◆ AssignAllRemainingItems()

void AssignAllRemainingItems ( )

Definition at line 483 of file pack.cc.

◆ AssignFirstPossibleToBin()

void AssignFirstPossibleToBin ( int  bin_index)

Definition at line 476 of file pack.cc.

◆ AssignVar()

IntVar * AssignVar ( int  var_index,
int  bin_index 
) const

Definition at line 432 of file pack.cc.

◆ BaseName()

std::string BaseName ( ) const
virtualinherited

Returns a base name for automatic naming.

Reimplemented in BooleanVar.

Definition at line 2521 of file constraint_solver.cc.

◆ ClearAll()

void ClearAll ( )

Definition at line 143 of file pack.cc.

◆ DebugString()

std::string DebugString ( ) const
overridevirtual

Reimplemented from Constraint.

Definition at line 380 of file pack.cc.

◆ EnqueueAll()

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

Definition at line 2527 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 3209 of file constraint_solver.h.

◆ EnqueueVar()

void EnqueueVar ( Demon *const  d)
inlineinherited

Definition at line 3210 of file constraint_solver.h.

◆ ExecuteAll()

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

Definition at line 2523 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 3200 of file constraint_solver.h.

◆ HasName()

bool HasName ( ) const
inherited

Returns whether the object has been named or not.

Definition at line 2519 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 190 of file pack.cc.

◆ IsAssignedStatusKnown()

bool IsAssignedStatusKnown ( int  var_index) const

Definition at line 424 of file pack.cc.

◆ IsCastConstraint()

bool IsCastConstraint ( ) const
inherited

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

Definition at line 3300 of file constraint_solver.cc.

◆ IsPossible()

bool IsPossible ( int  var_index,
int  bin_index 
) const

Definition at line 428 of file pack.cc.

◆ IsUndecided()

bool IsUndecided ( int  var_index,
int  bin_index 
) const

Definition at line 404 of file pack.cc.

◆ name()

std::string name ( ) const
virtualinherited

Object naming.

Reimplemented in PiecewiseLinearExpr.

Definition at line 2511 of file constraint_solver.cc.

◆ OneDomain()

void OneDomain ( int  var_index)

Definition at line 334 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 127 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 3286 of file constraint_solver.cc.

◆ Propagate()

void Propagate ( )

Definition at line 275 of file pack.cc.

◆ PropagateDelayed()

void PropagateDelayed ( )

Definition at line 154 of file pack.cc.

◆ RemoveAllPossibleFromBin()

void RemoveAllPossibleFromBin ( int  bin_index)

Definition at line 456 of file pack.cc.

◆ reset_action_on_fail()

void reset_action_on_fail ( )
inlineinherited

This method clears the failure callback.

Definition at line 3223 of file constraint_solver.h.

◆ set_action_on_fail()

void set_action_on_fail ( Solver::Action  a)
inlineinherited

Definition at line 3217 of file constraint_solver.h.

◆ set_name()

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

Definition at line 2515 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 3226 of file constraint_solver.h.

◆ SetAssigned()

void SetAssigned ( int  var_index)

Definition at line 436 of file pack.cc.

◆ SetImpossible()

void SetImpossible ( int  var_index,
int  bin_index 
)

Definition at line 408 of file pack.cc.

◆ SetUnassigned()

void SetUnassigned ( int  var_index)

Definition at line 444 of file pack.cc.

◆ solver()

Solver * solver ( ) const
inlineinherited

Definition at line 3196 of file constraint_solver.h.

◆ UnassignAllRemainingItems()

void UnassignAllRemainingItems ( )

Definition at line 493 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 3204 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 3304 of file constraint_solver.cc.


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