Class Pack
- java.lang.Object
-
- com.google.ortools.constraintsolver.BaseObject
-
- com.google.ortools.constraintsolver.PropagationBaseObject
-
- com.google.ortools.constraintsolver.Constraint
-
- com.google.ortools.constraintsolver.Pack
-
public class Pack extends Constraint
-
-
Field Summary
-
Fields inherited from class com.google.ortools.constraintsolver.BaseObject
swigCMemOwn
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(ModelVisitor visitor)Accepts the given visitor.voidaddCountAssignedItemsDimension(IntVar count_var)This dimension links 'count_var' to the actual number of items
assigned to a bin in the pack.voidaddCountUsedBinDimension(IntVar count_var)This dimension links 'count_var' to the actual number of bins used in the
pack.voidaddSumVariableWeightsLessOrEqualConstantDimension(IntVar[] usage, long[] 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.voidaddWeightedSumEqualVarDimension(long[] weights, 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].voidaddWeightedSumEqualVarDimension(java.util.function.LongBinaryOperator weights, 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].voidaddWeightedSumLessOrEqualConstantDimension(long[] weights, long[] bounds)Dimensions are additional constraints than can restrict what is
possible with the pack constraint.voidaddWeightedSumLessOrEqualConstantDimension(java.util.function.LongBinaryOperator weights, long[] 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]'.voidaddWeightedSumLessOrEqualConstantDimension(java.util.function.LongUnaryOperator weights, long[] 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]'.voidaddWeightedSumOfAssignedDimension(long[] weights, IntVar cost_var)This dimension enforces that cost_var == sum of weights[i] for
all objects 'i' assigned to a bin.voidassign(int var_index, int bin_index)voidassignAllPossibleToBin(int bin_index)voidassignAllRemainingItems()voidassignFirstPossibleToBin(int bin_index)IntVarassignVar(int var_index, int bin_index)voidclearAll()voiddelete()protected voidfinalize()protected static longgetCPtr(Pack obj)voidinitialPropagate()This method performs the initial propagation of the
constraint.booleanisAssignedStatusKnown(int var_index)booleanisPossible(int var_index, int bin_index)booleanisUndecided(int var_index, int bin_index)voidoneDomain(int var_index)voidpost()This method is called when the constraint is processed by the
solver.voidpropagate()voidpropagateDelayed()voidremoveAllPossibleFromBin(int bin_index)voidsetAssigned(int var_index)voidsetImpossible(int var_index, int bin_index)voidsetUnassigned(int var_index)protected static longswigRelease(Pack obj)java.lang.StringtoString()voidunassignAllRemainingItems()-
Methods inherited from class com.google.ortools.constraintsolver.Constraint
getCPtr, isCastConstraint, postAndPropagate, swigRelease, var
-
Methods inherited from class com.google.ortools.constraintsolver.PropagationBaseObject
baseName, enqueueDelayedDemon, enqueueVar, freezeQueue, getCPtr, hasName, name, reset_action_on_fail, set_variable_to_clean_on_fail, setName, solver, swigRelease, unfreezeQueue
-
Methods inherited from class com.google.ortools.constraintsolver.BaseObject
getCPtr, swigRelease
-
-
-
-
Method Detail
-
getCPtr
protected static long getCPtr(Pack obj)
-
swigRelease
protected static long swigRelease(Pack obj)
-
finalize
protected void finalize()
- Overrides:
finalizein classConstraint
-
delete
public void delete()
- Overrides:
deletein classConstraint
-
addWeightedSumLessOrEqualConstantDimension
public void addWeightedSumLessOrEqualConstantDimension(long[] weights, long[] 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]'.
-
addWeightedSumLessOrEqualConstantDimension
public void addWeightedSumLessOrEqualConstantDimension(java.util.function.LongUnaryOperator weights, long[] 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.
-
addWeightedSumLessOrEqualConstantDimension
public void addWeightedSumLessOrEqualConstantDimension(java.util.function.LongBinaryOperator weights, long[] 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.
-
addWeightedSumEqualVarDimension
public void addWeightedSumEqualVarDimension(long[] weights, 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].
-
addWeightedSumEqualVarDimension
public void addWeightedSumEqualVarDimension(java.util.function.LongBinaryOperator weights, 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].
-
addSumVariableWeightsLessOrEqualConstantDimension
public void addSumVariableWeightsLessOrEqualConstantDimension(IntVar[] usage, long[] 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.
-
addWeightedSumOfAssignedDimension
public void addWeightedSumOfAssignedDimension(long[] weights, IntVar cost_var)This dimension enforces that cost_var == sum of weights[i] for
all objects 'i' assigned to a bin.
-
addCountUsedBinDimension
public void addCountUsedBinDimension(IntVar count_var)
This dimension links 'count_var' to the actual number of bins used in the
pack.
-
addCountAssignedItemsDimension
public void addCountAssignedItemsDimension(IntVar count_var)
This dimension links 'count_var' to the actual number of items
assigned to a bin in the pack.
-
post
public void post()
Description copied from class:ConstraintThis method is called when the constraint is processed by the
solver. Its main usage is to attach demons to variables.- Overrides:
postin classConstraint
-
clearAll
public void clearAll()
-
propagateDelayed
public void propagateDelayed()
-
initialPropagate
public void initialPropagate()
Description copied from class:ConstraintThis method performs the initial propagation of the
constraint. It is called just after the post.- Overrides:
initialPropagatein classConstraint
-
propagate
public void propagate()
-
oneDomain
public void oneDomain(int var_index)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classConstraint
-
isUndecided
public boolean isUndecided(int var_index, int bin_index)
-
setImpossible
public void setImpossible(int var_index, int bin_index)
-
assign
public void assign(int var_index, int bin_index)
-
isAssignedStatusKnown
public boolean isAssignedStatusKnown(int var_index)
-
isPossible
public boolean isPossible(int var_index, int bin_index)
-
assignVar
public IntVar assignVar(int var_index, int bin_index)
-
setAssigned
public void setAssigned(int var_index)
-
setUnassigned
public void setUnassigned(int var_index)
-
removeAllPossibleFromBin
public void removeAllPossibleFromBin(int bin_index)
-
assignAllPossibleToBin
public void assignAllPossibleToBin(int bin_index)
-
assignFirstPossibleToBin
public void assignFirstPossibleToBin(int bin_index)
-
assignAllRemainingItems
public void assignAllRemainingItems()
-
unassignAllRemainingItems
public void unassignAllRemainingItems()
-
accept
public void accept(ModelVisitor visitor)
Description copied from class:ConstraintAccepts the given visitor.- Overrides:
acceptin classConstraint
-
-