Module org.maxicp

Class BinPacking

java.lang.Object
org.maxicp.cp.engine.core.AbstractCPConstraint
org.maxicp.cp.engine.constraints.BinPacking
All Implemented Interfaces:
CPConstraint, ConcreteConstraint<ConcreteCPModel>

public class BinPacking extends AbstractCPConstraint
The BinPacking constraint ensures that a set of items with given weights are packed into bins such that each bin's total weight respects a given capacity constraint.

This constraint is commonly used in Constraint Programming (CP) models to solve bin-packing problems, where a set of weighted items must be assigned to bins while respecting load capacities.

Author:
pschaus
  • Constructor Details

    • BinPacking

      public BinPacking(CPIntVar[] x, int[] w, CPIntVar[] load)
      Constructs a BinPacking constraint that ensures a set of weighted items are assigned to bins such that the total weight in each bin matches its specified load.

      Each item has a predefined weight and must be placed in exactly one bin. The constraint enforces that the sum of item weights assigned to each bin equals the corresponding load variable.

      Parameters:
      x - an array of CPIntVar variables where x[i] represents the bin index assigned to item i.
      w - an array of integers representing the weights of the items. The weight of item i is w[i].
      load - an array of CPIntVar variables where load[b] represents the total weight of bin b, which must match the sum of weights of items assigned to that bin.
  • Method Details