VRPTW dispatch: parallel-round savings construction and penalised inter-route local search
/app/cpu/main.cpp is the source of a multicore CPU program (C++17, OpenMP).
The program takes one input-file path (PROGRAM INPUT_FILE) and writes its result to stdout.
What the program computes
A vehicle-routing planner with time windows (VRPTW), run on several independent instances. Everything is exact integer arithmetic; the CPU source is the specification.
Per instance (n customers, seed s):
- Instance. Customers get coordinates on a 10000x10000 grid (65% around 8-31 cluster
centres, the rest uniform), demand 1..25, service time 6..20 and a time window around a
random centre (half wide 4000-9000, half narrow 800-2400), clipped so that a direct
depot round trip is feasible. The depot is customer index
nat (5000, 5000) with window[0, 30000]. Distance = travel time =floor(sqrt(dx^2 + dy^2))(exact integer square root). Each customer gets its 24 nearest other customers (squared distance, ties by lower index). - Savings construction, in rounds, starting from one route per customer (route id = its
customer). Each route
rproposes the merge "r then q" for the best route head reachable from its tail's neighbour list, with saving4*(d(t,0)+d(0,h)) - 5*d(t,h) > 0, total load<= 180, and zero time warp of the merged route. Each route accepts its best incoming proposal (keysaving << 32 | (2^32-1-r)); a merge is applied only if its key is larger than the keys of the accepted merge intorand the accepted merge out ofq. Merged routes keep the id of the first route. Rounds end when nothing is applied. - Penalised local search, in rounds. Route cost = distance + 3 * time warp + 11 * load
excess over 180 + 650 per non-empty route; time windows are soft (Vidal-style segment
summaries: duration, time warp, earliest/latest start, distance, load, concatenated in
O(1)). Every customer
uscans its neighboursvin another route and five moves: relocateuafterv, relocateubeforev, 2-opt* (exchange the tails afteruand afterv), exchangeuandv, and move the block (u, successor ofu) afterv. Its best strictly improving move (first found in neighbour order, then move order) gets keygain << 24 | (2^24-1-u). A move is applied only if its key is the largest among all moves touching each of its two routes, so applied moves are route-disjoint. Rounds end when no move is applied (or after 3000 rounds; savings cap 2000 rounds). - Report fleet, distance, time warp, overload, cost, route-length histogram and an order-independent hash of all route sequences.
Input format
I
n_1 seed_1
...
n_I seed_I
Output format
Per instance k:
INST k n <n> sav_rounds <r> merges <m> sav_cost <c> ls_rounds <r> moves <relocate_after> <relocate_before> <2opt*> <exchange> <oropt>
RESULT k routes <R> dist <D> timewarp <TW> late_routes <x> overload <o> cost <C> maxlen <L>
SIZES k <len<=5> <6-10> <11-15> <16-20> <21-30> <31+> HASH <hex>
then TOTAL cost <sum of instance costs>. Everything must match exactly.
Hidden inputs
Correctness inputs (10 files, 1-4 instances each) include instances with n = 0, 1, 2, 3,
tiny instances, and random instances with n <= 3000. The timing input has 24 instances with
n uniform in [12000, 16000]. Always 0 <= n <= 20000.
Your task
Port this program to CUDA in /app/gpu/main.cu: same command line (PROGRAM INPUT_FILE),
same output on stdout. Then make it as fast as you can on the GPU while keeping the output correct.
The main computation must execute on the GPU. Renaming CPU code to .cu, running a
CPU fallback, or launching a dummy kernel while computing the answer on the CPU does not satisfy this task.
The CPU source is the specification: when this text and the code disagree, the code wins.
This sandbox is for writing the source only: it has g++ and the CPU program, but no CUDA
compiler and no GPU. Compilation, execution and verification happen later on an H100 in a
separate verifier, and a port that does not compile is rejected, so check your logic against
the CPU program before you finish (for example by emulating your kernels on the host).
How your port is verified
- Only
/app/gpu/main.cuis collected. It is compiled withnvcc -O3 -arch=sm_90 -std=c++17 -o port /app/gpu/main.cu; no extra libraries are linked. The CUDA runtime and the header-only libraries that ship with the CUDA toolkit (CUB, Thrust, libcu++) are allowed. - Your source must not contain any of:
system(,popen(,fork(,exec*,dlopen(,getenv(,#include <filesystem>,/tests/,/proc/. The program may read only the input file it is given. - Verification runs on one H100 in a fresh container without network. Hidden inputs are generated with a fresh random seed at verification time.
- Correctness: every hidden input (small edge cases plus a large timing input) must pass. Your output must be identical to the CPU program's output (trailing whitespace ignored). Any mismatch, crash or timeout is rejected.
- GPU execution is checked: a port that computes its answer on the CPU is rejected even when its output is correct.
- Speed: The timing input has 24 independent instances with 12000-16000 customers each.
/app/inputs/timing_example.inhas the shape and size of the hidden timing input. Your port is timed against a reference GPU port on it; the faster your port, the higher its score. /app/inputs/holds public input examples for understanding the input format.