Skip to content

Commit a883d63

Browse files
author
Mikael Zayenz Lagerkvist
committed
Integrate bin-packing DFF propagation
1 parent c622f0f commit a883d63

6 files changed

Lines changed: 293 additions & 281 deletions

File tree

changelog.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ This release modernizes the Gecode build infrastructure, adds a
7575
first-class CMake package for downstream consumers, refreshes the
7676
autoconf build path, and updates CI coverage for current platforms.
7777

78+
[ENTRY]
79+
Module: int
80+
What: performance
81+
Rank: minor
82+
Issue: 202
83+
Thanks: Fabio Tardivo
84+
[DESCRIPTION]
85+
Strengthen bin-packing propagation with lower bounds based on
86+
dual-feasible functions, improving early detection of infeasible
87+
packing states.
88+
7889
[ENTRY]
7990
Module: other
8091
What: change

gecode/int/bin-packing.hh

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
* Christian Schulte <schulte@gecode.dev>
55
*
66
* Contributing authors:
7+
* Fabio Tardivo <ftardivo@nmsu.edu>
78
* Stefano Gualandi <stefano.gualandi@gmail.com>
89
*
910
* Copyright:
11+
* Fabio Tardivo, 2024
1012
* Stefano Gualandi, 2013
1113
* Christian Schulte, 2010
1214
*
@@ -127,11 +129,11 @@ namespace Gecode { namespace Int { namespace BinPacking {
127129
int operator [](int i) const;
128130
};
129131

130-
/// Range of lambda values
131-
struct LambdaRange {int min; int max;};
132-
133-
/// Integer Dynamic Array
134-
using IntDynamicArray = Support::DynamicArray<int,Region>;
132+
/// Range of lambda values
133+
struct LambdaRange {
134+
int min;
135+
int max;
136+
};
135137

136138
/**
137139
* \brief Bin-packing propagator
@@ -182,30 +184,39 @@ namespace Gecode { namespace Int { namespace BinPacking {
182184
/// Destructor
183185
virtual size_t dispose(Space& home);
184186
/// Reductions
185-
static int const nReductions = 3;
186-
static void calcReductions(const ViewArray<Item>& bs, const ViewArray<OffsetView>& l, IntDynamicArray & weightsBaseReduction, int & capacityBaseReduction, IntDynamicArray & deltaReductions);
187+
static int const n_reductions = 3;
188+
static void calc_reductions(const ViewArray<Item>& bs,
189+
const ViewArray<OffsetView>& l,
190+
int* weights_base_reduction,
191+
int& capacity_base_reduction,
192+
int* delta_reductions);
187193
/// Dual Feasible Functions
188-
static int fCCM1(int w, int l, int c);
189-
static int fMT(int w, int l, int c);
190-
static int fBJ1(int w, int l, int c);
191-
static int fVB2Base(int w, int l, int c);
192-
static int fVB2(int w, int l, int c);
193-
static int fFS1(int w, int l, int c);
194-
static int fRAD2Base(int w, int l, int c);
195-
static int fRAD2(int w, int l, int c);
196-
static int const nLambdaSamples = 256;
197-
static LambdaRange lCCM1(int c);
198-
static LambdaRange lMT(int c);
199-
static LambdaRange lBJ1(int c);
200-
static LambdaRange lVB2(int c);
201-
static LambdaRange lFS1(int c);
202-
static LambdaRange lRAD2(int c);
203-
static LambdaRange sanitizeLambdaRange(LambdaRange lambda, int nWeights, int maxWeight);
194+
static int f_ccm1(int w, int l, int c);
195+
static int f_mt(int w, int l, int c);
196+
static int f_bj1(int w, int l, int c);
197+
static int f_vb2_base(int w, int l, int c);
198+
static int f_vb2(int w, int l, int c);
199+
static int f_fs1(int w, int l, int c);
200+
static int f_rad2_base(int w, int l, int c);
201+
static int f_rad2(int w, int l, int c);
202+
static int const n_lambda_samples = 256;
203+
static LambdaRange l_ccm1(int c);
204+
static LambdaRange l_mt(int c);
205+
static LambdaRange l_bj1(int c);
206+
static LambdaRange l_vb2(int c);
207+
static LambdaRange l_fs1(int c);
208+
static LambdaRange l_rad2(int c);
209+
static LambdaRange sanitize_lambda_range(LambdaRange lambda,
210+
int n_weights, int max_weight);
204211
/// Lower bound
205212
template<int f(int,int,int)>
206-
static int calcDffLowerboundSingleLambda(const IntDynamicArray & weights, int capacity, int lambda);
213+
static int calc_dff_lower_bound_single_lambda(const int* weights,
214+
int n_weights,
215+
int capacity, int lambda);
207216
template<int f(int,int,int), LambdaRange l(int)>
208-
static int calcDffLowerbound(const IntDynamicArray & weights, int capacity, int nNotZeroWeights, int maxWeight, bool sanitize = false);
217+
static int calc_dff_lower_bound(const int* weights, int n_weights,
218+
int capacity, int n_not_zero_weights,
219+
int max_weight, bool sanitize = false);
209220
};
210221

211222

0 commit comments

Comments
 (0)