logistics-rules-to-optimization
Translate rebalancing business rules (routing + pickup/dropoff + inventory + unmet-target penalty) into a consistent MIP formulation and extract a reportable solution.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- logistics-rules-to-optimization
- description
- Translate rebalancing business rules (routing + pickup/dropoff + inventory + unmet-target penalty) into a consistent MIP formulation and extract a reportable solution.
03 SKILL.md 正文
Steps
- Enumerate entities and sets: vehicles
K, stationsN, depot start/end nodes, and routing arcs. - Choose variables consistent with the rules:
x[v,i,j] ∈ {0,1}for route arcsservice[v,i] ∈ Z(signed):>0pickup,<0dropoff,=0no serviceload[v,node] ∈ Zbounded in[0, vehicle_capacity]unmet[i] ≥ 0for absolute deviation from stationnet_rebalancing_target
- Add routing feasibility constraints:
- each vehicle leaves
depot_startonce and entersdepot_endonce (vehicles must be used) - continuity at each station: in-degree = out-degree per vehicle
- per-vehicle “visit at most once”: out-degree at a station ≤ 1
- each vehicle leaves
- Link service to visiting and enforce “no pickup and drop at the same stop” by using a single signed
service[v,i]and bounding it to zero when not visited:-cap * visit[v,i] ≤ service[v,i] ≤ cap * visit[v,i]
- Enforce load propagation along selected arcs with big‑M:
load[v,j] = load[v,i] + service[v,j]when arc(i→j)is used (treat depot change as 0)- keep all loads within
[0, vehicle_capacity], including start and end loads
- Enforce station inventory feasibility (hard bounds), using aggregated station net change:
net_change[i] = Σ_v service[v,i]- pickup limit:
net_change[i] ≤ initial_bikes[i] - dropoff limit:
net_change[i] ≥ -(station_capacity[i] - initial_bikes[i])These bounds correctly handle structurally impossible targets (e.g., pickup target exceeding available bikes) by limiting achievable service.
- Model unmet rebalancing with absolute deviation linearization:
net_change[i] - target[i] ≤ unmet[i]target[i] - net_change[i] ≤ unmet[i]- penalty term:
penalty_weight * Σ_i unmet[i]
- Objective: minimize
total_travel_distance + unmet_penalty. - Extract a reportable solution:
- reconstruct each vehicle’s ordered route from selected arcs (and ensure it is a single depot→…→depot path)
- per stop, output either
bikes_picked_up=max(service,0)orbikes_dropped_off=max(-service,0), and computeload_after_stop - station section must include every station with totals,
net_bike_change, andunmet_rebalancing_amount = abs(target - net_bike_change).
Expected Result
A solution that satisfies all hard routing/load/inventory rules, allows unavoidable target shortfalls via unmet penalties when targets exceed physical bounds, and supports direct construction of the required report.json station/vehicle summaries.
04 同仓库更多 Skills
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms