This repository contains a simple C++ implementation of the Vickrey–Clarke–Groves (VCG) mechanism for a combinatorial auction, where bundles of goods are represented using bitmasks.
The program computes:
- The efficient allocation (maximizing total social welfare).
- The VCG payment for each bidder (the externality imposed on the others).
The efficient allocation is found using a brute-force search over all bid combinations, so this implementation is intended for small instances only.
-
vcg.h
Defines theBidstructure and declares the main functions, as well as the global variables used by the tests. -
vcg.cpp
Implements:computeMaxWelfare(...): finds the welfare-maximizing set of non-overlapping bids.computeVCG(): prints the efficient allocation and the VCG payments for each bidder.
-
vcg_test.cpp
Contains a fixed test scenario and executescomputeVCG(), also printing the expected output.
Each bid is represented as:
struct Bid {
int bidder_id; // Bidder identifier
int bundle_mask; // Bitmask representing the bundle of goods
double value; // Declared value for the bundle
};