53 int *item_weights,
double *item_values)
66 Assert(num_items > 0 && item_weights);
71 for (
i = 0;
i <= max_weight; ++
i)
77 for (
i = 0;
i < num_items; ++
i)
79 int iw = item_weights[
i];
80 double iv = item_values ? item_values[
i] : 1;
82 for (
j = max_weight;
j >= iw; --
j)
Bitmapset * bms_make_singleton(int x)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_replace_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_del_member(Bitmapset *a, int x)
Bitmapset * bms_copy(const Bitmapset *a)
static Datum values[MAXATTR]
#define Assert(condition)
Bitmapset * DiscreteKnapsack(int max_weight, int num_items, int *item_weights, double *item_values)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_SMALL_SIZES
MemoryContextSwitchTo(old_ctx)