amazon-science/papercode-coordinating-spot-and-contracts
Python
Captured source
source ↗amazon-science/papercode-coordinating-spot-and-contracts
Description: Code for Paper: "Coordinating Spot and Contract Supply in Freight Marketplaces"
Language: Python
License: NOASSERTION
Stars: 0
Forks: 0
Open issues: 0
Created: 2026-03-28T14:47:56Z
Pushed: 2026-03-28T15:11:32Z
Default branch: main
Fork: no
Archived: yes
README:
Code for Paper: "Coordinating Spot and Contract Supply in Freight Marketplaces"
This code is being released solely for academic and scientific reproducibility purposes, in support of the methods and findings described in the associated publication. Pull requests are not being accepted in order to maintain the code exactly as it was used in [the paper](preprint.pdf).
arXiv: https://arxiv.org/abs/2603.24574
Requirements
Software Versions
- Python 3.13.5
- numpy 2.1.3
- pandas 2.2.3
- cvxpy 1.7.3
- gurobipy 12.0.3
- scipy 1.15.3
- matplotlib 3.10.0
Installation: pip install numpy pandas cvxpy gurobipy scipy matplotlib
Note: Gurobi requires a license.
Files:
- real_bipartite.py - Real-data bipartite contract experiment (Table 1)
- synthetic_bipartite.py - Synthetic Erdős-Rényi bipartite experiment (Figure: savings vs p)
- lane_level.py - Lane-level contract experiment (Figure: savings vs B/L and a)
- bipartite_left_loads.csv - Sigmoid coefficients and distances for left nodes
- bipartite_right_loads.csv - Sigmoid coefficients and distances for right nodes
- bipartite_edges.csv - Bipartite graph edge matrix (k × k)
Experiments
Calibrated Bipartite Contracts (Table 1)
Compares DFW and LBA on a bipartite graph calibrated from real freight data. Run with: python real_bipartite.py
Parameters: k = 50 (loads per side), B = 25 (contracts), late_posting in {1.0, 1.05, 1.10, 1.20, 1.50} (alternate cost premium), num_samples = 1000 (Monte Carlo samples)
Output: DFW cost, LBA cost, relative savings (%), std. error in relative savings (%)
Synthetic Bipartite Contracts (Figure: Savings vs Edge Probability)
Compares DFW and LBA on random Erdős-Rényi bipartite graphs G(50,50,p). Run with: python synthetic_bipartite.py
Parameters: k = 50 (loads per side), B = 25 (contracts), a = 300 (alternate cost), p_edge in {0.01, 0.02, ..., 0.30} (edge probability), S = 1000 (random graph replications), num_samples = 1000 (Monte Carlo samples per graph)
Output: Mean savings and 95% CI for each edge probability
Lane-Level Contracts (Figure: Savings vs B/L and a)
Compares DFW and LBA on lane-level contracts with uniform [100,200] carrier values and logistic carrier values. Run with: python lane_level.py
Parameters: L = 1000 (total loads), B/L in {0.1, 0.2, ..., 0.9} (contract ratio), a in {100, 110, ..., 400} (alternate cost)
Output: Relative savings as function of B/L and a. The iterates of the DFW algorithm on these instances.
Data Format
bipartite_left_loads.csv and bipartite_right_loads.csv contain two columns: sigmoid_coeff (e.g., "[1.263, 3.187]") which are the [x0, k] parameters for logistic acceptance curve F(z) = 1/(1 + exp(-k(z - x0))), and distance (load distance in miles). Scaled price is computed as z = (price - 100) / distance.
bipartite_edges.csv is a k × k binary matrix where edges[i,j] = 1 if left load i and right load j can be paired in a round-trip contract.
Security
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
License
This library is licensed under the CC-BY-NC-4.0 License.
Notability
notability 5.0/10New research code from amazon-science