Skip to content

Instantly share code, notes, and snippets.

@bokner
Created December 8, 2024 20:51
Show Gist options
  • Save bokner/ad85166f23d8f44291c683d8b3980367 to your computer and use it in GitHub Desktop.
Save bokner/ad85166f23d8f44291c683d8b3980367 to your computer and use it in GitHub Desktop.
include "globals.mzn";
% Number of items
int: N;
% Bin capacity
int: C;
set of int: ITEMS = 1..N;
% Upper Bound on the number of bins used
int: max_bins = N;
set of int: BINS = 1..max_bins;
array[ITEMS] of int: item_sizes;
% What bin each item goes to
array[ITEMS] of var BINS: item_placement;
var BINS: total_bins;
constraint bin_packing(C, item_placement, item_sizes);
constraint total_bins = max(item_placement);
solve minimize total_bins;
@bokner
Copy link
Author

bokner commented Dec 8, 2024

Results: (1 minute run)

Instance Gecode Best
u120_00 49 48
u120_01 49 49
u120_02 46 46
u120_03 49 49
u120_04 50 50
u120_05 48 48
u120_06 48 48
u120_07 50 49
u120_08 51 51
u120_09 47 46
u120_10 52 52
u120_11 49 49
u120_12 49 48
u120_13 49 49
u120_14 50 50
u120_15 48 48
u120_16 52 52
u120_17 53 52
u120_18 49 49
u120_19 50 50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment