scenario_id
stringlengths 17
34
| prompt
stringlengths 4.45k
7.03k
| data
stringlengths 2.79k
5.46k
| reference_status
stringclasses 2
values | reference_objective
float64 307k
5.8M
|
|---|---|---|---|---|
retail_f1_52_weeks_v0
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_52_weeks
Scenario ID: retail_f1_52_weeks_v0
[BUSINESS DESCRIPTION]
Business narrative:
The retailer plans inventory over a full year of weekly decisions, represented by fifty-two time periods. Exogenous seasonal demand, local inventories at each distribution center, and per-product production capacities work as in the core operations baseline. Customers are never backordered; unmet demand in a week is immediately lost and penalized. The main difference is the extended planning horizon, which tests the ability to manage long-run seasonality and accumulation effects.
Structure cues:
- The inventory system is the same as in retail_f1_base, with multiple products, multiple locations, and capacity-limited production for each product and period.
- The time index now runs for fifty-two periods. The same inventory evolution and demand fulfillment logic is applied in every period of the year.
- At each location and for each product, stock at the end of a week depends on what was carried over, what was produced for that location during the week, and what was sold or discarded. Inventory cannot go below zero; any unmet demand in a week is lost and penalized.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- Substitution: Edge [p_from, p_to] means p_from's demand can be served by p_to's inventory.
Variable sub[p_from, p_to, l, t] = units of p_from's demand fulfilled by p_to.
Demand fulfillment equation:
- For p_from: total_sales[p_from] + sub[p_from, p_to] + L[p_from] = demand[p_from]
- For p_to: total_sales[p_to] - sub[p_from, p_to] + L[p_to] = demand[p_to]
Interpretation: p_from's demand is served by own sales + substitution + lost.
p_to's total sales include serving both its own demand and p_from's demand.
- No transshipment and zero lead times in this scenario.
- Labor capacity remains high enough that it does not materially bind, though it can be represented consistently with the JSON.
- The objective is to minimize total cost over the entire year, aggregating holding, waste, and lost sales costs across all weeks.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_52_weeks_v0", "description": "Standard seasonal retail scenario.", "periods": 52, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311, 303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311, 303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155, 151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155, 151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124, 121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124, 121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 1,006,432
|
retail_f1_52_weeks_v1
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_52_weeks
Scenario ID: retail_f1_52_weeks_v1
[BUSINESS DESCRIPTION]
Business narrative:
The retailer plans inventory over a full year of weekly decisions, represented by fifty-two time periods. Exogenous seasonal demand, local inventories at each distribution center, and per-product production capacities work as in the core operations baseline. Customers are never backordered; unmet demand in a week is immediately lost and penalized. The main difference is the extended planning horizon, which tests the ability to manage long-run seasonality and accumulation effects.
Structure cues:
- The inventory system is the same as in retail_f1_base, with multiple products, multiple locations, and capacity-limited production for each product and period.
- The time index now runs for fifty-two periods. The same inventory evolution and demand fulfillment logic is applied in every period of the year.
- At each location and for each product, stock at the end of a week depends on what was carried over, what was produced for that location during the week, and what was sold or discarded. Inventory cannot go below zero; any unmet demand in a week is lost and penalized.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- Substitution: Edge [p_from, p_to] means p_from's demand can be served by p_to's inventory.
Variable sub[p_from, p_to, l, t] = units of p_from's demand fulfilled by p_to.
Demand fulfillment equation:
- For p_from: total_sales[p_from] + sub[p_from, p_to] + L[p_from] = demand[p_from]
- For p_to: total_sales[p_to] - sub[p_from, p_to] + L[p_to] = demand[p_to]
Interpretation: p_from's demand is served by own sales + substitution + lost.
p_to's total sales include serving both its own demand and p_from's demand.
- No transshipment and zero lead times in this scenario.
- Labor capacity remains high enough that it does not materially bind, though it can be represented consistently with the JSON.
- The objective is to minimize total cost over the entire year, aggregating holding, waste, and lost sales costs across all weeks.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_52_weeks_v1", "description": "Standard seasonal retail scenario.", "periods": 52, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3483.5107111415105, "DC2": 3583.3567701844527, "DC3": 2823.773247022257, "DC4": 2587.2574205432406, "DC5": 2324.632357495927}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [289, 294, 338, 348, 445, 626, 729, 911, 1247, 1288, 1207, 1213, 1097, 889, 808, 617, 437, 408, 337, 286, 338, 272, 359, 320, 414, 515, 628, 935, 1045, 1377, 1398, 1128, 997, 865, 774, 628, 426, 350, 324, 274, 301, 298, 359, 358, 427, 495, 773, 1008, 1188, 1400, 1407, 1321], "SKU_Premium": [156, 132, 170, 180, 199, 301, 357, 470, 487, 563, 735, 569, 508, 391, 321, 259, 206, 181, 186, 176, 140, 159, 181, 205, 245, 276, 384, 459, 526, 691, 612, 572, 579, 421, 336, 278, 245, 183, 144, 161, 132, 150, 172, 157, 231, 301, 321, 456, 497, 682, 621, 626], "SKU_ShortLife": [114, 126, 122, 166, 193, 224, 262, 328, 458, 430, 475, 446, 419, 314, 309, 201, 152, 163, 142, 140, 124, 112, 113, 161, 169, 188, 252, 359, 486, 523, 580, 543, 409, 335, 249, 226, 151, 148, 147, 126, 119, 140, 136, 151, 170, 188, 315, 334, 402, 431, 469, 466]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 1,004,271.5
|
retail_f1_52_weeks_v2
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_52_weeks
Scenario ID: retail_f1_52_weeks_v2
[BUSINESS DESCRIPTION]
Business narrative:
The retailer plans inventory over a full year of weekly decisions, represented by fifty-two time periods. Exogenous seasonal demand, local inventories at each distribution center, and per-product production capacities work as in the core operations baseline. Customers are never backordered; unmet demand in a week is immediately lost and penalized. The main difference is the extended planning horizon, which tests the ability to manage long-run seasonality and accumulation effects.
Structure cues:
- The inventory system is the same as in retail_f1_base, with multiple products, multiple locations, and capacity-limited production for each product and period.
- The time index now runs for fifty-two periods. The same inventory evolution and demand fulfillment logic is applied in every period of the year.
- At each location and for each product, stock at the end of a week depends on what was carried over, what was produced for that location during the week, and what was sold or discarded. Inventory cannot go below zero; any unmet demand in a week is lost and penalized.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- Substitution: Edge [p_from, p_to] means p_from's demand can be served by p_to's inventory.
Variable sub[p_from, p_to, l, t] = units of p_from's demand fulfilled by p_to.
Demand fulfillment equation:
- For p_from: total_sales[p_from] + sub[p_from, p_to] + L[p_from] = demand[p_from]
- For p_to: total_sales[p_to] - sub[p_from, p_to] + L[p_to] = demand[p_to]
Interpretation: p_from's demand is served by own sales + substitution + lost.
p_to's total sales include serving both its own demand and p_from's demand.
- No transshipment and zero lead times in this scenario.
- Labor capacity remains high enough that it does not materially bind, though it can be represented consistently with the JSON.
- The objective is to minimize total cost over the entire year, aggregating holding, waste, and lost sales costs across all weeks.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_52_weeks_v2", "description": "Standard seasonal retail scenario.", "periods": 52, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4291.310835751933, "DC2": 3586.8980554014483, "DC3": 2802.1254967501045, "DC4": 2560.502105140458, "DC5": 2521.5221885622987}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [331, 304, 318, 378, 411, 628, 792, 880, 1028, 1292, 1186, 1166, 1258, 808, 713, 621, 394, 343, 361, 348, 311, 345, 356, 403, 410, 611, 659, 983, 1013, 1172, 1257, 1291, 1053, 976, 737, 536, 435, 339, 306, 322, 303, 315, 335, 326, 458, 575, 717, 955, 1047, 1179, 1112, 1071], "SKU_Premium": [150, 172, 159, 162, 227, 279, 397, 400, 615, 691, 722, 707, 614, 473, 395, 261, 195, 181, 182, 168, 131, 174, 163, 182, 249, 308, 320, 514, 526, 645, 679, 673, 563, 435, 335, 279, 228, 192, 144, 149, 138, 152, 164, 167, 238, 301, 354, 456, 611, 643, 612, 601], "SKU_ShortLife": [138, 134, 146, 167, 154, 221, 249, 408, 460, 445, 532, 513, 453, 398, 303, 243, 199, 124, 121, 128, 127, 135, 122, 134, 158, 189, 272, 324, 408, 439, 540, 508, 471, 357, 308, 187, 173, 156, 129, 142, 137, 140, 116, 159, 175, 235, 256, 402, 492, 519, 455, 518]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 1,026,462.5
|
retail_f1_52_weeks_v3
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_52_weeks
Scenario ID: retail_f1_52_weeks_v3
[BUSINESS DESCRIPTION]
Business narrative:
The retailer plans inventory over a full year of weekly decisions, represented by fifty-two time periods. Exogenous seasonal demand, local inventories at each distribution center, and per-product production capacities work as in the core operations baseline. Customers are never backordered; unmet demand in a week is immediately lost and penalized. The main difference is the extended planning horizon, which tests the ability to manage long-run seasonality and accumulation effects.
Structure cues:
- The inventory system is the same as in retail_f1_base, with multiple products, multiple locations, and capacity-limited production for each product and period.
- The time index now runs for fifty-two periods. The same inventory evolution and demand fulfillment logic is applied in every period of the year.
- At each location and for each product, stock at the end of a week depends on what was carried over, what was produced for that location during the week, and what was sold or discarded. Inventory cannot go below zero; any unmet demand in a week is lost and penalized.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- Substitution: Edge [p_from, p_to] means p_from's demand can be served by p_to's inventory.
Variable sub[p_from, p_to, l, t] = units of p_from's demand fulfilled by p_to.
Demand fulfillment equation:
- For p_from: total_sales[p_from] + sub[p_from, p_to] + L[p_from] = demand[p_from]
- For p_to: total_sales[p_to] - sub[p_from, p_to] + L[p_to] = demand[p_to]
Interpretation: p_from's demand is served by own sales + substitution + lost.
p_to's total sales include serving both its own demand and p_from's demand.
- No transshipment and zero lead times in this scenario.
- Labor capacity remains high enough that it does not materially bind, though it can be represented consistently with the JSON.
- The objective is to minimize total cost over the entire year, aggregating holding, waste, and lost sales costs across all weeks.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_52_weeks_v3", "description": "Standard seasonal retail scenario.", "periods": 52, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4580.392163478575, "DC2": 3714.3315490990617, "DC3": 3353.9465124536155, "DC4": 2764.352652808441, "DC5": 2583.456876146125}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [345, 287, 324, 310, 481, 539, 778, 883, 1037, 1367, 1242, 1250, 1135, 1025, 753, 498, 477, 357, 349, 298, 308, 320, 299, 376, 475, 485, 776, 846, 1026, 1409, 1114, 1198, 1256, 958, 709, 523, 465, 415, 374, 272, 283, 295, 375, 350, 500, 532, 605, 966, 1177, 1308, 1141, 1165], "SKU_Premium": [166, 144, 176, 208, 221, 312, 379, 416, 511, 604, 638, 667, 599, 488, 358, 312, 238, 190, 143, 155, 162, 158, 146, 168, 205, 311, 385, 455, 608, 600, 605, 606, 525, 386, 407, 279, 224, 165, 156, 147, 169, 150, 159, 197, 226, 242, 326, 435, 603, 607, 561, 544], "SKU_ShortLife": [121, 115, 145, 156, 148, 232, 311, 390, 394, 511, 448, 437, 499, 358, 272, 240, 180, 167, 122, 125, 106, 126, 111, 138, 190, 186, 312, 408, 404, 539, 458, 540, 475, 314, 316, 218, 158, 141, 119, 125, 115, 126, 142, 143, 179, 223, 306, 414, 483, 496, 443, 427]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 1,006,574.5
|
retail_f1_52_weeks_v4
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_52_weeks
Scenario ID: retail_f1_52_weeks_v4
[BUSINESS DESCRIPTION]
Business narrative:
The retailer plans inventory over a full year of weekly decisions, represented by fifty-two time periods. Exogenous seasonal demand, local inventories at each distribution center, and per-product production capacities work as in the core operations baseline. Customers are never backordered; unmet demand in a week is immediately lost and penalized. The main difference is the extended planning horizon, which tests the ability to manage long-run seasonality and accumulation effects.
Structure cues:
- The inventory system is the same as in retail_f1_base, with multiple products, multiple locations, and capacity-limited production for each product and period.
- The time index now runs for fifty-two periods. The same inventory evolution and demand fulfillment logic is applied in every period of the year.
- At each location and for each product, stock at the end of a week depends on what was carried over, what was produced for that location during the week, and what was sold or discarded. Inventory cannot go below zero; any unmet demand in a week is lost and penalized.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- Substitution: Edge [p_from, p_to] means p_from's demand can be served by p_to's inventory.
Variable sub[p_from, p_to, l, t] = units of p_from's demand fulfilled by p_to.
Demand fulfillment equation:
- For p_from: total_sales[p_from] + sub[p_from, p_to] + L[p_from] = demand[p_from]
- For p_to: total_sales[p_to] - sub[p_from, p_to] + L[p_to] = demand[p_to]
Interpretation: p_from's demand is served by own sales + substitution + lost.
p_to's total sales include serving both its own demand and p_from's demand.
- No transshipment and zero lead times in this scenario.
- Labor capacity remains high enough that it does not materially bind, though it can be represented consistently with the JSON.
- The objective is to minimize total cost over the entire year, aggregating holding, waste, and lost sales costs across all weeks.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_52_weeks_v4", "description": "Standard seasonal retail scenario.", "periods": 52, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3499.737385701882, "DC2": 3365.874638487682, "DC3": 2875.5852152529897, "DC4": 3022.249693724108, "DC5": 2610.05013090868}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [285, 270, 313, 317, 383, 529, 772, 913, 1046, 1281, 1329, 1234, 1081, 866, 801, 582, 487, 395, 362, 315, 301, 306, 368, 369, 458, 501, 808, 849, 1120, 1315, 1419, 1307, 1156, 903, 647, 484, 408, 336, 320, 278, 284, 337, 298, 382, 399, 581, 709, 918, 1023, 1127, 1342, 1281], "SKU_Premium": [158, 149, 150, 179, 201, 289, 334, 448, 525, 641, 715, 641, 523, 472, 329, 238, 236, 178, 184, 136, 155, 169, 177, 157, 186, 295, 342, 415, 555, 528, 726, 711, 485, 393, 373, 283, 230, 176, 180, 155, 168, 132, 155, 156, 212, 277, 388, 476, 485, 611, 737, 572], "SKU_ShortLife": [130, 137, 133, 144, 156, 234, 274, 396, 449, 467, 480, 508, 409, 373, 295, 226, 152, 135, 120, 118, 137, 106, 147, 149, 171, 241, 248, 329, 450, 437, 548, 572, 397, 404, 255, 226, 178, 144, 122, 136, 126, 120, 148, 127, 162, 207, 247, 337, 496, 436, 568, 548]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 1,006,442.5
|
retail_f1_base_v0
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_base
Scenario ID: retail_f1_base_v0
[BUSINESS DESCRIPTION]
Business narrative:
The retailer manages weekly inventory for several products across multiple distribution centers that directly serve final customer demand. Demand for each product at each location is seasonal and exogenous. Products are replenished each period up to a per-product production or procurement capacity, and any demand that is not served immediately in the period is permanently lost and penalized. Customers are never backlogged or promised future delivery. Inventory is held locally at each distribution center, and there is no movement of stock between locations in this archetype.
Structure cues:
- Time is a discrete sequence of periods defined in the JSON. Decisions about how much to produce or procure and how much to ship to each location are made at the beginning of each period; demand is realized and served within that same period.
- Inventory evolves by carrying over what remains from the previous period, adding any new production assigned to the location, and subtracting units that are sold or intentionally discarded as waste. On-hand stock is never allowed to become negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Any demand that cannot be met from available local inventory in the period is treated as lost sales and incurs the lost sales penalty. There is no concept of backorders, reservations, or delayed fulfillment.
- Production for each product in each period cannot exceed the given production capacity. Production is available without delay in this archetype because lead times are effectively zero.
- Storage capacity at each location and period limits the total volume of on-hand inventory using product-specific storage usage coefficients and location capacities from the JSON: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected even in periods where they do not bind.
- Substitution: Edge [p_from, p_to] means p_from's demand can be served by p_to's inventory.
Variable sub[p_from, p_to, l, t] = units of p_from's demand fulfilled by p_to.
Demand fulfillment equation:
- For p_from: total_sales[p_from] + sub[p_from, p_to] + L[p_from] = demand[p_from]
- For p_to: total_sales[p_to] - sub[p_from, p_to] + L[p_to] = demand[p_to]
Interpretation: p_from's demand is served by own sales + substitution + lost.
p_to's total sales include serving both its own demand and p_from's demand.
- There is no transshipment of inventory between locations; each location can only serve its own local demand from its own inventory.
- Labor capacity is set high enough that it does not bind in this archetype, but if labor constraints are included they must be consistent with the JSON parameters.
- The objective is to minimize total cost over the horizon, including inventory holding costs, waste costs, and lost sales penalties. No fixed ordering costs, minimum order quantities, lead times, reverse flows, or global budgets are active here.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_base_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 378,951.5
|
retail_f1_base_v1
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_base
Scenario ID: retail_f1_base_v1
[BUSINESS DESCRIPTION]
Business narrative:
The retailer manages weekly inventory for several products across multiple distribution centers that directly serve final customer demand. Demand for each product at each location is seasonal and exogenous. Products are replenished each period up to a per-product production or procurement capacity, and any demand that is not served immediately in the period is permanently lost and penalized. Customers are never backlogged or promised future delivery. Inventory is held locally at each distribution center, and there is no movement of stock between locations in this archetype.
Structure cues:
- Time is a discrete sequence of periods defined in the JSON. Decisions about how much to produce or procure and how much to ship to each location are made at the beginning of each period; demand is realized and served within that same period.
- Inventory evolves by carrying over what remains from the previous period, adding any new production assigned to the location, and subtracting units that are sold or intentionally discarded as waste. On-hand stock is never allowed to become negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Any demand that cannot be met from available local inventory in the period is treated as lost sales and incurs the lost sales penalty. There is no concept of backorders, reservations, or delayed fulfillment.
- Production for each product in each period cannot exceed the given production capacity. Production is available without delay in this archetype because lead times are effectively zero.
- Storage capacity at each location and period limits the total volume of on-hand inventory using product-specific storage usage coefficients and location capacities from the JSON: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected even in periods where they do not bind.
- Substitution: Edge [p_from, p_to] means p_from's demand can be served by p_to's inventory.
Variable sub[p_from, p_to, l, t] = units of p_from's demand fulfilled by p_to.
Demand fulfillment equation:
- For p_from: total_sales[p_from] + sub[p_from, p_to] + L[p_from] = demand[p_from]
- For p_to: total_sales[p_to] - sub[p_from, p_to] + L[p_to] = demand[p_to]
Interpretation: p_from's demand is served by own sales + substitution + lost.
p_to's total sales include serving both its own demand and p_from's demand.
- There is no transshipment of inventory between locations; each location can only serve its own local demand from its own inventory.
- Labor capacity is set high enough that it does not bind in this archetype, but if labor constraints are included they must be consistent with the JSON parameters.
- The objective is to minimize total cost over the horizon, including inventory holding costs, waste costs, and lost sales penalties. No fixed ordering costs, minimum order quantities, lead times, reverse flows, or global budgets are active here.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_base_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3533.9579113297223, "DC2": 3317.622259031674, "DC3": 2662.2471240015657, "DC4": 2571.1157376641754, "DC5": 2208.3235255734785}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [258, 307, 329, 349, 465, 513, 673, 868, 1079, 1397, 1353, 1185, 945, 825, 787, 516, 420, 330, 329, 307], "SKU_Premium": [150, 151, 166, 207, 245, 312, 372, 392, 582, 679, 639, 681, 559, 387, 338, 302, 191, 198, 179, 165], "SKU_ShortLife": [131, 120, 144, 164, 175, 218, 293, 361, 396, 444, 569, 492, 422, 386, 323, 249, 192, 157, 137, 136]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 379,803
|
retail_f1_base_v2
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_base
Scenario ID: retail_f1_base_v2
[BUSINESS DESCRIPTION]
Business narrative:
The retailer manages weekly inventory for several products across multiple distribution centers that directly serve final customer demand. Demand for each product at each location is seasonal and exogenous. Products are replenished each period up to a per-product production or procurement capacity, and any demand that is not served immediately in the period is permanently lost and penalized. Customers are never backlogged or promised future delivery. Inventory is held locally at each distribution center, and there is no movement of stock between locations in this archetype.
Structure cues:
- Time is a discrete sequence of periods defined in the JSON. Decisions about how much to produce or procure and how much to ship to each location are made at the beginning of each period; demand is realized and served within that same period.
- Inventory evolves by carrying over what remains from the previous period, adding any new production assigned to the location, and subtracting units that are sold or intentionally discarded as waste. On-hand stock is never allowed to become negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Any demand that cannot be met from available local inventory in the period is treated as lost sales and incurs the lost sales penalty. There is no concept of backorders, reservations, or delayed fulfillment.
- Production for each product in each period cannot exceed the given production capacity. Production is available without delay in this archetype because lead times are effectively zero.
- Storage capacity at each location and period limits the total volume of on-hand inventory using product-specific storage usage coefficients and location capacities from the JSON: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected even in periods where they do not bind.
- Substitution: Edge [p_from, p_to] means p_from's demand can be served by p_to's inventory.
Variable sub[p_from, p_to, l, t] = units of p_from's demand fulfilled by p_to.
Demand fulfillment equation:
- For p_from: total_sales[p_from] + sub[p_from, p_to] + L[p_from] = demand[p_from]
- For p_to: total_sales[p_to] - sub[p_from, p_to] + L[p_to] = demand[p_to]
Interpretation: p_from's demand is served by own sales + substitution + lost.
p_to's total sales include serving both its own demand and p_from's demand.
- There is no transshipment of inventory between locations; each location can only serve its own local demand from its own inventory.
- Labor capacity is set high enough that it does not bind in this archetype, but if labor constraints are included they must be consistent with the JSON parameters.
- The objective is to minimize total cost over the horizon, including inventory holding costs, waste costs, and lost sales penalties. No fixed ordering costs, minimum order quantities, lead times, reverse flows, or global budgets are active here.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_base_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4447.5755491154705, "DC2": 2987.5840778008924, "DC3": 3053.895707116281, "DC4": 3109.0834536561856, "DC5": 2396.33602691168}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [316, 341, 356, 411, 415, 593, 780, 888, 1143, 1284, 1406, 1211, 1062, 845, 799, 490, 461, 344, 330, 286], "SKU_Premium": [167, 168, 182, 189, 213, 306, 357, 513, 602, 655, 734, 590, 504, 445, 366, 311, 239, 204, 188, 133], "SKU_ShortLife": [107, 126, 150, 163, 177, 232, 311, 338, 478, 527, 464, 467, 461, 322, 313, 200, 172, 139, 113, 139]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 391,558.5
|
retail_f1_base_v3
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_base
Scenario ID: retail_f1_base_v3
[BUSINESS DESCRIPTION]
Business narrative:
The retailer manages weekly inventory for several products across multiple distribution centers that directly serve final customer demand. Demand for each product at each location is seasonal and exogenous. Products are replenished each period up to a per-product production or procurement capacity, and any demand that is not served immediately in the period is permanently lost and penalized. Customers are never backlogged or promised future delivery. Inventory is held locally at each distribution center, and there is no movement of stock between locations in this archetype.
Structure cues:
- Time is a discrete sequence of periods defined in the JSON. Decisions about how much to produce or procure and how much to ship to each location are made at the beginning of each period; demand is realized and served within that same period.
- Inventory evolves by carrying over what remains from the previous period, adding any new production assigned to the location, and subtracting units that are sold or intentionally discarded as waste. On-hand stock is never allowed to become negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Any demand that cannot be met from available local inventory in the period is treated as lost sales and incurs the lost sales penalty. There is no concept of backorders, reservations, or delayed fulfillment.
- Production for each product in each period cannot exceed the given production capacity. Production is available without delay in this archetype because lead times are effectively zero.
- Storage capacity at each location and period limits the total volume of on-hand inventory using product-specific storage usage coefficients and location capacities from the JSON: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected even in periods where they do not bind.
- Substitution: Edge [p_from, p_to] means p_from's demand can be served by p_to's inventory.
Variable sub[p_from, p_to, l, t] = units of p_from's demand fulfilled by p_to.
Demand fulfillment equation:
- For p_from: total_sales[p_from] + sub[p_from, p_to] + L[p_from] = demand[p_from]
- For p_to: total_sales[p_to] - sub[p_from, p_to] + L[p_to] = demand[p_to]
Interpretation: p_from's demand is served by own sales + substitution + lost.
p_to's total sales include serving both its own demand and p_from's demand.
- There is no transshipment of inventory between locations; each location can only serve its own local demand from its own inventory.
- Labor capacity is set high enough that it does not bind in this archetype, but if labor constraints are included they must be consistent with the JSON parameters.
- The objective is to minimize total cost over the horizon, including inventory holding costs, waste costs, and lost sales penalties. No fixed ordering costs, minimum order quantities, lead times, reverse flows, or global budgets are active here.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_base_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3562.759788915129, "DC2": 3723.1267692084807, "DC3": 2902.8972961960258, "DC4": 2878.3647165557336, "DC5": 2406.5336318774703}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [333, 319, 364, 412, 411, 488, 707, 770, 953, 1277, 1481, 1181, 1026, 808, 783, 512, 478, 392, 289, 313], "SKU_Premium": [158, 175, 152, 185, 199, 260, 371, 485, 600, 551, 655, 577, 488, 491, 346, 309, 223, 205, 153, 164], "SKU_ShortLife": [128, 113, 113, 125, 185, 218, 278, 356, 427, 567, 468, 450, 419, 311, 318, 206, 169, 133, 124, 121]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 370,433.5
|
retail_f1_base_v4
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_base
Scenario ID: retail_f1_base_v4
[BUSINESS DESCRIPTION]
Business narrative:
The retailer manages weekly inventory for several products across multiple distribution centers that directly serve final customer demand. Demand for each product at each location is seasonal and exogenous. Products are replenished each period up to a per-product production or procurement capacity, and any demand that is not served immediately in the period is permanently lost and penalized. Customers are never backlogged or promised future delivery. Inventory is held locally at each distribution center, and there is no movement of stock between locations in this archetype.
Structure cues:
- Time is a discrete sequence of periods defined in the JSON. Decisions about how much to produce or procure and how much to ship to each location are made at the beginning of each period; demand is realized and served within that same period.
- Inventory evolves by carrying over what remains from the previous period, adding any new production assigned to the location, and subtracting units that are sold or intentionally discarded as waste. On-hand stock is never allowed to become negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Any demand that cannot be met from available local inventory in the period is treated as lost sales and incurs the lost sales penalty. There is no concept of backorders, reservations, or delayed fulfillment.
- Production for each product in each period cannot exceed the given production capacity. Production is available without delay in this archetype because lead times are effectively zero.
- Storage capacity at each location and period limits the total volume of on-hand inventory using product-specific storage usage coefficients and location capacities from the JSON: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected even in periods where they do not bind.
- Substitution: Edge [p_from, p_to] means p_from's demand can be served by p_to's inventory.
Variable sub[p_from, p_to, l, t] = units of p_from's demand fulfilled by p_to.
Demand fulfillment equation:
- For p_from: total_sales[p_from] + sub[p_from, p_to] + L[p_from] = demand[p_from]
- For p_to: total_sales[p_to] - sub[p_from, p_to] + L[p_to] = demand[p_to]
Interpretation: p_from's demand is served by own sales + substitution + lost.
p_to's total sales include serving both its own demand and p_from's demand.
- There is no transshipment of inventory between locations; each location can only serve its own local demand from its own inventory.
- Labor capacity is set high enough that it does not bind in this archetype, but if labor constraints are included they must be consistent with the JSON parameters.
- The objective is to minimize total cost over the horizon, including inventory holding costs, waste costs, and lost sales penalties. No fixed ordering costs, minimum order quantities, lead times, reverse flows, or global budgets are active here.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_base_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4177.522809726864, "DC2": 3710.855822151861, "DC3": 2808.537929551953, "DC4": 3211.796405026038, "DC5": 2753.1161453167974}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [268, 294, 341, 377, 427, 537, 806, 772, 1120, 1156, 1485, 1316, 997, 859, 663, 505, 408, 364, 356, 302], "SKU_Premium": [171, 135, 182, 204, 210, 236, 361, 402, 632, 536, 590, 619, 529, 452, 323, 295, 229, 166, 146, 162], "SKU_ShortLife": [121, 116, 119, 156, 190, 236, 271, 368, 484, 505, 553, 452, 376, 324, 322, 195, 177, 124, 132, 136]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 371,353
|
retail_f1_high_waste_v0
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_high_waste
Scenario ID: retail_f1_high_waste_v0
[BUSINESS DESCRIPTION]
Business narrative:
This scenario keeps the same basic single-echelon structure as the core operations baseline but represents categories where waste is extremely expensive, such as highly perishable or sensitive products. The retailer still serves exogenous seasonal demand from local inventories at distribution centers with no transshipment and no backorders. Any units that must be discarded because they are no longer usable incur a much higher penalty than in the baseline, creating strong pressure to avoid overstocking.
Structure cues:
- The network is the same as in retail_f1_base: multiple products, multiple locations that directly serve final demand, and per-product production capacities in each period.
- Inventory is held at each location, evolves from period to period by adding local production and subtracting sales and waste, and is never allowed to go negative. Unserved demand is treated as lost sales and penalized as in the baseline.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution pattern (Basic's demand served by Premium), absence of transshipment, zero lead times, and effectively non-binding labor capacities are the same as in the baseline scenario.
- The only intended structural change is in the cost weights: waste costs in the JSON are much larger, so discarding inventory is heavily discouraged, but the constraint system itself is not altered.
- The objective continues to minimize the sum of holding costs, waste costs, and lost sales penalties over all products, locations, and periods.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_high_waste_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 40.0, "SKU_Premium": 60.0, "SKU_ShortLife": 40.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 378,951.5
|
retail_f1_high_waste_v1
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_high_waste
Scenario ID: retail_f1_high_waste_v1
[BUSINESS DESCRIPTION]
Business narrative:
This scenario keeps the same basic single-echelon structure as the core operations baseline but represents categories where waste is extremely expensive, such as highly perishable or sensitive products. The retailer still serves exogenous seasonal demand from local inventories at distribution centers with no transshipment and no backorders. Any units that must be discarded because they are no longer usable incur a much higher penalty than in the baseline, creating strong pressure to avoid overstocking.
Structure cues:
- The network is the same as in retail_f1_base: multiple products, multiple locations that directly serve final demand, and per-product production capacities in each period.
- Inventory is held at each location, evolves from period to period by adding local production and subtracting sales and waste, and is never allowed to go negative. Unserved demand is treated as lost sales and penalized as in the baseline.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution pattern (Basic's demand served by Premium), absence of transshipment, zero lead times, and effectively non-binding labor capacities are the same as in the baseline scenario.
- The only intended structural change is in the cost weights: waste costs in the JSON are much larger, so discarding inventory is heavily discouraged, but the constraint system itself is not altered.
- The objective continues to minimize the sum of holding costs, waste costs, and lost sales penalties over all products, locations, and periods.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_high_waste_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4374.126676532868, "DC2": 4009.3552443495837, "DC3": 3127.8288463783015, "DC4": 3346.928548537924, "DC5": 2760.3224302412423}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [270, 269, 299, 334, 482, 504, 632, 782, 1058, 1218, 1360, 1352, 1230, 810, 787, 567, 374, 338, 289, 334], "SKU_Premium": [145, 140, 160, 175, 234, 311, 382, 407, 559, 545, 651, 567, 498, 404, 324, 237, 206, 161, 183, 171], "SKU_ShortLife": [107, 135, 134, 154, 178, 220, 246, 367, 485, 429, 556, 499, 405, 403, 265, 217, 197, 163, 135, 112]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 40.0, "SKU_Premium": 60.0, "SKU_ShortLife": 40.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 367,896
|
retail_f1_high_waste_v2
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_high_waste
Scenario ID: retail_f1_high_waste_v2
[BUSINESS DESCRIPTION]
Business narrative:
This scenario keeps the same basic single-echelon structure as the core operations baseline but represents categories where waste is extremely expensive, such as highly perishable or sensitive products. The retailer still serves exogenous seasonal demand from local inventories at distribution centers with no transshipment and no backorders. Any units that must be discarded because they are no longer usable incur a much higher penalty than in the baseline, creating strong pressure to avoid overstocking.
Structure cues:
- The network is the same as in retail_f1_base: multiple products, multiple locations that directly serve final demand, and per-product production capacities in each period.
- Inventory is held at each location, evolves from period to period by adding local production and subtracting sales and waste, and is never allowed to go negative. Unserved demand is treated as lost sales and penalized as in the baseline.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution pattern (Basic's demand served by Premium), absence of transshipment, zero lead times, and effectively non-binding labor capacities are the same as in the baseline scenario.
- The only intended structural change is in the cost weights: waste costs in the JSON are much larger, so discarding inventory is heavily discouraged, but the constraint system itself is not altered.
- The objective continues to minimize the sum of holding costs, waste costs, and lost sales penalties over all products, locations, and periods.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_high_waste_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4239.5437634365735, "DC2": 3281.1772732001004, "DC3": 3309.019640012453, "DC4": 3287.5725035998616, "DC5": 2148.382238669537}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [278, 266, 291, 364, 400, 472, 773, 1023, 1239, 1320, 1122, 1132, 1070, 934, 754, 549, 378, 355, 348, 338], "SKU_Premium": [165, 135, 184, 172, 198, 258, 311, 464, 515, 625, 645, 701, 585, 465, 368, 256, 208, 178, 157, 170], "SKU_ShortLife": [136, 114, 119, 127, 157, 199, 289, 382, 489, 570, 447, 462, 465, 338, 324, 216, 162, 156, 136, 122]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 40.0, "SKU_Premium": 60.0, "SKU_ShortLife": 40.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 379,063
|
retail_f1_high_waste_v3
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_high_waste
Scenario ID: retail_f1_high_waste_v3
[BUSINESS DESCRIPTION]
Business narrative:
This scenario keeps the same basic single-echelon structure as the core operations baseline but represents categories where waste is extremely expensive, such as highly perishable or sensitive products. The retailer still serves exogenous seasonal demand from local inventories at distribution centers with no transshipment and no backorders. Any units that must be discarded because they are no longer usable incur a much higher penalty than in the baseline, creating strong pressure to avoid overstocking.
Structure cues:
- The network is the same as in retail_f1_base: multiple products, multiple locations that directly serve final demand, and per-product production capacities in each period.
- Inventory is held at each location, evolves from period to period by adding local production and subtracting sales and waste, and is never allowed to go negative. Unserved demand is treated as lost sales and penalized as in the baseline.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution pattern (Basic's demand served by Premium), absence of transshipment, zero lead times, and effectively non-binding labor capacities are the same as in the baseline scenario.
- The only intended structural change is in the cost weights: waste costs in the JSON are much larger, so discarding inventory is heavily discouraged, but the constraint system itself is not altered.
- The objective continues to minimize the sum of holding costs, waste costs, and lost sales penalties over all products, locations, and periods.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_high_waste_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4401.3951355135505, "DC2": 3048.001515599564, "DC3": 3055.142380942407, "DC4": 3274.881736277081, "DC5": 2129.7650931970747}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [319, 288, 305, 364, 447, 587, 638, 778, 1105, 1197, 1283, 1219, 1261, 873, 673, 528, 463, 314, 336, 350], "SKU_Premium": [130, 155, 185, 187, 223, 282, 337, 499, 485, 684, 727, 538, 574, 406, 334, 235, 208, 169, 176, 147], "SKU_ShortLife": [121, 135, 114, 132, 172, 222, 322, 388, 455, 453, 518, 546, 483, 371, 301, 207, 194, 139, 133, 126]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 40.0, "SKU_Premium": 60.0, "SKU_ShortLife": 40.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 377,421.5
|
retail_f1_high_waste_v4
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_high_waste
Scenario ID: retail_f1_high_waste_v4
[BUSINESS DESCRIPTION]
Business narrative:
This scenario keeps the same basic single-echelon structure as the core operations baseline but represents categories where waste is extremely expensive, such as highly perishable or sensitive products. The retailer still serves exogenous seasonal demand from local inventories at distribution centers with no transshipment and no backorders. Any units that must be discarded because they are no longer usable incur a much higher penalty than in the baseline, creating strong pressure to avoid overstocking.
Structure cues:
- The network is the same as in retail_f1_base: multiple products, multiple locations that directly serve final demand, and per-product production capacities in each period.
- Inventory is held at each location, evolves from period to period by adding local production and subtracting sales and waste, and is never allowed to go negative. Unserved demand is treated as lost sales and penalized as in the baseline.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution pattern (Basic's demand served by Premium), absence of transshipment, zero lead times, and effectively non-binding labor capacities are the same as in the baseline scenario.
- The only intended structural change is in the cost weights: waste costs in the JSON are much larger, so discarding inventory is heavily discouraged, but the constraint system itself is not altered.
- The objective continues to minimize the sum of holding costs, waste costs, and lost sales penalties over all products, locations, and periods.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_high_waste_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3430.373920082548, "DC2": 3117.199409297448, "DC3": 3249.5025472470406, "DC4": 3171.7893883100883, "DC5": 2551.077956769335}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [262, 292, 343, 318, 463, 621, 802, 881, 1159, 1300, 1128, 1311, 1145, 1022, 667, 619, 484, 329, 279, 281], "SKU_Premium": [172, 140, 172, 181, 221, 267, 396, 481, 483, 665, 646, 685, 501, 500, 329, 270, 209, 176, 171, 142], "SKU_ShortLife": [109, 126, 143, 134, 192, 241, 257, 332, 438, 474, 467, 491, 503, 397, 265, 220, 150, 165, 116, 141]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 40.0, "SKU_Premium": 60.0, "SKU_ShortLife": 40.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 385,802.5
|
retail_f1_jit_logic_v0
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_jit_logic
Scenario ID: retail_f1_jit_logic_v0
[BUSINESS DESCRIPTION]
Business narrative:
This scenario represents a just-in-time regime where holding inventory is very expensive. The retailer still faces exogenous seasonal demand at each location, cannot backorder customers, and has limited per-product production capacity per period. Because holding costs are high, the retailer is incentivized to keep inventories as lean as possible while still avoiding excessive lost sales.
Structure cues:
- The physical network and decision timing are the same as in retail_f1_base: single-echelon, multi-product, multi-location, with local demand and local inventory.
- Inventory at each location carries over from the previous period, is increased by local production that arrives without delay, and is reduced by sales and any intentional waste. Stock levels must remain non-negative, and any demand in excess of available stock is treated as lost sales.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- Substitution behavior (Basic's demand served by Premium), absence of transshipment, and zero lead times all match the baseline archetype.
- Holding cost coefficients in the JSON are scaled up substantially compared with retail_f1_base, making on-hand inventory much more expensive relative to lost sales. The underlying constraint structure is unchanged.
- The objective is to minimize total cost including holding, waste, and lost sales, with the higher holding cost forcing a just-in-time style of operation.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_jit_logic_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 20.0, "SKU_Premium": 30.0, "SKU_ShortLife": 20.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 502,325
|
retail_f1_jit_logic_v1
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_jit_logic
Scenario ID: retail_f1_jit_logic_v1
[BUSINESS DESCRIPTION]
Business narrative:
This scenario represents a just-in-time regime where holding inventory is very expensive. The retailer still faces exogenous seasonal demand at each location, cannot backorder customers, and has limited per-product production capacity per period. Because holding costs are high, the retailer is incentivized to keep inventories as lean as possible while still avoiding excessive lost sales.
Structure cues:
- The physical network and decision timing are the same as in retail_f1_base: single-echelon, multi-product, multi-location, with local demand and local inventory.
- Inventory at each location carries over from the previous period, is increased by local production that arrives without delay, and is reduced by sales and any intentional waste. Stock levels must remain non-negative, and any demand in excess of available stock is treated as lost sales.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- Substitution behavior (Basic's demand served by Premium), absence of transshipment, and zero lead times all match the baseline archetype.
- Holding cost coefficients in the JSON are scaled up substantially compared with retail_f1_base, making on-hand inventory much more expensive relative to lost sales. The underlying constraint structure is unchanged.
- The objective is to minimize total cost including holding, waste, and lost sales, with the higher holding cost forcing a just-in-time style of operation.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_jit_logic_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4227.503985981191, "DC2": 3175.2200216676033, "DC3": 2994.148110462189, "DC4": 3096.259483977715, "DC5": 2402.735217991342}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [309, 303, 337, 340, 452, 609, 663, 844, 1155, 1285, 1418, 1103, 1209, 843, 806, 541, 375, 330, 357, 321], "SKU_Premium": [165, 151, 157, 154, 209, 280, 385, 478, 620, 635, 609, 667, 566, 451, 357, 266, 204, 188, 146, 169], "SKU_ShortLife": [104, 132, 122, 155, 162, 226, 288, 334, 421, 514, 527, 527, 434, 326, 251, 232, 151, 130, 114, 122]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 20.0, "SKU_Premium": 30.0, "SKU_ShortLife": 20.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 516,420
|
retail_f1_jit_logic_v2
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_jit_logic
Scenario ID: retail_f1_jit_logic_v2
[BUSINESS DESCRIPTION]
Business narrative:
This scenario represents a just-in-time regime where holding inventory is very expensive. The retailer still faces exogenous seasonal demand at each location, cannot backorder customers, and has limited per-product production capacity per period. Because holding costs are high, the retailer is incentivized to keep inventories as lean as possible while still avoiding excessive lost sales.
Structure cues:
- The physical network and decision timing are the same as in retail_f1_base: single-echelon, multi-product, multi-location, with local demand and local inventory.
- Inventory at each location carries over from the previous period, is increased by local production that arrives without delay, and is reduced by sales and any intentional waste. Stock levels must remain non-negative, and any demand in excess of available stock is treated as lost sales.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- Substitution behavior (Basic's demand served by Premium), absence of transshipment, and zero lead times all match the baseline archetype.
- Holding cost coefficients in the JSON are scaled up substantially compared with retail_f1_base, making on-hand inventory much more expensive relative to lost sales. The underlying constraint structure is unchanged.
- The objective is to minimize total cost including holding, waste, and lost sales, with the higher holding cost forcing a just-in-time style of operation.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_jit_logic_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4452.650038535987, "DC2": 3413.3710389191046, "DC3": 2793.7486082944533, "DC4": 2591.9222764205074, "DC5": 2357.3241337705263}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [257, 319, 344, 411, 494, 519, 750, 871, 1258, 1264, 1196, 1414, 1086, 927, 638, 584, 419, 392, 323, 350], "SKU_Premium": [171, 137, 187, 206, 247, 247, 376, 386, 471, 639, 647, 604, 615, 474, 329, 293, 199, 175, 174, 147], "SKU_ShortLife": [136, 128, 119, 161, 173, 193, 251, 393, 442, 527, 542, 453, 435, 385, 250, 219, 153, 163, 122, 110]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 20.0, "SKU_Premium": 30.0, "SKU_ShortLife": 20.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 512,565
|
retail_f1_jit_logic_v3
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_jit_logic
Scenario ID: retail_f1_jit_logic_v3
[BUSINESS DESCRIPTION]
Business narrative:
This scenario represents a just-in-time regime where holding inventory is very expensive. The retailer still faces exogenous seasonal demand at each location, cannot backorder customers, and has limited per-product production capacity per period. Because holding costs are high, the retailer is incentivized to keep inventories as lean as possible while still avoiding excessive lost sales.
Structure cues:
- The physical network and decision timing are the same as in retail_f1_base: single-echelon, multi-product, multi-location, with local demand and local inventory.
- Inventory at each location carries over from the previous period, is increased by local production that arrives without delay, and is reduced by sales and any intentional waste. Stock levels must remain non-negative, and any demand in excess of available stock is treated as lost sales.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- Substitution behavior (Basic's demand served by Premium), absence of transshipment, and zero lead times all match the baseline archetype.
- Holding cost coefficients in the JSON are scaled up substantially compared with retail_f1_base, making on-hand inventory much more expensive relative to lost sales. The underlying constraint structure is unchanged.
- The objective is to minimize total cost including holding, waste, and lost sales, with the higher holding cost forcing a just-in-time style of operation.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_jit_logic_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4555.306381840641, "DC2": 3422.9891952366816, "DC3": 3109.676300553904, "DC4": 2978.9533068169394, "DC5": 2419.4473267149483}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [344, 349, 329, 376, 437, 599, 604, 928, 959, 1064, 1163, 1146, 936, 781, 660, 601, 444, 356, 359, 316], "SKU_Premium": [141, 159, 148, 185, 196, 243, 337, 512, 594, 708, 617, 697, 615, 407, 305, 270, 214, 156, 164, 156], "SKU_ShortLife": [115, 110, 140, 147, 196, 239, 250, 348, 415, 531, 550, 536, 454, 310, 271, 249, 173, 153, 115, 125]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 20.0, "SKU_Premium": 30.0, "SKU_ShortLife": 20.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 480,555
|
retail_f1_jit_logic_v4
|
[SCENARIO]
Family: F1 (Core Operations)
Archetype: retail_f1_jit_logic
Scenario ID: retail_f1_jit_logic_v4
[BUSINESS DESCRIPTION]
Business narrative:
This scenario represents a just-in-time regime where holding inventory is very expensive. The retailer still faces exogenous seasonal demand at each location, cannot backorder customers, and has limited per-product production capacity per period. Because holding costs are high, the retailer is incentivized to keep inventories as lean as possible while still avoiding excessive lost sales.
Structure cues:
- The physical network and decision timing are the same as in retail_f1_base: single-echelon, multi-product, multi-location, with local demand and local inventory.
- Inventory at each location carries over from the previous period, is increased by local production that arrives without delay, and is reduced by sales and any intentional waste. Stock levels must remain non-negative, and any demand in excess of available stock is treated as lost sales.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- Substitution behavior (Basic's demand served by Premium), absence of transshipment, and zero lead times all match the baseline archetype.
- Holding cost coefficients in the JSON are scaled up substantially compared with retail_f1_base, making on-hand inventory much more expensive relative to lost sales. The underlying constraint structure is unchanged.
- The objective is to minimize total cost including holding, waste, and lost sales, with the higher holding cost forcing a just-in-time style of operation.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f1_jit_logic_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4360.258165461391, "DC2": 3699.6661096856687, "DC3": 2889.2660497979646, "DC4": 2969.6855695873214, "DC5": 2574.1834181917643}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [311, 267, 330, 395, 470, 548, 738, 853, 1188, 1289, 1443, 1356, 1201, 1034, 811, 496, 393, 338, 300, 356], "SKU_Premium": [149, 171, 173, 167, 239, 293, 363, 470, 617, 591, 571, 714, 569, 499, 302, 261, 235, 200, 153, 133], "SKU_ShortLife": [112, 126, 126, 132, 165, 244, 287, 328, 467, 443, 501, 508, 391, 319, 313, 191, 157, 137, 119, 128]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 20.0, "SKU_Premium": 30.0, "SKU_ShortLife": 20.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 539,060
|
retail_f2_cannibalization_v0
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_cannibalization
Scenario ID: retail_f2_cannibalization_v0
[BUSINESS DESCRIPTION]
Business narrative:
The retailer heavily promotes a low-margin basic product, strongly increasing its demand and making lost sales on that product relatively cheap, while shared storage is tightened. Because all products share limited storage, stocking more of the promoted basic product can displace higher-margin premium and short-life items. Customers can still switch along the substitution pattern in the category, but the promotional focus on the basic product creates cannibalization pressure.
Structure cues:
- The underlying inventory and substitution structure is the same as in retail_f2_circular_sub, with a single-echelon system, shared storage at each location, and a directed substitution graph defined in the JSON.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. The JSON reduces storage capacity, making space more scarce.
- The JSON increases demand for the basic product and reduces its lost sales penalty while keeping higher margins on other items.
- Tight shared storage capacity means that choosing to stock more of the basic product can crowd out premium and short-life items in the warehouse, purely through the capacity and cost parameters.
- Inventory remains non-negative, lost sales capture unsatisfied demand after substitution, and there is still no transshipment or backordering.
- The objective is to minimize total cost, and the cannibalization effect is driven by the interplay of demand, margin, lost sales penalties, and capacity parameters rather than by any change to the model's basic structure.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_cannibalization_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 2000.0, "DC2": 1750.0, "DC3": 1500.0, "DC4": 1500.0, "DC5": 1250.0}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [606, 622, 656, 730, 870, 1098, 1422, 1812, 2200, 2490, 2600, 2490, 2200, 1812, 1422, 1098, 870, 730, 656, 622], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 5.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 362,918.5
|
retail_f2_cannibalization_v1
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_cannibalization
Scenario ID: retail_f2_cannibalization_v1
[BUSINESS DESCRIPTION]
Business narrative:
The retailer heavily promotes a low-margin basic product, strongly increasing its demand and making lost sales on that product relatively cheap, while shared storage is tightened. Because all products share limited storage, stocking more of the promoted basic product can displace higher-margin premium and short-life items. Customers can still switch along the substitution pattern in the category, but the promotional focus on the basic product creates cannibalization pressure.
Structure cues:
- The underlying inventory and substitution structure is the same as in retail_f2_circular_sub, with a single-echelon system, shared storage at each location, and a directed substitution graph defined in the JSON.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. The JSON reduces storage capacity, making space more scarce.
- The JSON increases demand for the basic product and reduces its lost sales penalty while keeping higher margins on other items.
- Tight shared storage capacity means that choosing to stock more of the basic product can crowd out premium and short-life items in the warehouse, purely through the capacity and cost parameters.
- Inventory remains non-negative, lost sales capture unsatisfied demand after substitution, and there is still no transshipment or backordering.
- The objective is to minimize total cost, and the cannibalization effect is driven by the interplay of demand, margin, lost sales penalties, and capacity parameters rather than by any change to the model's basic structure.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_cannibalization_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 1778.8028994099282, "DC2": 1557.6602758218983, "DC3": 1361.536642922949, "DC4": 1531.1222473565335, "DC5": 1338.3709482251743}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [679, 617, 719, 784, 840, 1226, 1249, 1661, 2347, 2751, 2890, 2656, 2361, 1877, 1232, 939, 748, 751, 607, 647], "SKU_Premium": [130, 170, 157, 198, 218, 276, 403, 451, 481, 581, 698, 653, 575, 507, 322, 290, 249, 184, 162, 137], "SKU_ShortLife": [136, 141, 122, 133, 168, 202, 324, 339, 450, 491, 485, 431, 394, 356, 258, 192, 171, 167, 142, 126]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 5.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 367,019
|
retail_f2_cannibalization_v2
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_cannibalization
Scenario ID: retail_f2_cannibalization_v2
[BUSINESS DESCRIPTION]
Business narrative:
The retailer heavily promotes a low-margin basic product, strongly increasing its demand and making lost sales on that product relatively cheap, while shared storage is tightened. Because all products share limited storage, stocking more of the promoted basic product can displace higher-margin premium and short-life items. Customers can still switch along the substitution pattern in the category, but the promotional focus on the basic product creates cannibalization pressure.
Structure cues:
- The underlying inventory and substitution structure is the same as in retail_f2_circular_sub, with a single-echelon system, shared storage at each location, and a directed substitution graph defined in the JSON.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. The JSON reduces storage capacity, making space more scarce.
- The JSON increases demand for the basic product and reduces its lost sales penalty while keeping higher margins on other items.
- Tight shared storage capacity means that choosing to stock more of the basic product can crowd out premium and short-life items in the warehouse, purely through the capacity and cost parameters.
- Inventory remains non-negative, lost sales capture unsatisfied demand after substitution, and there is still no transshipment or backordering.
- The objective is to minimize total cost, and the cannibalization effect is driven by the interplay of demand, margin, lost sales penalties, and capacity parameters rather than by any change to the model's basic structure.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_cannibalization_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 2244.0402236247196, "DC2": 1699.331200549469, "DC3": 1280.5201027175053, "DC4": 1539.7512559729769, "DC5": 1119.0333113901247}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [637, 578, 753, 788, 831, 1253, 1398, 1619, 2460, 2471, 2232, 2120, 2129, 1972, 1595, 1199, 820, 727, 747, 674], "SKU_Premium": [146, 148, 164, 172, 188, 303, 315, 385, 519, 678, 607, 538, 476, 406, 373, 304, 241, 160, 181, 134], "SKU_ShortLife": [111, 127, 125, 148, 175, 223, 312, 372, 387, 516, 525, 563, 455, 359, 268, 186, 172, 157, 116, 110]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 5.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 352,674
|
retail_f2_cannibalization_v3
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_cannibalization
Scenario ID: retail_f2_cannibalization_v3
[BUSINESS DESCRIPTION]
Business narrative:
The retailer heavily promotes a low-margin basic product, strongly increasing its demand and making lost sales on that product relatively cheap, while shared storage is tightened. Because all products share limited storage, stocking more of the promoted basic product can displace higher-margin premium and short-life items. Customers can still switch along the substitution pattern in the category, but the promotional focus on the basic product creates cannibalization pressure.
Structure cues:
- The underlying inventory and substitution structure is the same as in retail_f2_circular_sub, with a single-echelon system, shared storage at each location, and a directed substitution graph defined in the JSON.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. The JSON reduces storage capacity, making space more scarce.
- The JSON increases demand for the basic product and reduces its lost sales penalty while keeping higher margins on other items.
- Tight shared storage capacity means that choosing to stock more of the basic product can crowd out premium and short-life items in the warehouse, purely through the capacity and cost parameters.
- Inventory remains non-negative, lost sales capture unsatisfied demand after substitution, and there is still no transshipment or backordering.
- The objective is to minimize total cost, and the cannibalization effect is driven by the interplay of demand, margin, lost sales penalties, and capacity parameters rather than by any change to the model's basic structure.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_cannibalization_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 2159.267870664336, "DC2": 1947.1171093504597, "DC3": 1484.7541613610883, "DC4": 1517.4769188514363, "DC5": 1359.4549478997042}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [535, 549, 722, 665, 990, 1229, 1406, 1546, 2147, 2418, 2875, 2175, 2027, 1984, 1633, 1129, 843, 777, 672, 646], "SKU_Premium": [136, 175, 175, 178, 201, 279, 407, 473, 489, 641, 569, 563, 506, 437, 325, 306, 220, 192, 168, 141], "SKU_ShortLife": [111, 122, 118, 138, 173, 199, 318, 309, 380, 528, 590, 475, 480, 307, 276, 201, 191, 153, 133, 113]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 5.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 355,445.5
|
retail_f2_cannibalization_v4
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_cannibalization
Scenario ID: retail_f2_cannibalization_v4
[BUSINESS DESCRIPTION]
Business narrative:
The retailer heavily promotes a low-margin basic product, strongly increasing its demand and making lost sales on that product relatively cheap, while shared storage is tightened. Because all products share limited storage, stocking more of the promoted basic product can displace higher-margin premium and short-life items. Customers can still switch along the substitution pattern in the category, but the promotional focus on the basic product creates cannibalization pressure.
Structure cues:
- The underlying inventory and substitution structure is the same as in retail_f2_circular_sub, with a single-echelon system, shared storage at each location, and a directed substitution graph defined in the JSON.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. The JSON reduces storage capacity, making space more scarce.
- The JSON increases demand for the basic product and reduces its lost sales penalty while keeping higher margins on other items.
- Tight shared storage capacity means that choosing to stock more of the basic product can crowd out premium and short-life items in the warehouse, purely through the capacity and cost parameters.
- Inventory remains non-negative, lost sales capture unsatisfied demand after substitution, and there is still no transshipment or backordering.
- The objective is to minimize total cost, and the cannibalization effect is driven by the interplay of demand, margin, lost sales penalties, and capacity parameters rather than by any change to the model's basic structure.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_cannibalization_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 2130.0920075505283, "DC2": 1791.593449254044, "DC3": 1333.4028661526593, "DC4": 1355.7222579803988, "DC5": 1135.6893821866583}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [523, 585, 727, 652, 890, 1034, 1410, 1630, 2505, 2393, 2510, 2326, 2212, 1892, 1553, 1170, 989, 748, 654, 692], "SKU_Premium": [140, 143, 159, 201, 219, 300, 359, 433, 616, 659, 660, 551, 567, 509, 326, 254, 224, 155, 149, 175], "SKU_ShortLife": [115, 107, 122, 153, 182, 226, 291, 349, 377, 552, 527, 425, 481, 414, 304, 248, 196, 155, 143, 106]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 5.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 367,405
|
retail_f2_circular_sub_v0
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_circular_sub
Scenario ID: retail_f2_circular_sub_v0
[BUSINESS DESCRIPTION]
Business narrative:
The retailer offers several products in a category where customers are willing to switch along a circular pattern when their first choice is unavailable. The basic, premium, and short-life products form a directed substitution ring, so demand may move from one item to the next according to that ring. Demand remains exogenous by product and location, and any demand that cannot be satisfied even after considering allowed substitution is treated as a lost sale.
Structure cues:
- The overall structure is still single-echelon inventory with per-product production capacities, local storage, and lost sales when demand is not met.
- Inventory at each location evolves from carried-over stock, new production, sales to customers who originally requested that product, and sales to customers diverted from other products along the substitution ring, minus any discarded units. Inventory must remain non-negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution graph in the JSON defines a directed ring among the products. Each edge [A, B] means A's demand can be served by B's inventory. When demand for product A cannot be fully served from A's own stock, the model may serve part of that demand using B's inventory if edge [A, B] exists.
- Any remaining unmet demand after using all allowed substitutions becomes lost sales with a penalty cost. Customers are not backordered.
- Zero lead times remain in effect, and there is no transshipment between locations.
- The objective is to minimize total cost including holding, waste, and lost sales while respecting the substitution pattern encoded in the JSON.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_circular_sub_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"], ["SKU_Premium", "SKU_ShortLife"], ["SKU_ShortLife", "SKU_Basic"]], "trans_edges": []}}
|
OPTIMAL
| 347,594
|
retail_f2_circular_sub_v1
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_circular_sub
Scenario ID: retail_f2_circular_sub_v1
[BUSINESS DESCRIPTION]
Business narrative:
The retailer offers several products in a category where customers are willing to switch along a circular pattern when their first choice is unavailable. The basic, premium, and short-life products form a directed substitution ring, so demand may move from one item to the next according to that ring. Demand remains exogenous by product and location, and any demand that cannot be satisfied even after considering allowed substitution is treated as a lost sale.
Structure cues:
- The overall structure is still single-echelon inventory with per-product production capacities, local storage, and lost sales when demand is not met.
- Inventory at each location evolves from carried-over stock, new production, sales to customers who originally requested that product, and sales to customers diverted from other products along the substitution ring, minus any discarded units. Inventory must remain non-negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution graph in the JSON defines a directed ring among the products. Each edge [A, B] means A's demand can be served by B's inventory. When demand for product A cannot be fully served from A's own stock, the model may serve part of that demand using B's inventory if edge [A, B] exists.
- Any remaining unmet demand after using all allowed substitutions becomes lost sales with a penalty cost. Customers are not backordered.
- Zero lead times remain in effect, and there is no transshipment between locations.
- The objective is to minimize total cost including holding, waste, and lost sales while respecting the substitution pattern encoded in the JSON.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_circular_sub_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4588.825236933483, "DC2": 3817.8607505060004, "DC3": 2852.2628502006805, "DC4": 2899.198618699413, "DC5": 2452.806717338397}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [313, 357, 297, 409, 475, 623, 790, 860, 1244, 1356, 1168, 1093, 978, 1028, 720, 553, 412, 344, 319, 299], "SKU_Premium": [141, 157, 165, 207, 219, 269, 374, 432, 505, 575, 697, 620, 517, 481, 371, 295, 215, 200, 169, 175], "SKU_ShortLife": [119, 129, 125, 151, 184, 221, 316, 368, 396, 508, 446, 554, 395, 359, 248, 245, 148, 132, 149, 130]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"], ["SKU_Premium", "SKU_ShortLife"], ["SKU_ShortLife", "SKU_Basic"]], "trans_edges": []}}
|
OPTIMAL
| 348,252
|
retail_f2_circular_sub_v2
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_circular_sub
Scenario ID: retail_f2_circular_sub_v2
[BUSINESS DESCRIPTION]
Business narrative:
The retailer offers several products in a category where customers are willing to switch along a circular pattern when their first choice is unavailable. The basic, premium, and short-life products form a directed substitution ring, so demand may move from one item to the next according to that ring. Demand remains exogenous by product and location, and any demand that cannot be satisfied even after considering allowed substitution is treated as a lost sale.
Structure cues:
- The overall structure is still single-echelon inventory with per-product production capacities, local storage, and lost sales when demand is not met.
- Inventory at each location evolves from carried-over stock, new production, sales to customers who originally requested that product, and sales to customers diverted from other products along the substitution ring, minus any discarded units. Inventory must remain non-negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution graph in the JSON defines a directed ring among the products. Each edge [A, B] means A's demand can be served by B's inventory. When demand for product A cannot be fully served from A's own stock, the model may serve part of that demand using B's inventory if edge [A, B] exists.
- Any remaining unmet demand after using all allowed substitutions becomes lost sales with a penalty cost. Customers are not backordered.
- Zero lead times remain in effect, and there is no transshipment between locations.
- The objective is to minimize total cost including holding, waste, and lost sales while respecting the substitution pattern encoded in the JSON.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_circular_sub_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3858.821627833047, "DC2": 3199.8547138582135, "DC3": 2943.8767327995683, "DC4": 2602.832055899518, "DC5": 2698.77770496729}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [321, 334, 299, 344, 434, 585, 623, 786, 1156, 1325, 1356, 1360, 963, 873, 680, 547, 443, 321, 360, 273], "SKU_Premium": [138, 155, 172, 208, 200, 300, 393, 470, 532, 613, 633, 551, 544, 446, 330, 283, 243, 205, 152, 176], "SKU_ShortLife": [109, 126, 136, 148, 192, 195, 266, 345, 385, 547, 517, 464, 468, 361, 265, 199, 170, 127, 121, 139]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"], ["SKU_Premium", "SKU_ShortLife"], ["SKU_ShortLife", "SKU_Basic"]], "trans_edges": []}}
|
OPTIMAL
| 342,916
|
retail_f2_circular_sub_v3
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_circular_sub
Scenario ID: retail_f2_circular_sub_v3
[BUSINESS DESCRIPTION]
Business narrative:
The retailer offers several products in a category where customers are willing to switch along a circular pattern when their first choice is unavailable. The basic, premium, and short-life products form a directed substitution ring, so demand may move from one item to the next according to that ring. Demand remains exogenous by product and location, and any demand that cannot be satisfied even after considering allowed substitution is treated as a lost sale.
Structure cues:
- The overall structure is still single-echelon inventory with per-product production capacities, local storage, and lost sales when demand is not met.
- Inventory at each location evolves from carried-over stock, new production, sales to customers who originally requested that product, and sales to customers diverted from other products along the substitution ring, minus any discarded units. Inventory must remain non-negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution graph in the JSON defines a directed ring among the products. Each edge [A, B] means A's demand can be served by B's inventory. When demand for product A cannot be fully served from A's own stock, the model may serve part of that demand using B's inventory if edge [A, B] exists.
- Any remaining unmet demand after using all allowed substitutions becomes lost sales with a penalty cost. Customers are not backordered.
- Zero lead times remain in effect, and there is no transshipment between locations.
- The objective is to minimize total cost including holding, waste, and lost sales while respecting the substitution pattern encoded in the JSON.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_circular_sub_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3462.23662947628, "DC2": 3989.713994899447, "DC3": 2795.6840758104636, "DC4": 3207.3520166764847, "DC5": 2480.6254358169203}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [335, 266, 286, 316, 491, 531, 796, 901, 1064, 1362, 1300, 1214, 1029, 844, 792, 572, 495, 398, 281, 316], "SKU_Premium": [157, 170, 143, 202, 246, 258, 402, 444, 622, 591, 666, 699, 569, 474, 328, 255, 243, 168, 181, 159], "SKU_ShortLife": [132, 113, 116, 127, 152, 238, 297, 312, 399, 487, 471, 555, 409, 311, 246, 212, 170, 142, 135, 141]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"], ["SKU_Premium", "SKU_ShortLife"], ["SKU_ShortLife", "SKU_Basic"]], "trans_edges": []}}
|
OPTIMAL
| 348,595
|
retail_f2_circular_sub_v4
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_circular_sub
Scenario ID: retail_f2_circular_sub_v4
[BUSINESS DESCRIPTION]
Business narrative:
The retailer offers several products in a category where customers are willing to switch along a circular pattern when their first choice is unavailable. The basic, premium, and short-life products form a directed substitution ring, so demand may move from one item to the next according to that ring. Demand remains exogenous by product and location, and any demand that cannot be satisfied even after considering allowed substitution is treated as a lost sale.
Structure cues:
- The overall structure is still single-echelon inventory with per-product production capacities, local storage, and lost sales when demand is not met.
- Inventory at each location evolves from carried-over stock, new production, sales to customers who originally requested that product, and sales to customers diverted from other products along the substitution ring, minus any discarded units. Inventory must remain non-negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution graph in the JSON defines a directed ring among the products. Each edge [A, B] means A's demand can be served by B's inventory. When demand for product A cannot be fully served from A's own stock, the model may serve part of that demand using B's inventory if edge [A, B] exists.
- Any remaining unmet demand after using all allowed substitutions becomes lost sales with a penalty cost. Customers are not backordered.
- Zero lead times remain in effect, and there is no transshipment between locations.
- The objective is to minimize total cost including holding, waste, and lost sales while respecting the substitution pattern encoded in the JSON.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_circular_sub_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3752.9461758346024, "DC2": 3737.14604169585, "DC3": 3124.3037966979764, "DC4": 3111.6473701379737, "DC5": 2173.22913323354}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [290, 310, 376, 355, 459, 606, 635, 976, 1032, 1261, 1213, 1316, 992, 949, 668, 499, 463, 364, 350, 350], "SKU_Premium": [129, 172, 147, 182, 241, 282, 323, 481, 549, 606, 720, 564, 501, 438, 319, 267, 199, 173, 155, 156], "SKU_ShortLife": [104, 124, 125, 148, 183, 240, 308, 374, 497, 509, 558, 475, 443, 376, 317, 214, 199, 129, 150, 106]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"], ["SKU_Premium", "SKU_ShortLife"], ["SKU_ShortLife", "SKU_Basic"]], "trans_edges": []}}
|
OPTIMAL
| 346,881
|
retail_f2_no_substitution_v0
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_no_substitution
Scenario ID: retail_f2_no_substitution_v0
[BUSINESS DESCRIPTION]
Business narrative:
The retailer manages multiple products that do not substitute for each other. Customers either buy the specific product they requested or, if it is unavailable, do not purchase anything and generate a lost sale. Demand for each product at each location is exogenous and seasonal. Inventory is held locally with no transshipment and no backorders, and there is no cross-product switching under any circumstances.
Structure cues:
- The physical setup matches retail_f1_base: single-echelon, multi-product, multi-location, with inventory held only at the locations that serve final demand.
- Inventory at each location and period starts from the previous period's ending stock, is increased by local production or procurement, and is decreased by sales and waste. Stock cannot become negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In this archetype, the substitution graph in the JSON is empty (sub_edges = []). The model must not allow demand for one product to be satisfied by any other product; each product's demand can only be met by its own on-hand inventory at that location.
- There is no transshipment of inventory between locations, lead times are effectively zero, and labor capacity is large relative to demand.
- The objective is to minimize total cost including holding, waste, and lost sales without any cross-product substitution logic.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_no_substitution_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [], "trans_edges": []}}
|
OPTIMAL
| 378,951.5
|
retail_f2_no_substitution_v1
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_no_substitution
Scenario ID: retail_f2_no_substitution_v1
[BUSINESS DESCRIPTION]
Business narrative:
The retailer manages multiple products that do not substitute for each other. Customers either buy the specific product they requested or, if it is unavailable, do not purchase anything and generate a lost sale. Demand for each product at each location is exogenous and seasonal. Inventory is held locally with no transshipment and no backorders, and there is no cross-product switching under any circumstances.
Structure cues:
- The physical setup matches retail_f1_base: single-echelon, multi-product, multi-location, with inventory held only at the locations that serve final demand.
- Inventory at each location and period starts from the previous period's ending stock, is increased by local production or procurement, and is decreased by sales and waste. Stock cannot become negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In this archetype, the substitution graph in the JSON is empty (sub_edges = []). The model must not allow demand for one product to be satisfied by any other product; each product's demand can only be met by its own on-hand inventory at that location.
- There is no transshipment of inventory between locations, lead times are effectively zero, and labor capacity is large relative to demand.
- The objective is to minimize total cost including holding, waste, and lost sales without any cross-product substitution logic.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_no_substitution_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4594.849055105259, "DC2": 3369.1125228697274, "DC3": 2560.8368277444156, "DC4": 3331.2426314946406, "DC5": 2646.2119480166125}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [296, 352, 309, 344, 475, 612, 693, 883, 1007, 1214, 1427, 1157, 1103, 936, 785, 579, 391, 379, 279, 310], "SKU_Premium": [139, 150, 147, 172, 241, 283, 344, 518, 573, 635, 741, 639, 628, 519, 365, 268, 194, 195, 180, 169], "SKU_ShortLife": [137, 138, 139, 164, 154, 218, 303, 361, 396, 542, 510, 565, 420, 408, 281, 197, 190, 154, 114, 136]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [], "trans_edges": []}}
|
OPTIMAL
| 399,083.5
|
retail_f2_no_substitution_v2
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_no_substitution
Scenario ID: retail_f2_no_substitution_v2
[BUSINESS DESCRIPTION]
Business narrative:
The retailer manages multiple products that do not substitute for each other. Customers either buy the specific product they requested or, if it is unavailable, do not purchase anything and generate a lost sale. Demand for each product at each location is exogenous and seasonal. Inventory is held locally with no transshipment and no backorders, and there is no cross-product switching under any circumstances.
Structure cues:
- The physical setup matches retail_f1_base: single-echelon, multi-product, multi-location, with inventory held only at the locations that serve final demand.
- Inventory at each location and period starts from the previous period's ending stock, is increased by local production or procurement, and is decreased by sales and waste. Stock cannot become negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In this archetype, the substitution graph in the JSON is empty (sub_edges = []). The model must not allow demand for one product to be satisfied by any other product; each product's demand can only be met by its own on-hand inventory at that location.
- There is no transshipment of inventory between locations, lead times are effectively zero, and labor capacity is large relative to demand.
- The objective is to minimize total cost including holding, waste, and lost sales without any cross-product substitution logic.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_no_substitution_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4530.2463124172755, "DC2": 3341.4403177853974, "DC3": 3248.8934776584942, "DC4": 3310.1763863048486, "DC5": 2569.5986589116396}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [319, 314, 321, 339, 438, 605, 789, 770, 1102, 1069, 1217, 1130, 977, 923, 681, 492, 488, 317, 286, 308], "SKU_Premium": [134, 157, 162, 181, 240, 309, 381, 460, 584, 614, 613, 649, 624, 398, 317, 295, 209, 190, 149, 158], "SKU_ShortLife": [109, 113, 126, 129, 189, 241, 260, 394, 427, 536, 576, 489, 435, 395, 276, 206, 154, 167, 147, 127]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [], "trans_edges": []}}
|
OPTIMAL
| 372,422
|
retail_f2_no_substitution_v3
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_no_substitution
Scenario ID: retail_f2_no_substitution_v3
[BUSINESS DESCRIPTION]
Business narrative:
The retailer manages multiple products that do not substitute for each other. Customers either buy the specific product they requested or, if it is unavailable, do not purchase anything and generate a lost sale. Demand for each product at each location is exogenous and seasonal. Inventory is held locally with no transshipment and no backorders, and there is no cross-product switching under any circumstances.
Structure cues:
- The physical setup matches retail_f1_base: single-echelon, multi-product, multi-location, with inventory held only at the locations that serve final demand.
- Inventory at each location and period starts from the previous period's ending stock, is increased by local production or procurement, and is decreased by sales and waste. Stock cannot become negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In this archetype, the substitution graph in the JSON is empty (sub_edges = []). The model must not allow demand for one product to be satisfied by any other product; each product's demand can only be met by its own on-hand inventory at that location.
- There is no transshipment of inventory between locations, lead times are effectively zero, and labor capacity is large relative to demand.
- The objective is to minimize total cost including holding, waste, and lost sales without any cross-product substitution logic.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_no_substitution_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4143.868514996318, "DC2": 3121.3812599787016, "DC3": 2980.2287652786576, "DC4": 2779.593856611721, "DC5": 2461.964259537608}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [299, 333, 366, 373, 468, 583, 802, 1016, 1165, 1333, 1189, 1413, 1235, 988, 649, 601, 384, 316, 316, 280], "SKU_Premium": [128, 138, 166, 192, 187, 296, 393, 509, 593, 623, 717, 582, 553, 435, 370, 239, 239, 180, 152, 164], "SKU_ShortLife": [134, 139, 140, 132, 157, 230, 290, 384, 379, 571, 525, 509, 429, 376, 319, 200, 150, 142, 150, 108]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [], "trans_edges": []}}
|
OPTIMAL
| 406,316.5
|
retail_f2_no_substitution_v4
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_no_substitution
Scenario ID: retail_f2_no_substitution_v4
[BUSINESS DESCRIPTION]
Business narrative:
The retailer manages multiple products that do not substitute for each other. Customers either buy the specific product they requested or, if it is unavailable, do not purchase anything and generate a lost sale. Demand for each product at each location is exogenous and seasonal. Inventory is held locally with no transshipment and no backorders, and there is no cross-product switching under any circumstances.
Structure cues:
- The physical setup matches retail_f1_base: single-echelon, multi-product, multi-location, with inventory held only at the locations that serve final demand.
- Inventory at each location and period starts from the previous period's ending stock, is increased by local production or procurement, and is decreased by sales and waste. Stock cannot become negative.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In this archetype, the substitution graph in the JSON is empty (sub_edges = []). The model must not allow demand for one product to be satisfied by any other product; each product's demand can only be met by its own on-hand inventory at that location.
- There is no transshipment of inventory between locations, lead times are effectively zero, and labor capacity is large relative to demand.
- The objective is to minimize total cost including holding, waste, and lost sales without any cross-product substitution logic.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_no_substitution_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4260.278490066865, "DC2": 3315.338938753029, "DC3": 2883.82686409195, "DC4": 2886.8885213083827, "DC5": 2143.9514310524273}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [291, 356, 279, 378, 388, 548, 777, 895, 1003, 1302, 1129, 1319, 1202, 958, 775, 500, 411, 357, 330, 311], "SKU_Premium": [129, 163, 180, 183, 207, 293, 339, 511, 614, 684, 670, 679, 477, 495, 319, 266, 239, 168, 154, 141], "SKU_ShortLife": [103, 118, 143, 145, 161, 203, 280, 350, 472, 539, 537, 467, 379, 348, 254, 235, 175, 143, 144, 111]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [], "trans_edges": []}}
|
OPTIMAL
| 385,892
|
retail_f2_price_band_tight_v0
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_price_band_tight
Scenario ID: retail_f2_price_band_tight_v0
[BUSINESS DESCRIPTION]
Business narrative:
The retailer operates a category with a value-oriented basic product and a premium product that are sold under tight price bands and margin trade-offs. Premium carries higher effective margin and stricter implicit service expectations, while basic is cheaper but more price sensitive. When Basic inventory is insufficient, Basic's demand can be served by Premium (upward substitution); the reverse does not occur. Unmet demand after this limited upgrade behavior is lost and penalized.
Structure cues:
- The physical and inventory structure follows the same pattern as in retail_f1_base: single-echelon, local demand, local inventory, shared storage, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution graph contains a single directed edge [Basic, Premium]. This means: when Basic inventory is insufficient, Premium inventory can serve Basic's demand. S[Basic, Premium] represents units of Basic's demand fulfilled by Premium.
- Lost sales penalties and purchasing or production costs in the JSON make premium more valuable to protect and basic cheaper but more elastic. This asymmetry is expressed through cost parameters, not through any special-case constraints.
- Inventory remains non-negative; any demand that cannot be satisfied even after allowing the basic-to-premium substitution is recorded as lost sales.
- There is no transshipment, lead times are effectively zero, and labor capacity is non-binding.
- The objective is to minimize total cost including holding, waste, and lost sales while respecting the one-way substitution rule and storage capacity limits.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_price_band_tight_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 160.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 11.0, "SKU_Premium": 16.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 365,474.5
|
retail_f2_price_band_tight_v1
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_price_band_tight
Scenario ID: retail_f2_price_band_tight_v1
[BUSINESS DESCRIPTION]
Business narrative:
The retailer operates a category with a value-oriented basic product and a premium product that are sold under tight price bands and margin trade-offs. Premium carries higher effective margin and stricter implicit service expectations, while basic is cheaper but more price sensitive. When Basic inventory is insufficient, Basic's demand can be served by Premium (upward substitution); the reverse does not occur. Unmet demand after this limited upgrade behavior is lost and penalized.
Structure cues:
- The physical and inventory structure follows the same pattern as in retail_f1_base: single-echelon, local demand, local inventory, shared storage, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution graph contains a single directed edge [Basic, Premium]. This means: when Basic inventory is insufficient, Premium inventory can serve Basic's demand. S[Basic, Premium] represents units of Basic's demand fulfilled by Premium.
- Lost sales penalties and purchasing or production costs in the JSON make premium more valuable to protect and basic cheaper but more elastic. This asymmetry is expressed through cost parameters, not through any special-case constraints.
- Inventory remains non-negative; any demand that cannot be satisfied even after allowing the basic-to-premium substitution is recorded as lost sales.
- There is no transshipment, lead times are effectively zero, and labor capacity is non-binding.
- The objective is to minimize total cost including holding, waste, and lost sales while respecting the one-way substitution rule and storage capacity limits.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_price_band_tight_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4445.6810643573535, "DC2": 3521.2582938498463, "DC3": 3047.593282264405, "DC4": 3344.9192979551704, "DC5": 2461.136827380781}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [305, 326, 367, 350, 463, 494, 740, 928, 1208, 1359, 1386, 1166, 1066, 827, 782, 512, 460, 321, 350, 280], "SKU_Premium": [144, 162, 139, 189, 187, 273, 371, 504, 572, 712, 649, 546, 498, 399, 331, 279, 218, 169, 158, 159], "SKU_ShortLife": [138, 132, 137, 130, 185, 237, 322, 366, 471, 451, 509, 532, 442, 387, 295, 242, 182, 155, 148, 139]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 160.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 11.0, "SKU_Premium": 16.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 368,586
|
retail_f2_price_band_tight_v2
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_price_band_tight
Scenario ID: retail_f2_price_band_tight_v2
[BUSINESS DESCRIPTION]
Business narrative:
The retailer operates a category with a value-oriented basic product and a premium product that are sold under tight price bands and margin trade-offs. Premium carries higher effective margin and stricter implicit service expectations, while basic is cheaper but more price sensitive. When Basic inventory is insufficient, Basic's demand can be served by Premium (upward substitution); the reverse does not occur. Unmet demand after this limited upgrade behavior is lost and penalized.
Structure cues:
- The physical and inventory structure follows the same pattern as in retail_f1_base: single-echelon, local demand, local inventory, shared storage, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution graph contains a single directed edge [Basic, Premium]. This means: when Basic inventory is insufficient, Premium inventory can serve Basic's demand. S[Basic, Premium] represents units of Basic's demand fulfilled by Premium.
- Lost sales penalties and purchasing or production costs in the JSON make premium more valuable to protect and basic cheaper but more elastic. This asymmetry is expressed through cost parameters, not through any special-case constraints.
- Inventory remains non-negative; any demand that cannot be satisfied even after allowing the basic-to-premium substitution is recorded as lost sales.
- There is no transshipment, lead times are effectively zero, and labor capacity is non-binding.
- The objective is to minimize total cost including holding, waste, and lost sales while respecting the one-way substitution rule and storage capacity limits.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_price_band_tight_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4428.925839469926, "DC2": 3413.0724185973922, "DC3": 2931.031094470947, "DC4": 3023.386533565639, "DC5": 2749.119772107613}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [347, 352, 355, 403, 474, 498, 748, 890, 1002, 1422, 1276, 1334, 1129, 878, 767, 531, 376, 341, 289, 285], "SKU_Premium": [165, 138, 180, 186, 248, 301, 407, 434, 625, 665, 693, 606, 485, 516, 393, 274, 209, 173, 164, 168], "SKU_ShortLife": [124, 138, 115, 140, 196, 188, 250, 399, 456, 568, 552, 538, 392, 362, 293, 190, 187, 150, 143, 131]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 160.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 11.0, "SKU_Premium": 16.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 384,738.5
|
retail_f2_price_band_tight_v3
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_price_band_tight
Scenario ID: retail_f2_price_band_tight_v3
[BUSINESS DESCRIPTION]
Business narrative:
The retailer operates a category with a value-oriented basic product and a premium product that are sold under tight price bands and margin trade-offs. Premium carries higher effective margin and stricter implicit service expectations, while basic is cheaper but more price sensitive. When Basic inventory is insufficient, Basic's demand can be served by Premium (upward substitution); the reverse does not occur. Unmet demand after this limited upgrade behavior is lost and penalized.
Structure cues:
- The physical and inventory structure follows the same pattern as in retail_f1_base: single-echelon, local demand, local inventory, shared storage, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution graph contains a single directed edge [Basic, Premium]. This means: when Basic inventory is insufficient, Premium inventory can serve Basic's demand. S[Basic, Premium] represents units of Basic's demand fulfilled by Premium.
- Lost sales penalties and purchasing or production costs in the JSON make premium more valuable to protect and basic cheaper but more elastic. This asymmetry is expressed through cost parameters, not through any special-case constraints.
- Inventory remains non-negative; any demand that cannot be satisfied even after allowing the basic-to-premium substitution is recorded as lost sales.
- There is no transshipment, lead times are effectively zero, and labor capacity is non-binding.
- The objective is to minimize total cost including holding, waste, and lost sales while respecting the one-way substitution rule and storage capacity limits.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_price_band_tight_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3426.851027013356, "DC2": 4014.3338689418874, "DC3": 2845.2151192755423, "DC4": 2932.70194359208, "DC5": 2291.9453290268225}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [304, 290, 361, 363, 493, 483, 660, 998, 1122, 1147, 1224, 1151, 1115, 859, 696, 610, 386, 344, 301, 328], "SKU_Premium": [148, 141, 175, 169, 216, 236, 345, 475, 600, 613, 716, 702, 477, 425, 402, 288, 211, 191, 164, 161], "SKU_ShortLife": [135, 128, 132, 139, 148, 189, 295, 380, 420, 508, 520, 445, 436, 376, 273, 216, 183, 167, 150, 106]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 160.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 11.0, "SKU_Premium": 16.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 361,787.5
|
retail_f2_price_band_tight_v4
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_price_band_tight
Scenario ID: retail_f2_price_band_tight_v4
[BUSINESS DESCRIPTION]
Business narrative:
The retailer operates a category with a value-oriented basic product and a premium product that are sold under tight price bands and margin trade-offs. Premium carries higher effective margin and stricter implicit service expectations, while basic is cheaper but more price sensitive. When Basic inventory is insufficient, Basic's demand can be served by Premium (upward substitution); the reverse does not occur. Unmet demand after this limited upgrade behavior is lost and penalized.
Structure cues:
- The physical and inventory structure follows the same pattern as in retail_f1_base: single-echelon, local demand, local inventory, shared storage, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- The substitution graph contains a single directed edge [Basic, Premium]. This means: when Basic inventory is insufficient, Premium inventory can serve Basic's demand. S[Basic, Premium] represents units of Basic's demand fulfilled by Premium.
- Lost sales penalties and purchasing or production costs in the JSON make premium more valuable to protect and basic cheaper but more elastic. This asymmetry is expressed through cost parameters, not through any special-case constraints.
- Inventory remains non-negative; any demand that cannot be satisfied even after allowing the basic-to-premium substitution is recorded as lost sales.
- There is no transshipment, lead times are effectively zero, and labor capacity is non-binding.
- The objective is to minimize total cost including holding, waste, and lost sales while respecting the one-way substitution rule and storage capacity limits.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_price_band_tight_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3427.627149702561, "DC2": 3132.062723953799, "DC3": 2714.118544653094, "DC4": 2672.4786538885255, "DC5": 2561.026704650092}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [268, 313, 345, 390, 442, 479, 785, 905, 1015, 1418, 1200, 1223, 1032, 835, 733, 542, 378, 393, 332, 298], "SKU_Premium": [130, 163, 173, 156, 210, 304, 341, 473, 564, 547, 575, 563, 627, 514, 332, 304, 203, 158, 165, 164], "SKU_ShortLife": [124, 126, 148, 156, 193, 209, 319, 336, 492, 554, 555, 527, 403, 310, 307, 196, 190, 162, 119, 122]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 160.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 11.0, "SKU_Premium": 16.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 362,825
|
retail_f2_promo_budget_v0
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_promo_budget
Scenario ID: retail_f2_promo_budget_v0
[BUSINESS DESCRIPTION]
Business narrative:
In the final periods of the horizon the retailer runs strong promotions on the basic and short-life products, causing their demand to spike. At the same time, an open-to-buy style budget limits how much can be spent in each period on inventory-related activities. The retailer must allocate inventory and spending over time so that promotion-induced demand is supported as well as possible without violating the budget caps.
Structure cues:
- The inventory and substitution structure is the usual single-echelon system with shared storage, production capacity, and a substitution graph, together with lost sales for unmet demand.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the last few periods, the JSON scales up demand for the basic and short-life products to represent promotion-induced lifts; these are treated as ordinary exogenous demands with larger magnitudes.
- The JSON also provides a per-period budget for inventory-related spending. For each period, the total purchasing spend (order quantity times purchasing cost) plus any fixed ordering costs if enabled must not exceed this budget.
- Inventory remains non-negative, and any demand that cannot be satisfied within the budget and capacity limits becomes lost sales.
- Substitution behavior, zero lead times, and generous labor capacity remain active as in other Family 2 archetypes.
- The objective is to minimize total cost subject to the per-period budget, making the trade-off between promotion support and resource limits explicit.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_promo_budget_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 870, 730, 656, 622], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 348, 292, 262, 248]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": 15000.0, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 539,902.33
|
retail_f2_promo_budget_v1
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_promo_budget
Scenario ID: retail_f2_promo_budget_v1
[BUSINESS DESCRIPTION]
Business narrative:
In the final periods of the horizon the retailer runs strong promotions on the basic and short-life products, causing their demand to spike. At the same time, an open-to-buy style budget limits how much can be spent in each period on inventory-related activities. The retailer must allocate inventory and spending over time so that promotion-induced demand is supported as well as possible without violating the budget caps.
Structure cues:
- The inventory and substitution structure is the usual single-echelon system with shared storage, production capacity, and a substitution graph, together with lost sales for unmet demand.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the last few periods, the JSON scales up demand for the basic and short-life products to represent promotion-induced lifts; these are treated as ordinary exogenous demands with larger magnitudes.
- The JSON also provides a per-period budget for inventory-related spending. For each period, the total purchasing spend (order quantity times purchasing cost) plus any fixed ordering costs if enabled must not exceed this budget.
- Inventory remains non-negative, and any demand that cannot be satisfied within the budget and capacity limits becomes lost sales.
- Substitution behavior, zero lead times, and generous labor capacity remain active as in other Family 2 archetypes.
- The objective is to minimize total cost subject to the per-period budget, making the trade-off between promotion support and resource limits explicit.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_promo_budget_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3927.796111686252, "DC2": 3664.3480700069595, "DC3": 3239.291492965392, "DC4": 2648.7276547218867, "DC5": 2359.990813239097}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [341, 318, 355, 415, 497, 597, 775, 919, 1074, 1120, 1295, 1237, 1122, 796, 657, 544, 811, 822, 584, 534], "SKU_Premium": [155, 163, 151, 205, 211, 261, 340, 397, 515, 681, 670, 589, 531, 401, 377, 256, 208, 174, 143, 157], "SKU_ShortLife": [107, 115, 127, 167, 168, 245, 249, 392, 380, 559, 481, 493, 455, 348, 277, 245, 314, 250, 230, 239]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": 15000.0, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 522,743.92
|
retail_f2_promo_budget_v2
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_promo_budget
Scenario ID: retail_f2_promo_budget_v2
[BUSINESS DESCRIPTION]
Business narrative:
In the final periods of the horizon the retailer runs strong promotions on the basic and short-life products, causing their demand to spike. At the same time, an open-to-buy style budget limits how much can be spent in each period on inventory-related activities. The retailer must allocate inventory and spending over time so that promotion-induced demand is supported as well as possible without violating the budget caps.
Structure cues:
- The inventory and substitution structure is the usual single-echelon system with shared storage, production capacity, and a substitution graph, together with lost sales for unmet demand.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the last few periods, the JSON scales up demand for the basic and short-life products to represent promotion-induced lifts; these are treated as ordinary exogenous demands with larger magnitudes.
- The JSON also provides a per-period budget for inventory-related spending. For each period, the total purchasing spend (order quantity times purchasing cost) plus any fixed ordering costs if enabled must not exceed this budget.
- Inventory remains non-negative, and any demand that cannot be satisfied within the budget and capacity limits becomes lost sales.
- Substitution behavior, zero lead times, and generous labor capacity remain active as in other Family 2 archetypes.
- The objective is to minimize total cost subject to the per-period budget, making the trade-off between promotion support and resource limits explicit.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_promo_budget_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3514.0049602177187, "DC2": 2978.815548884458, "DC3": 3270.184260527497, "DC4": 3141.730615435521, "DC5": 2678.8726331690727}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [267, 279, 356, 417, 462, 581, 661, 939, 1182, 1233, 1321, 1426, 1082, 929, 749, 543, 956, 812, 721, 692], "SKU_Premium": [163, 158, 167, 160, 197, 245, 310, 520, 518, 616, 583, 548, 477, 510, 351, 235, 192, 207, 154, 177], "SKU_ShortLife": [137, 134, 139, 131, 181, 234, 306, 339, 489, 471, 597, 533, 403, 407, 248, 203, 370, 269, 288, 268]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": 15000.0, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 546,708.5
|
retail_f2_promo_budget_v3
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_promo_budget
Scenario ID: retail_f2_promo_budget_v3
[BUSINESS DESCRIPTION]
Business narrative:
In the final periods of the horizon the retailer runs strong promotions on the basic and short-life products, causing their demand to spike. At the same time, an open-to-buy style budget limits how much can be spent in each period on inventory-related activities. The retailer must allocate inventory and spending over time so that promotion-induced demand is supported as well as possible without violating the budget caps.
Structure cues:
- The inventory and substitution structure is the usual single-echelon system with shared storage, production capacity, and a substitution graph, together with lost sales for unmet demand.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the last few periods, the JSON scales up demand for the basic and short-life products to represent promotion-induced lifts; these are treated as ordinary exogenous demands with larger magnitudes.
- The JSON also provides a per-period budget for inventory-related spending. For each period, the total purchasing spend (order quantity times purchasing cost) plus any fixed ordering costs if enabled must not exceed this budget.
- Inventory remains non-negative, and any demand that cannot be satisfied within the budget and capacity limits becomes lost sales.
- Substitution behavior, zero lead times, and generous labor capacity remain active as in other Family 2 archetypes.
- The objective is to minimize total cost subject to the per-period budget, making the trade-off between promotion support and resource limits explicit.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_promo_budget_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4067.504721874054, "DC2": 3364.679049680995, "DC3": 3226.0592560031964, "DC4": 2560.436070515946, "DC5": 2343.357719960569}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [298, 310, 290, 355, 424, 582, 772, 947, 1126, 1354, 1227, 1331, 1080, 1007, 816, 621, 747, 705, 592, 571], "SKU_Premium": [148, 147, 164, 200, 201, 291, 353, 404, 545, 547, 610, 690, 573, 460, 337, 241, 239, 172, 158, 160], "SKU_ShortLife": [135, 141, 134, 140, 164, 207, 286, 344, 440, 457, 460, 535, 497, 355, 251, 225, 304, 259, 293, 260]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": 15000.0, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 542,136.08
|
retail_f2_promo_budget_v4
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_promo_budget
Scenario ID: retail_f2_promo_budget_v4
[BUSINESS DESCRIPTION]
Business narrative:
In the final periods of the horizon the retailer runs strong promotions on the basic and short-life products, causing their demand to spike. At the same time, an open-to-buy style budget limits how much can be spent in each period on inventory-related activities. The retailer must allocate inventory and spending over time so that promotion-induced demand is supported as well as possible without violating the budget caps.
Structure cues:
- The inventory and substitution structure is the usual single-echelon system with shared storage, production capacity, and a substitution graph, together with lost sales for unmet demand.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the last few periods, the JSON scales up demand for the basic and short-life products to represent promotion-induced lifts; these are treated as ordinary exogenous demands with larger magnitudes.
- The JSON also provides a per-period budget for inventory-related spending. For each period, the total purchasing spend (order quantity times purchasing cost) plus any fixed ordering costs if enabled must not exceed this budget.
- Inventory remains non-negative, and any demand that cannot be satisfied within the budget and capacity limits becomes lost sales.
- Substitution behavior, zero lead times, and generous labor capacity remain active as in other Family 2 archetypes.
- The objective is to minimize total cost subject to the per-period budget, making the trade-off between promotion support and resource limits explicit.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_promo_budget_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3665.97505027651, "DC2": 3192.2769461415705, "DC3": 2776.6243625130755, "DC4": 3139.5910066903148, "DC5": 2284.8887784501344}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [271, 351, 338, 334, 469, 540, 641, 958, 1007, 1154, 1478, 1192, 1183, 951, 617, 627, 750, 686, 661, 710], "SKU_Premium": [158, 171, 156, 168, 185, 267, 342, 397, 568, 686, 601, 665, 592, 421, 325, 261, 217, 183, 165, 173], "SKU_ShortLife": [119, 139, 116, 148, 199, 249, 314, 350, 379, 479, 578, 436, 423, 410, 276, 242, 379, 307, 293, 277]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": 15000.0, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 540,282.08
|
retail_f2_ultra_fresh_v0
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_ultra_fresh
Scenario ID: retail_f2_ultra_fresh_v0
[BUSINESS DESCRIPTION]
Business narrative:
This scenario represents extremely short shelf-life products such as daily bakery items or ready-to-eat meals. All products must be sold very soon after arrival; otherwise they must be discarded as waste. Demand for each product at each location is seasonal and exogenous. Customers may switch between products according to the substitution graph, but only non-expired inventory can be used to satisfy demand. There are no backorders and no transshipment.
Structure cues:
- The inventory and assortment framework is the same as in the other Family 2 archetypes: single-echelon, multiple products, local demand, and an encoded substitution graph.
- Shelf-life values in the JSON are very short, measured in periods. Inventory must be tracked by age so that units older than their shelf life are no longer eligible to serve demand.
- When units expire they leave usable inventory and are counted as waste, incurring waste costs. Only non-expired stock can be used to satisfy original and substituted demand.
- Inventory levels must remain non-negative; any demand that cannot be met from non-expired inventory and allowed substitution becomes lost sales.
- Storage capacity, production capacity, the absence of transshipment, zero lead times, and generous labor capacity remain in force.
- The objective is to minimize total cost including short-horizon holding, waste from expiry, and lost sales.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_ultra_fresh_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 2, "SKU_Premium": 2, "SKU_ShortLife": 1}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 454,980
|
retail_f2_ultra_fresh_v1
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_ultra_fresh
Scenario ID: retail_f2_ultra_fresh_v1
[BUSINESS DESCRIPTION]
Business narrative:
This scenario represents extremely short shelf-life products such as daily bakery items or ready-to-eat meals. All products must be sold very soon after arrival; otherwise they must be discarded as waste. Demand for each product at each location is seasonal and exogenous. Customers may switch between products according to the substitution graph, but only non-expired inventory can be used to satisfy demand. There are no backorders and no transshipment.
Structure cues:
- The inventory and assortment framework is the same as in the other Family 2 archetypes: single-echelon, multiple products, local demand, and an encoded substitution graph.
- Shelf-life values in the JSON are very short, measured in periods. Inventory must be tracked by age so that units older than their shelf life are no longer eligible to serve demand.
- When units expire they leave usable inventory and are counted as waste, incurring waste costs. Only non-expired stock can be used to satisfy original and substituted demand.
- Inventory levels must remain non-negative; any demand that cannot be met from non-expired inventory and allowed substitution becomes lost sales.
- Storage capacity, production capacity, the absence of transshipment, zero lead times, and generous labor capacity remain in force.
- The objective is to minimize total cost including short-horizon holding, waste from expiry, and lost sales.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_ultra_fresh_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 2, "SKU_Premium": 2, "SKU_ShortLife": 1}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4183.142994878131, "DC2": 3511.4617985383957, "DC3": 2796.598976081488, "DC4": 3114.4975244972347, "DC5": 2199.4654208538896}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [266, 268, 331, 383, 475, 606, 772, 972, 1198, 1153, 1382, 1171, 985, 1003, 670, 481, 409, 395, 371, 286], "SKU_Premium": [128, 141, 171, 157, 227, 247, 333, 403, 631, 658, 714, 682, 578, 407, 400, 287, 240, 205, 158, 137], "SKU_ShortLife": [128, 113, 120, 158, 193, 226, 263, 378, 400, 440, 493, 503, 419, 394, 262, 194, 162, 128, 146, 132]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 469,130.5
|
retail_f2_ultra_fresh_v2
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_ultra_fresh
Scenario ID: retail_f2_ultra_fresh_v2
[BUSINESS DESCRIPTION]
Business narrative:
This scenario represents extremely short shelf-life products such as daily bakery items or ready-to-eat meals. All products must be sold very soon after arrival; otherwise they must be discarded as waste. Demand for each product at each location is seasonal and exogenous. Customers may switch between products according to the substitution graph, but only non-expired inventory can be used to satisfy demand. There are no backorders and no transshipment.
Structure cues:
- The inventory and assortment framework is the same as in the other Family 2 archetypes: single-echelon, multiple products, local demand, and an encoded substitution graph.
- Shelf-life values in the JSON are very short, measured in periods. Inventory must be tracked by age so that units older than their shelf life are no longer eligible to serve demand.
- When units expire they leave usable inventory and are counted as waste, incurring waste costs. Only non-expired stock can be used to satisfy original and substituted demand.
- Inventory levels must remain non-negative; any demand that cannot be met from non-expired inventory and allowed substitution becomes lost sales.
- Storage capacity, production capacity, the absence of transshipment, zero lead times, and generous labor capacity remain in force.
- The objective is to minimize total cost including short-horizon holding, waste from expiry, and lost sales.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_ultra_fresh_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 2, "SKU_Premium": 2, "SKU_ShortLife": 1}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3947.3702160442394, "DC2": 3290.0400751905904, "DC3": 2683.0462935844844, "DC4": 3310.4499083646383, "DC5": 2866.4778909068746}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [317, 347, 328, 412, 479, 564, 638, 790, 950, 1367, 1323, 1305, 1067, 945, 672, 578, 470, 344, 331, 325], "SKU_Premium": [172, 149, 142, 200, 205, 291, 377, 470, 617, 530, 566, 619, 489, 518, 333, 263, 232, 190, 153, 156], "SKU_ShortLife": [117, 118, 116, 154, 153, 188, 300, 398, 374, 498, 492, 455, 417, 365, 299, 196, 191, 138, 119, 134]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 443,865.5
|
retail_f2_ultra_fresh_v3
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_ultra_fresh
Scenario ID: retail_f2_ultra_fresh_v3
[BUSINESS DESCRIPTION]
Business narrative:
This scenario represents extremely short shelf-life products such as daily bakery items or ready-to-eat meals. All products must be sold very soon after arrival; otherwise they must be discarded as waste. Demand for each product at each location is seasonal and exogenous. Customers may switch between products according to the substitution graph, but only non-expired inventory can be used to satisfy demand. There are no backorders and no transshipment.
Structure cues:
- The inventory and assortment framework is the same as in the other Family 2 archetypes: single-echelon, multiple products, local demand, and an encoded substitution graph.
- Shelf-life values in the JSON are very short, measured in periods. Inventory must be tracked by age so that units older than their shelf life are no longer eligible to serve demand.
- When units expire they leave usable inventory and are counted as waste, incurring waste costs. Only non-expired stock can be used to satisfy original and substituted demand.
- Inventory levels must remain non-negative; any demand that cannot be met from non-expired inventory and allowed substitution becomes lost sales.
- Storage capacity, production capacity, the absence of transshipment, zero lead times, and generous labor capacity remain in force.
- The objective is to minimize total cost including short-horizon holding, waste from expiry, and lost sales.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_ultra_fresh_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 2, "SKU_Premium": 2, "SKU_ShortLife": 1}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4044.6217219616046, "DC2": 3712.3099143093596, "DC3": 2820.0400649419153, "DC4": 2552.0114443696934, "DC5": 2779.2237911610905}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [330, 327, 297, 381, 473, 563, 799, 909, 1053, 1087, 1127, 1137, 953, 807, 653, 614, 443, 350, 336, 278], "SKU_Premium": [159, 164, 146, 189, 230, 308, 360, 462, 541, 648, 623, 707, 516, 437, 322, 265, 193, 183, 188, 159], "SKU_ShortLife": [122, 117, 115, 133, 176, 218, 296, 327, 438, 434, 559, 540, 392, 408, 272, 211, 184, 140, 135, 106]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 424,617.5
|
retail_f2_ultra_fresh_v4
|
[SCENARIO]
Family: F2 (Assortment and Substitution)
Archetype: retail_f2_ultra_fresh
Scenario ID: retail_f2_ultra_fresh_v4
[BUSINESS DESCRIPTION]
Business narrative:
This scenario represents extremely short shelf-life products such as daily bakery items or ready-to-eat meals. All products must be sold very soon after arrival; otherwise they must be discarded as waste. Demand for each product at each location is seasonal and exogenous. Customers may switch between products according to the substitution graph, but only non-expired inventory can be used to satisfy demand. There are no backorders and no transshipment.
Structure cues:
- The inventory and assortment framework is the same as in the other Family 2 archetypes: single-echelon, multiple products, local demand, and an encoded substitution graph.
- Shelf-life values in the JSON are very short, measured in periods. Inventory must be tracked by age so that units older than their shelf life are no longer eligible to serve demand.
- When units expire they leave usable inventory and are counted as waste, incurring waste costs. Only non-expired stock can be used to satisfy original and substituted demand.
- Inventory levels must remain non-negative; any demand that cannot be met from non-expired inventory and allowed substitution becomes lost sales.
- Storage capacity, production capacity, the absence of transshipment, zero lead times, and generous labor capacity remain in force.
- The objective is to minimize total cost including short-horizon holding, waste from expiry, and lost sales.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f2_ultra_fresh_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 2, "SKU_Premium": 2, "SKU_ShortLife": 1}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4237.975898559984, "DC2": 3790.530716130663, "DC3": 2554.9351789060497, "DC4": 2872.993121158345, "DC5": 2509.306613610699}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [277, 327, 375, 336, 383, 620, 647, 1034, 1199, 1224, 1187, 1199, 1125, 934, 736, 627, 414, 411, 300, 320], "SKU_Premium": [167, 153, 184, 176, 246, 239, 330, 476, 601, 591, 671, 667, 627, 461, 400, 233, 242, 176, 143, 156], "SKU_ShortLife": [112, 110, 132, 137, 192, 241, 267, 354, 425, 507, 454, 493, 450, 316, 272, 235, 163, 132, 119, 121]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 472,643.5
|
retail_f3_storage_bottleneck_v0
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_storage_bottleneck
Scenario ID: retail_f3_storage_bottleneck_v0
[BUSINESS DESCRIPTION]
Business narrative:
All locations share a tight storage resource that applies across all products, representing limited chilled, ambient, or dry space. Demand at each location is still exogenous and local, and inventory is not transferred between locations. The main operational challenge is that total stored volume at each site must fit within a strict capacity, so stocking one product reduces room for others.
Structure cues:
- The inventory, production, and lost sales logic is the same as in retail_f1_base: single-echelon, multiple products and locations, local demand, and no backorders or transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. This constraint is designed to be binding and central to the trade-offs.
- Inventory levels at each location are kept non-negative and evolve from carried-over stock and new production, minus sales and waste.
- Substitution edges, if any, are taken from the JSON and follow the standard semantics: edge [A, B] means A's demand can be served by B.
- Production capacities, zero lead times, and generous labor capacity remain as in the base scenario.
- The objective is to minimize total cost while respecting the tight storage constraint.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_storage_bottleneck_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 1200.0, "DC2": 1050.0, "DC3": 900.0, "DC4": 900.0, "DC5": 750.0}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 429,782.4
|
retail_f3_storage_bottleneck_v1
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_storage_bottleneck
Scenario ID: retail_f3_storage_bottleneck_v1
[BUSINESS DESCRIPTION]
Business narrative:
All locations share a tight storage resource that applies across all products, representing limited chilled, ambient, or dry space. Demand at each location is still exogenous and local, and inventory is not transferred between locations. The main operational challenge is that total stored volume at each site must fit within a strict capacity, so stocking one product reduces room for others.
Structure cues:
- The inventory, production, and lost sales logic is the same as in retail_f1_base: single-echelon, multiple products and locations, local demand, and no backorders or transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. This constraint is designed to be binding and central to the trade-offs.
- Inventory levels at each location are kept non-negative and evolve from carried-over stock and new production, minus sales and waste.
- Substitution edges, if any, are taken from the JSON and follow the standard semantics: edge [A, B] means A's demand can be served by B.
- Production capacities, zero lead times, and generous labor capacity remain as in the base scenario.
- The objective is to minimize total cost while respecting the tight storage constraint.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_storage_bottleneck_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 1055.8079522800297, "DC2": 1018.6134333265579, "DC3": 859.9214861012979, "DC4": 790.3183063284633, "DC5": 713.9196544245406}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [302, 301, 366, 379, 386, 628, 658, 784, 1008, 1187, 1451, 1335, 938, 805, 610, 600, 410, 346, 342, 302], "SKU_Premium": [143, 149, 160, 192, 235, 252, 393, 405, 609, 578, 724, 532, 580, 473, 325, 296, 211, 178, 161, 169], "SKU_ShortLife": [131, 114, 112, 156, 189, 202, 317, 338, 382, 529, 565, 483, 446, 410, 299, 186, 154, 152, 136, 122]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 428,363.7
|
retail_f3_storage_bottleneck_v2
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_storage_bottleneck
Scenario ID: retail_f3_storage_bottleneck_v2
[BUSINESS DESCRIPTION]
Business narrative:
All locations share a tight storage resource that applies across all products, representing limited chilled, ambient, or dry space. Demand at each location is still exogenous and local, and inventory is not transferred between locations. The main operational challenge is that total stored volume at each site must fit within a strict capacity, so stocking one product reduces room for others.
Structure cues:
- The inventory, production, and lost sales logic is the same as in retail_f1_base: single-echelon, multiple products and locations, local demand, and no backorders or transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. This constraint is designed to be binding and central to the trade-offs.
- Inventory levels at each location are kept non-negative and evolve from carried-over stock and new production, minus sales and waste.
- Substitution edges, if any, are taken from the JSON and follow the standard semantics: edge [A, B] means A's demand can be served by B.
- Production capacities, zero lead times, and generous labor capacity remain as in the base scenario.
- The objective is to minimize total cost while respecting the tight storage constraint.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_storage_bottleneck_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 1275.7199172389057, "DC2": 1106.0485166959793, "DC3": 905.8185887894177, "DC4": 882.0340831983854, "DC5": 658.5554847687304}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [331, 287, 308, 326, 478, 531, 683, 774, 1045, 1220, 1216, 1370, 997, 848, 690, 556, 464, 380, 324, 320], "SKU_Premium": [173, 172, 158, 187, 215, 239, 305, 385, 601, 590, 625, 625, 559, 411, 399, 279, 198, 183, 144, 141], "SKU_ShortLife": [119, 123, 139, 127, 170, 199, 306, 311, 384, 436, 457, 498, 496, 340, 243, 210, 198, 143, 122, 112]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 405,046.03
|
retail_f3_storage_bottleneck_v3
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_storage_bottleneck
Scenario ID: retail_f3_storage_bottleneck_v3
[BUSINESS DESCRIPTION]
Business narrative:
All locations share a tight storage resource that applies across all products, representing limited chilled, ambient, or dry space. Demand at each location is still exogenous and local, and inventory is not transferred between locations. The main operational challenge is that total stored volume at each site must fit within a strict capacity, so stocking one product reduces room for others.
Structure cues:
- The inventory, production, and lost sales logic is the same as in retail_f1_base: single-echelon, multiple products and locations, local demand, and no backorders or transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. This constraint is designed to be binding and central to the trade-offs.
- Inventory levels at each location are kept non-negative and evolve from carried-over stock and new production, minus sales and waste.
- Substitution edges, if any, are taken from the JSON and follow the standard semantics: edge [A, B] means A's demand can be served by B.
- Production capacities, zero lead times, and generous labor capacity remain as in the base scenario.
- The objective is to minimize total cost while respecting the tight storage constraint.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_storage_bottleneck_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 1327.281582216799, "DC2": 1168.4903524146278, "DC3": 1024.1576323547497, "DC4": 968.1078224441308, "DC5": 852.9966194079219}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [331, 287, 341, 367, 454, 500, 800, 858, 1178, 1067, 1433, 1141, 1216, 927, 612, 529, 414, 327, 296, 305], "SKU_Premium": [141, 164, 167, 180, 188, 273, 309, 493, 490, 624, 743, 624, 550, 454, 392, 308, 245, 175, 186, 158], "SKU_ShortLife": [115, 105, 121, 162, 159, 193, 324, 394, 407, 546, 568, 467, 466, 344, 254, 251, 190, 151, 130, 106]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 428,965.89
|
retail_f3_storage_bottleneck_v4
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_storage_bottleneck
Scenario ID: retail_f3_storage_bottleneck_v4
[BUSINESS DESCRIPTION]
Business narrative:
All locations share a tight storage resource that applies across all products, representing limited chilled, ambient, or dry space. Demand at each location is still exogenous and local, and inventory is not transferred between locations. The main operational challenge is that total stored volume at each site must fit within a strict capacity, so stocking one product reduces room for others.
Structure cues:
- The inventory, production, and lost sales logic is the same as in retail_f1_base: single-echelon, multiple products and locations, local demand, and no backorders or transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. This constraint is designed to be binding and central to the trade-offs.
- Inventory levels at each location are kept non-negative and evolve from carried-over stock and new production, minus sales and waste.
- Substitution edges, if any, are taken from the JSON and follow the standard semantics: edge [A, B] means A's demand can be served by B.
- Production capacities, zero lead times, and generous labor capacity remain as in the base scenario.
- The objective is to minimize total cost while respecting the tight storage constraint.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_storage_bottleneck_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 1182.00878315445, "DC2": 975.086606198174, "DC3": 801.0610854428372, "DC4": 957.8138828879366, "DC5": 818.909378943503}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [318, 287, 282, 311, 423, 516, 796, 814, 1117, 1161, 1222, 1357, 988, 1024, 773, 479, 445, 414, 374, 306], "SKU_Premium": [151, 137, 162, 177, 247, 247, 402, 510, 538, 605, 634, 641, 507, 416, 343, 258, 205, 169, 174, 149], "SKU_ShortLife": [120, 107, 147, 155, 163, 238, 310, 379, 446, 463, 505, 545, 446, 391, 269, 219, 150, 139, 147, 122]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 424,383.49
|
retail_f3_supply_bottleneck_v0
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_supply_bottleneck
Scenario ID: retail_f3_supply_bottleneck_v0
[BUSINESS DESCRIPTION]
Business narrative:
Storage space is abundant but upstream production capacity is tight. The main bottleneck is how many units can be produced or procured each period, not how many can be stored. Demand is still exogenous, local to each location, and there are no backorders or transshipment.
Structure cues:
- The inventory and lost sales logic is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. Storage capacities in the JSON are set very high so that storage constraints are effectively non-binding.
- Per-product production capacities are significantly reduced. These caps must be enforced and become the main source of unmet demand.
- Inventory at each location and period stays non-negative and changes according to local production, sales, and waste.
- There is no transshipment, lead times are zero, and substitution behavior is determined by the substitution graph with standard semantics.
- The objective is to minimize total cost, with lost sales penalties playing a central role because of tight production capacity.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_supply_bottleneck_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 999999.0, "DC2": 999999.0, "DC3": 999999.0, "DC4": 999999.0, "DC5": 999999.0}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0], "SKU_Premium": [120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0], "SKU_ShortLife": [150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 1,021,145
|
retail_f3_supply_bottleneck_v1
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_supply_bottleneck
Scenario ID: retail_f3_supply_bottleneck_v1
[BUSINESS DESCRIPTION]
Business narrative:
Storage space is abundant but upstream production capacity is tight. The main bottleneck is how many units can be produced or procured each period, not how many can be stored. Demand is still exogenous, local to each location, and there are no backorders or transshipment.
Structure cues:
- The inventory and lost sales logic is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. Storage capacities in the JSON are set very high so that storage constraints are effectively non-binding.
- Per-product production capacities are significantly reduced. These caps must be enforced and become the main source of unmet demand.
- Inventory at each location and period stays non-negative and changes according to local production, sales, and waste.
- There is no transshipment, lead times are zero, and substitution behavior is determined by the substitution graph with standard semantics.
- The objective is to minimize total cost, with lost sales penalties playing a central role because of tight production capacity.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_supply_bottleneck_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 1059614.6153592607, "DC2": 1114196.4763288377, "DC3": 1097372.2063868342, "DC4": 1009131.0994909529, "DC5": 960649.2079182867}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0], "SKU_Premium": [120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0], "SKU_ShortLife": [150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [263, 272, 348, 325, 429, 513, 684, 1017, 1093, 1370, 1387, 1394, 1154, 1041, 743, 580, 464, 380, 343, 285], "SKU_Premium": [128, 174, 175, 171, 186, 251, 387, 409, 509, 541, 572, 661, 530, 416, 339, 273, 222, 166, 178, 168], "SKU_ShortLife": [121, 142, 128, 155, 155, 204, 297, 337, 495, 551, 451, 534, 455, 311, 264, 193, 189, 146, 128, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 1,026,458
|
retail_f3_supply_bottleneck_v2
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_supply_bottleneck
Scenario ID: retail_f3_supply_bottleneck_v2
[BUSINESS DESCRIPTION]
Business narrative:
Storage space is abundant but upstream production capacity is tight. The main bottleneck is how many units can be produced or procured each period, not how many can be stored. Demand is still exogenous, local to each location, and there are no backorders or transshipment.
Structure cues:
- The inventory and lost sales logic is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. Storage capacities in the JSON are set very high so that storage constraints are effectively non-binding.
- Per-product production capacities are significantly reduced. These caps must be enforced and become the main source of unmet demand.
- Inventory at each location and period stays non-negative and changes according to local production, sales, and waste.
- There is no transshipment, lead times are zero, and substitution behavior is determined by the substitution graph with standard semantics.
- The objective is to minimize total cost, with lost sales penalties playing a central role because of tight production capacity.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_supply_bottleneck_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 946970.0399827102, "DC2": 880447.1675486389, "DC3": 949324.3034532923, "DC4": 862526.3058170992, "DC5": 977649.0928957443}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0], "SKU_Premium": [120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0], "SKU_ShortLife": [150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [284, 306, 311, 383, 390, 613, 702, 893, 1145, 1342, 1464, 1150, 943, 956, 653, 569, 422, 351, 355, 329], "SKU_Premium": [163, 153, 168, 172, 196, 284, 375, 458, 474, 553, 605, 704, 567, 458, 351, 245, 237, 190, 165, 177], "SKU_ShortLife": [118, 127, 118, 142, 195, 233, 244, 344, 411, 461, 482, 539, 426, 370, 283, 217, 147, 156, 112, 122]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 1,014,502
|
retail_f3_supply_bottleneck_v3
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_supply_bottleneck
Scenario ID: retail_f3_supply_bottleneck_v3
[BUSINESS DESCRIPTION]
Business narrative:
Storage space is abundant but upstream production capacity is tight. The main bottleneck is how many units can be produced or procured each period, not how many can be stored. Demand is still exogenous, local to each location, and there are no backorders or transshipment.
Structure cues:
- The inventory and lost sales logic is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. Storage capacities in the JSON are set very high so that storage constraints are effectively non-binding.
- Per-product production capacities are significantly reduced. These caps must be enforced and become the main source of unmet demand.
- Inventory at each location and period stays non-negative and changes according to local production, sales, and waste.
- There is no transshipment, lead times are zero, and substitution behavior is determined by the substitution graph with standard semantics.
- The objective is to minimize total cost, with lost sales penalties playing a central role because of tight production capacity.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_supply_bottleneck_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 984274.8528025018, "DC2": 1114181.370009113, "DC3": 1131005.7124726693, "DC4": 996232.77657489, "DC5": 1070109.43972981}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0], "SKU_Premium": [120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0], "SKU_ShortLife": [150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [311, 301, 300, 404, 472, 600, 722, 884, 1181, 1278, 1318, 1220, 1226, 894, 696, 529, 436, 359, 318, 313], "SKU_Premium": [131, 177, 166, 208, 200, 305, 329, 427, 502, 613, 743, 711, 551, 513, 382, 239, 193, 183, 178, 141], "SKU_ShortLife": [123, 131, 142, 133, 152, 238, 261, 391, 486, 519, 507, 541, 380, 308, 319, 197, 199, 152, 116, 137]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 1,047,182
|
retail_f3_supply_bottleneck_v4
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_supply_bottleneck
Scenario ID: retail_f3_supply_bottleneck_v4
[BUSINESS DESCRIPTION]
Business narrative:
Storage space is abundant but upstream production capacity is tight. The main bottleneck is how many units can be produced or procured each period, not how many can be stored. Demand is still exogenous, local to each location, and there are no backorders or transshipment.
Structure cues:
- The inventory and lost sales logic is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. Storage capacities in the JSON are set very high so that storage constraints are effectively non-binding.
- Per-product production capacities are significantly reduced. These caps must be enforced and become the main source of unmet demand.
- Inventory at each location and period stays non-negative and changes according to local production, sales, and waste.
- There is no transshipment, lead times are zero, and substitution behavior is determined by the substitution graph with standard semantics.
- The objective is to minimize total cost, with lost sales penalties playing a central role because of tight production capacity.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_supply_bottleneck_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 1100171.654473379, "DC2": 1095657.8622260948, "DC3": 1084235.3355647023, "DC4": 975199.3968462343, "DC5": 1018455.8155221663}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0, 240.0], "SKU_Premium": [120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0, 120.0], "SKU_ShortLife": [150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0, 150.0]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [294, 344, 338, 333, 418, 611, 693, 779, 1069, 1407, 1236, 1058, 1204, 927, 728, 486, 383, 381, 317, 340], "SKU_Premium": [156, 154, 150, 165, 238, 287, 337, 491, 618, 631, 637, 546, 610, 386, 340, 287, 193, 163, 163, 170], "SKU_ShortLife": [127, 126, 132, 166, 176, 199, 265, 376, 473, 519, 502, 454, 403, 354, 261, 238, 163, 152, 139, 116]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 1,009,032
|
retail_f3_unbalanced_network_v0
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_unbalanced_network
Scenario ID: retail_f3_unbalanced_network_v0
[BUSINESS DESCRIPTION]
Business narrative:
Storage capacity is highly unbalanced across locations. One location acts as a high-capacity hub with ample space, while all other locations have very limited storage. Demand is still local to each location, and there is no movement of inventory between locations. The retailer must decide how much to store at each site given these asymmetric capacity limits.
Structure cues:
- The inventory system remains single-echelon with local demand at each location and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. The JSON concentrates storage capacity at one hub location and gives very small capacities to the satellites.
- Inventory for each product and location evolves from previous stock and local production, minus sales and waste, without ever going below zero.
- Production capacities, zero lead times, and substitution behavior are as in the base scenario.
- The objective is to minimize total cost while respecting the highly asymmetric storage limits across locations.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_unbalanced_network_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 15360.0, "DC2": 160.0, "DC3": 160.0, "DC4": 160.0, "DC5": 160.0}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 735,284.93
|
retail_f3_unbalanced_network_v1
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_unbalanced_network
Scenario ID: retail_f3_unbalanced_network_v1
[BUSINESS DESCRIPTION]
Business narrative:
Storage capacity is highly unbalanced across locations. One location acts as a high-capacity hub with ample space, while all other locations have very limited storage. Demand is still local to each location, and there is no movement of inventory between locations. The retailer must decide how much to store at each site given these asymmetric capacity limits.
Structure cues:
- The inventory system remains single-echelon with local demand at each location and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. The JSON concentrates storage capacity at one hub location and gives very small capacities to the satellites.
- Inventory for each product and location evolves from previous stock and local production, minus sales and waste, without ever going below zero.
- Production capacities, zero lead times, and substitution behavior are as in the base scenario.
- The objective is to minimize total cost while respecting the highly asymmetric storage limits across locations.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_unbalanced_network_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 16389.784391040364, "DC2": 144.57522575120956, "DC3": 147.24246404591747, "DC4": 137.8978360879057, "DC5": 171.46237064937515}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [290, 314, 288, 402, 418, 512, 636, 838, 1248, 1341, 1275, 1258, 1033, 782, 658, 556, 424, 361, 300, 315], "SKU_Premium": [135, 133, 141, 171, 244, 306, 376, 414, 609, 620, 585, 533, 530, 506, 307, 291, 189, 191, 153, 147], "SKU_ShortLife": [138, 125, 131, 153, 169, 242, 292, 329, 439, 524, 474, 472, 441, 390, 247, 228, 190, 130, 112, 137]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 739,353.78
|
retail_f3_unbalanced_network_v2
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_unbalanced_network
Scenario ID: retail_f3_unbalanced_network_v2
[BUSINESS DESCRIPTION]
Business narrative:
Storage capacity is highly unbalanced across locations. One location acts as a high-capacity hub with ample space, while all other locations have very limited storage. Demand is still local to each location, and there is no movement of inventory between locations. The retailer must decide how much to store at each site given these asymmetric capacity limits.
Structure cues:
- The inventory system remains single-echelon with local demand at each location and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. The JSON concentrates storage capacity at one hub location and gives very small capacities to the satellites.
- Inventory for each product and location evolves from previous stock and local production, minus sales and waste, without ever going below zero.
- Production capacities, zero lead times, and substitution behavior are as in the base scenario.
- The objective is to minimize total cost while respecting the highly asymmetric storage limits across locations.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_unbalanced_network_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 13769.355971074652, "DC2": 149.77059259913372, "DC3": 144.0730334676832, "DC4": 149.18431787774554, "DC5": 166.26127542067172}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [298, 296, 348, 363, 464, 617, 644, 949, 1250, 1232, 1235, 1363, 1209, 845, 715, 474, 396, 416, 325, 319], "SKU_Premium": [133, 162, 167, 208, 200, 281, 361, 459, 535, 625, 731, 617, 608, 425, 364, 303, 189, 162, 163, 137], "SKU_ShortLife": [137, 126, 129, 124, 193, 212, 245, 309, 484, 540, 574, 447, 467, 402, 308, 187, 198, 164, 131, 109]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 771,200.16
|
retail_f3_unbalanced_network_v3
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_unbalanced_network
Scenario ID: retail_f3_unbalanced_network_v3
[BUSINESS DESCRIPTION]
Business narrative:
Storage capacity is highly unbalanced across locations. One location acts as a high-capacity hub with ample space, while all other locations have very limited storage. Demand is still local to each location, and there is no movement of inventory between locations. The retailer must decide how much to store at each site given these asymmetric capacity limits.
Structure cues:
- The inventory system remains single-echelon with local demand at each location and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. The JSON concentrates storage capacity at one hub location and gives very small capacities to the satellites.
- Inventory for each product and location evolves from previous stock and local production, minus sales and waste, without ever going below zero.
- Production capacities, zero lead times, and substitution behavior are as in the base scenario.
- The objective is to minimize total cost while respecting the highly asymmetric storage limits across locations.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_unbalanced_network_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 14761.272810283635, "DC2": 180.588723830699, "DC3": 160.22303538972722, "DC4": 177.76422370924027, "DC5": 169.45876027788506}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [311, 275, 321, 324, 374, 631, 623, 873, 1171, 1292, 1356, 1422, 1223, 796, 743, 571, 482, 334, 356, 283], "SKU_Premium": [165, 133, 154, 174, 188, 271, 390, 443, 595, 538, 568, 557, 520, 478, 339, 310, 240, 199, 182, 142], "SKU_ShortLife": [126, 105, 113, 159, 191, 213, 250, 413, 445, 511, 467, 504, 384, 372, 266, 218, 161, 155, 139, 130]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 714,169.2
|
retail_f3_unbalanced_network_v4
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_unbalanced_network
Scenario ID: retail_f3_unbalanced_network_v4
[BUSINESS DESCRIPTION]
Business narrative:
Storage capacity is highly unbalanced across locations. One location acts as a high-capacity hub with ample space, while all other locations have very limited storage. Demand is still local to each location, and there is no movement of inventory between locations. The retailer must decide how much to store at each site given these asymmetric capacity limits.
Structure cues:
- The inventory system remains single-echelon with local demand at each location and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. The JSON concentrates storage capacity at one hub location and gives very small capacities to the satellites.
- Inventory for each product and location evolves from previous stock and local production, minus sales and waste, without ever going below zero.
- Production capacities, zero lead times, and substitution behavior are as in the base scenario.
- The objective is to minimize total cost while respecting the highly asymmetric storage limits across locations.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_unbalanced_network_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 14412.151874089117, "DC2": 173.1692842982701, "DC3": 174.5411583707828, "DC4": 148.6420766336367, "DC5": 182.22021083391184}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [342, 285, 292, 360, 469, 547, 788, 798, 943, 1429, 1193, 1146, 1152, 793, 626, 557, 440, 361, 287, 265], "SKU_Premium": [163, 158, 144, 164, 192, 281, 305, 411, 470, 612, 696, 593, 508, 489, 326, 298, 239, 197, 153, 140], "SKU_ShortLife": [109, 105, 112, 130, 196, 207, 317, 399, 475, 482, 523, 486, 456, 375, 247, 209, 165, 152, 130, 116]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 693,650.01
|
retail_f3_volumetric_constraint_v0
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_volumetric_constraint
Scenario ID: retail_f3_volumetric_constraint_v0
[BUSINESS DESCRIPTION]
Business narrative:
One product—typically a bulky premium item—uses much more storage volume per unit than the others. Storage capacity at each location becomes tight primarily because of this product, forcing the retailer to choose between stocking bulky high-margin units and smaller items. All demand remains local and exogenous, with no transshipment or backorders.
Structure cues:
- The overall structure and shared storage framework match retail_f3_storage_bottleneck.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. Product-specific storage usage parameters in the JSON are much larger for the premium product than for other SKUs.
- Inventory cannot be negative and is updated based on previous stock, local production, sales, and waste.
- There is no transshipment, lead times are zero, and substitution behavior follows the JSON graph with standard semantics.
- The objective is to minimize total cost under capacity constraints that make the volumetrically heavy premium product particularly expensive in terms of space.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_volumetric_constraint_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 15.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 409,419.62
|
retail_f3_volumetric_constraint_v1
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_volumetric_constraint
Scenario ID: retail_f3_volumetric_constraint_v1
[BUSINESS DESCRIPTION]
Business narrative:
One product—typically a bulky premium item—uses much more storage volume per unit than the others. Storage capacity at each location becomes tight primarily because of this product, forcing the retailer to choose between stocking bulky high-margin units and smaller items. All demand remains local and exogenous, with no transshipment or backorders.
Structure cues:
- The overall structure and shared storage framework match retail_f3_storage_bottleneck.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. Product-specific storage usage parameters in the JSON are much larger for the premium product than for other SKUs.
- Inventory cannot be negative and is updated based on previous stock, local production, sales, and waste.
- There is no transshipment, lead times are zero, and substitution behavior follows the JSON graph with standard semantics.
- The objective is to minimize total cost under capacity constraints that make the volumetrically heavy premium product particularly expensive in terms of space.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_volumetric_constraint_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4408.72627642685, "DC2": 3667.439800340886, "DC3": 3140.886796114431, "DC4": 3377.991537212454, "DC5": 2597.040290953764}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 15.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [294, 271, 376, 355, 492, 488, 689, 879, 1126, 1376, 1222, 1256, 1173, 1021, 755, 583, 425, 399, 324, 299], "SKU_Premium": [169, 144, 159, 170, 221, 257, 314, 486, 469, 644, 695, 628, 567, 503, 307, 287, 199, 158, 155, 137], "SKU_ShortLife": [126, 129, 111, 139, 167, 225, 253, 373, 472, 456, 530, 543, 390, 319, 278, 193, 165, 160, 124, 115]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 414,093.56
|
retail_f3_volumetric_constraint_v2
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_volumetric_constraint
Scenario ID: retail_f3_volumetric_constraint_v2
[BUSINESS DESCRIPTION]
Business narrative:
One product—typically a bulky premium item—uses much more storage volume per unit than the others. Storage capacity at each location becomes tight primarily because of this product, forcing the retailer to choose between stocking bulky high-margin units and smaller items. All demand remains local and exogenous, with no transshipment or backorders.
Structure cues:
- The overall structure and shared storage framework match retail_f3_storage_bottleneck.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. Product-specific storage usage parameters in the JSON are much larger for the premium product than for other SKUs.
- Inventory cannot be negative and is updated based on previous stock, local production, sales, and waste.
- There is no transshipment, lead times are zero, and substitution behavior follows the JSON graph with standard semantics.
- The objective is to minimize total cost under capacity constraints that make the volumetrically heavy premium product particularly expensive in terms of space.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_volumetric_constraint_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3406.179071113192, "DC2": 3048.861714569209, "DC3": 2894.369002627237, "DC4": 2568.1215645149905, "DC5": 2303.0678179461047}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 15.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [284, 278, 357, 319, 475, 614, 814, 839, 996, 1344, 1288, 1246, 969, 899, 804, 493, 445, 314, 333, 319], "SKU_Premium": [137, 140, 163, 183, 248, 278, 360, 390, 495, 665, 737, 543, 500, 429, 342, 271, 227, 189, 149, 153], "SKU_ShortLife": [108, 130, 119, 146, 194, 212, 296, 373, 473, 471, 579, 491, 403, 317, 257, 219, 160, 145, 127, 135]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 402,309
|
retail_f3_volumetric_constraint_v3
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_volumetric_constraint
Scenario ID: retail_f3_volumetric_constraint_v3
[BUSINESS DESCRIPTION]
Business narrative:
One product—typically a bulky premium item—uses much more storage volume per unit than the others. Storage capacity at each location becomes tight primarily because of this product, forcing the retailer to choose between stocking bulky high-margin units and smaller items. All demand remains local and exogenous, with no transshipment or backorders.
Structure cues:
- The overall structure and shared storage framework match retail_f3_storage_bottleneck.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. Product-specific storage usage parameters in the JSON are much larger for the premium product than for other SKUs.
- Inventory cannot be negative and is updated based on previous stock, local production, sales, and waste.
- There is no transshipment, lead times are zero, and substitution behavior follows the JSON graph with standard semantics.
- The objective is to minimize total cost under capacity constraints that make the volumetrically heavy premium product particularly expensive in terms of space.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_volumetric_constraint_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3908.8086755208647, "DC2": 3666.698399375343, "DC3": 3350.9437816388095, "DC4": 3187.328873088867, "DC5": 2699.649372855567}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 15.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [316, 294, 306, 414, 380, 495, 621, 1035, 981, 1161, 1304, 1330, 1181, 885, 631, 582, 450, 409, 334, 317], "SKU_Premium": [131, 165, 142, 196, 199, 272, 308, 510, 545, 714, 612, 563, 504, 402, 348, 257, 200, 204, 166, 153], "SKU_ShortLife": [106, 113, 142, 143, 167, 214, 244, 336, 495, 519, 581, 466, 375, 415, 295, 199, 190, 151, 119, 109]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 399,819.62
|
retail_f3_volumetric_constraint_v4
|
[SCENARIO]
Family: F3 (Shared Resources and Capacity)
Archetype: retail_f3_volumetric_constraint
Scenario ID: retail_f3_volumetric_constraint_v4
[BUSINESS DESCRIPTION]
Business narrative:
One product—typically a bulky premium item—uses much more storage volume per unit than the others. Storage capacity at each location becomes tight primarily because of this product, forcing the retailer to choose between stocking bulky high-margin units and smaller items. All demand remains local and exogenous, with no transshipment or backorders.
Structure cues:
- The overall structure and shared storage framework match retail_f3_storage_bottleneck.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. Product-specific storage usage parameters in the JSON are much larger for the premium product than for other SKUs.
- Inventory cannot be negative and is updated based on previous stock, local production, sales, and waste.
- There is no transshipment, lead times are zero, and substitution behavior follows the JSON graph with standard semantics.
- The objective is to minimize total cost under capacity constraints that make the volumetrically heavy premium product particularly expensive in terms of space.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f3_volumetric_constraint_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3856.209407179451, "DC2": 3798.723085114051, "DC3": 2628.0429516606355, "DC4": 3092.571454223831, "DC5": 2701.5171856724796}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 15.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [322, 330, 356, 373, 393, 571, 615, 825, 951, 1189, 1367, 1151, 1026, 835, 737, 479, 381, 352, 335, 322], "SKU_Premium": [143, 160, 157, 158, 229, 248, 345, 386, 604, 710, 726, 533, 481, 516, 402, 255, 248, 164, 165, 145], "SKU_ShortLife": [133, 132, 131, 136, 162, 194, 247, 392, 378, 460, 460, 553, 383, 387, 303, 208, 182, 145, 131, 113]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 399,408.82
|
retail_f4_demand_surge_v0
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_demand_surge
Scenario ID: retail_f4_demand_surge_v0
[BUSINESS DESCRIPTION]
Business narrative:
The retailer experiences a single-period viral demand spike where demand suddenly multiplies for all products. Production capacity and other structural elements remain unchanged; only the magnitude of demand in that period is much higher. The retailer must decide whether to build extra inventory in advance or accept lost sales during the surge.
Structure cues:
- The inventory and production structure is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, one mid-horizon period has demand for each product scaled up by a large factor, representing the surge. This period is treated as having much higher exogenous demand.
- Inventory stays non-negative and is updated using previous stock, current production, sales, and waste.
- Substitution behavior is unchanged, there is no transshipment, and lead times remain effectively zero.
- The objective is to minimize total cost, with the demand spike increasing the importance of planning ahead for that particular period.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_demand_surge_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 2844, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 1420, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 1136, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 562,717.5
|
retail_f4_demand_surge_v1
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_demand_surge
Scenario ID: retail_f4_demand_surge_v1
[BUSINESS DESCRIPTION]
Business narrative:
The retailer experiences a single-period viral demand spike where demand suddenly multiplies for all products. Production capacity and other structural elements remain unchanged; only the magnitude of demand in that period is much higher. The retailer must decide whether to build extra inventory in advance or accept lost sales during the surge.
Structure cues:
- The inventory and production structure is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, one mid-horizon period has demand for each product scaled up by a large factor, representing the surge. This period is treated as having much higher exogenous demand.
- Inventory stays non-negative and is updated using previous stock, current production, sales, and waste.
- Substitution behavior is unchanged, there is no transshipment, and lead times remain effectively zero.
- The objective is to minimize total cost, with the demand spike increasing the importance of planning ahead for that particular period.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_demand_surge_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3402.049614362719, "DC2": 3601.0137027081646, "DC3": 3079.9458330278408, "DC4": 3367.5100616585687, "DC5": 2373.1356267711126}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [285, 348, 340, 316, 395, 540, 795, 1029, 1254, 1405, 1246, 1095, 1078, 795, 3200, 623, 444, 339, 340, 312], "SKU_Premium": [153, 156, 158, 196, 232, 263, 344, 492, 598, 635, 675, 564, 556, 388, 1529, 249, 222, 162, 176, 172], "SKU_ShortLife": [107, 111, 129, 129, 196, 223, 283, 374, 505, 456, 591, 464, 503, 388, 1082, 243, 158, 162, 148, 128]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 596,190
|
retail_f4_demand_surge_v2
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_demand_surge
Scenario ID: retail_f4_demand_surge_v2
[BUSINESS DESCRIPTION]
Business narrative:
The retailer experiences a single-period viral demand spike where demand suddenly multiplies for all products. Production capacity and other structural elements remain unchanged; only the magnitude of demand in that period is much higher. The retailer must decide whether to build extra inventory in advance or accept lost sales during the surge.
Structure cues:
- The inventory and production structure is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, one mid-horizon period has demand for each product scaled up by a large factor, representing the surge. This period is treated as having much higher exogenous demand.
- Inventory stays non-negative and is updated using previous stock, current production, sales, and waste.
- Substitution behavior is unchanged, there is no transshipment, and lead times remain effectively zero.
- The objective is to minimize total cost, with the demand spike increasing the importance of planning ahead for that particular period.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_demand_surge_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3819.945865685423, "DC2": 3609.9362252451174, "DC3": 3185.7109811662085, "DC4": 3387.014925133641, "DC5": 2300.786190660187}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [297, 306, 348, 417, 416, 526, 645, 871, 1162, 1062, 1275, 1416, 1228, 796, 3191, 580, 493, 366, 358, 351], "SKU_Premium": [171, 138, 150, 170, 233, 301, 324, 406, 537, 663, 711, 550, 495, 398, 1267, 252, 190, 169, 173, 176], "SKU_ShortLife": [118, 131, 135, 152, 174, 208, 286, 326, 434, 443, 551, 484, 475, 340, 1222, 193, 154, 155, 121, 108]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 555,907
|
retail_f4_demand_surge_v3
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_demand_surge
Scenario ID: retail_f4_demand_surge_v3
[BUSINESS DESCRIPTION]
Business narrative:
The retailer experiences a single-period viral demand spike where demand suddenly multiplies for all products. Production capacity and other structural elements remain unchanged; only the magnitude of demand in that period is much higher. The retailer must decide whether to build extra inventory in advance or accept lost sales during the surge.
Structure cues:
- The inventory and production structure is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, one mid-horizon period has demand for each product scaled up by a large factor, representing the surge. This period is treated as having much higher exogenous demand.
- Inventory stays non-negative and is updated using previous stock, current production, sales, and waste.
- Substitution behavior is unchanged, there is no transshipment, and lead times remain effectively zero.
- The objective is to minimize total cost, with the demand spike increasing the importance of planning ahead for that particular period.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_demand_surge_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3428.7738365410414, "DC2": 3550.439767792903, "DC3": 3179.3554972854326, "DC4": 3143.953222784597, "DC5": 2568.592625321386}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [293, 280, 366, 371, 388, 543, 660, 872, 1023, 1265, 1151, 1315, 1042, 1031, 2972, 523, 424, 312, 313, 306], "SKU_Premium": [137, 178, 183, 194, 213, 306, 367, 429, 503, 701, 620, 669, 615, 426, 1572, 302, 235, 191, 181, 142], "SKU_ShortLife": [107, 116, 114, 143, 167, 199, 270, 308, 396, 547, 516, 554, 451, 412, 1202, 244, 174, 137, 130, 130]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 585,562.5
|
retail_f4_demand_surge_v4
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_demand_surge
Scenario ID: retail_f4_demand_surge_v4
[BUSINESS DESCRIPTION]
Business narrative:
The retailer experiences a single-period viral demand spike where demand suddenly multiplies for all products. Production capacity and other structural elements remain unchanged; only the magnitude of demand in that period is much higher. The retailer must decide whether to build extra inventory in advance or accept lost sales during the surge.
Structure cues:
- The inventory and production structure is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, one mid-horizon period has demand for each product scaled up by a large factor, representing the surge. This period is treated as having much higher exogenous demand.
- Inventory stays non-negative and is updated using previous stock, current production, sales, and waste.
- Substitution behavior is unchanged, there is no transshipment, and lead times remain effectively zero.
- The objective is to minimize total cost, with the demand spike increasing the importance of planning ahead for that particular period.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_demand_surge_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3626.2266666772134, "DC2": 3203.9969463048124, "DC3": 2770.76224849127, "DC4": 3030.909280245911, "DC5": 2715.192803182658}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [311, 338, 350, 331, 469, 509, 748, 778, 1041, 1224, 1145, 1318, 1169, 1018, 3163, 562, 402, 384, 290, 295], "SKU_Premium": [159, 172, 164, 156, 226, 252, 334, 402, 548, 568, 665, 620, 477, 450, 1631, 237, 212, 184, 143, 159], "SKU_ShortLife": [114, 108, 123, 136, 193, 223, 306, 353, 450, 564, 556, 483, 486, 323, 983, 239, 181, 135, 120, 114]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 575,165
|
retail_f4_early_stockout_v0
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_early_stockout
Scenario ID: retail_f4_early_stockout_v0
[BUSINESS DESCRIPTION]
Business narrative:
The retailer experiences an upstream supply failure at launch. For several initial periods, no production is possible for any product, but customer demand already exists at the locations. The retailer must decide how much inventory to build before the disruption and how to ration demand while supply is temporarily unavailable. Unserved demand in the disruption window is lost and penalized; customers are not backordered.
Structure cues:
- The inventory, storage, and lost sales framework matches the base scenario: single-echelon, local inventories, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, production capacity for all products is set to zero in early periods. The model must respect this by not assigning any new production in those periods.
- Inventory remains non-negative and changes from period to period based on previous stock, any allowed production (zero during the disruption), sales, and waste.
- Substitution behavior and zero lead times remain unchanged from the baseline.
- Labor capacity is generous and does not bind.
- The objective is to minimize total cost while capturing the trade-off between carrying inventory into the supply failure (and paying holding or waste costs) and accepting lost sales during the disruption.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_early_stockout_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [0, 0, 0, 0, 0, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [0, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 621,810.5
|
retail_f4_early_stockout_v1
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_early_stockout
Scenario ID: retail_f4_early_stockout_v1
[BUSINESS DESCRIPTION]
Business narrative:
The retailer experiences an upstream supply failure at launch. For several initial periods, no production is possible for any product, but customer demand already exists at the locations. The retailer must decide how much inventory to build before the disruption and how to ration demand while supply is temporarily unavailable. Unserved demand in the disruption window is lost and penalized; customers are not backordered.
Structure cues:
- The inventory, storage, and lost sales framework matches the base scenario: single-echelon, local inventories, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, production capacity for all products is set to zero in early periods. The model must respect this by not assigning any new production in those periods.
- Inventory remains non-negative and changes from period to period based on previous stock, any allowed production (zero during the disruption), sales, and waste.
- Substitution behavior and zero lead times remain unchanged from the baseline.
- Labor capacity is generous and does not bind.
- The objective is to minimize total cost while capturing the trade-off between carrying inventory into the supply failure (and paying holding or waste costs) and accepting lost sales during the disruption.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_early_stockout_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3549.146998436031, "DC2": 3484.681415984728, "DC3": 2965.5892139513503, "DC4": 3134.8427347753077, "DC5": 2327.4432911690656}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [0, 0, 0, 0, 0, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [0, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [260, 290, 324, 381, 424, 609, 684, 857, 1176, 1085, 1136, 1331, 992, 783, 778, 539, 392, 364, 371, 312], "SKU_Premium": [142, 166, 159, 175, 203, 243, 315, 459, 516, 603, 658, 664, 532, 514, 318, 252, 205, 169, 175, 143], "SKU_ShortLife": [123, 142, 144, 166, 149, 219, 242, 356, 470, 536, 582, 534, 387, 322, 278, 247, 163, 140, 139, 130]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 596,280.5
|
retail_f4_early_stockout_v2
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_early_stockout
Scenario ID: retail_f4_early_stockout_v2
[BUSINESS DESCRIPTION]
Business narrative:
The retailer experiences an upstream supply failure at launch. For several initial periods, no production is possible for any product, but customer demand already exists at the locations. The retailer must decide how much inventory to build before the disruption and how to ration demand while supply is temporarily unavailable. Unserved demand in the disruption window is lost and penalized; customers are not backordered.
Structure cues:
- The inventory, storage, and lost sales framework matches the base scenario: single-echelon, local inventories, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, production capacity for all products is set to zero in early periods. The model must respect this by not assigning any new production in those periods.
- Inventory remains non-negative and changes from period to period based on previous stock, any allowed production (zero during the disruption), sales, and waste.
- Substitution behavior and zero lead times remain unchanged from the baseline.
- Labor capacity is generous and does not bind.
- The objective is to minimize total cost while capturing the trade-off between carrying inventory into the supply failure (and paying holding or waste costs) and accepting lost sales during the disruption.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_early_stockout_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4421.064669109754, "DC2": 3784.9443762579076, "DC3": 3295.183136103139, "DC4": 2765.1023047085446, "DC5": 2161.092015261721}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [0, 0, 0, 0, 0, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [0, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [302, 286, 358, 403, 468, 571, 616, 942, 1227, 1088, 1492, 1107, 1084, 1034, 770, 622, 492, 335, 309, 356], "SKU_Premium": [145, 160, 167, 198, 215, 312, 346, 465, 510, 667, 584, 573, 591, 419, 304, 236, 193, 156, 179, 153], "SKU_ShortLife": [135, 121, 119, 140, 190, 200, 265, 394, 495, 444, 560, 522, 497, 395, 300, 221, 157, 127, 129, 131]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 628,599.5
|
retail_f4_early_stockout_v3
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_early_stockout
Scenario ID: retail_f4_early_stockout_v3
[BUSINESS DESCRIPTION]
Business narrative:
The retailer experiences an upstream supply failure at launch. For several initial periods, no production is possible for any product, but customer demand already exists at the locations. The retailer must decide how much inventory to build before the disruption and how to ration demand while supply is temporarily unavailable. Unserved demand in the disruption window is lost and penalized; customers are not backordered.
Structure cues:
- The inventory, storage, and lost sales framework matches the base scenario: single-echelon, local inventories, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, production capacity for all products is set to zero in early periods. The model must respect this by not assigning any new production in those periods.
- Inventory remains non-negative and changes from period to period based on previous stock, any allowed production (zero during the disruption), sales, and waste.
- Substitution behavior and zero lead times remain unchanged from the baseline.
- Labor capacity is generous and does not bind.
- The objective is to minimize total cost while capturing the trade-off between carrying inventory into the supply failure (and paying holding or waste costs) and accepting lost sales during the disruption.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_early_stockout_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4302.566094233799, "DC2": 3992.79581524138, "DC3": 2920.988690935649, "DC4": 2889.8701602545884, "DC5": 2678.3134583400038}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [0, 0, 0, 0, 0, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [0, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [267, 303, 307, 417, 487, 517, 639, 949, 1176, 1336, 1190, 1314, 1240, 892, 691, 625, 442, 353, 360, 307], "SKU_Premium": [172, 174, 148, 188, 228, 297, 319, 470, 500, 628, 645, 565, 533, 407, 351, 280, 224, 162, 166, 133], "SKU_ShortLife": [103, 107, 137, 141, 165, 235, 305, 325, 473, 463, 523, 455, 394, 337, 313, 235, 199, 162, 140, 119]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 621,677.5
|
retail_f4_early_stockout_v4
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_early_stockout
Scenario ID: retail_f4_early_stockout_v4
[BUSINESS DESCRIPTION]
Business narrative:
The retailer experiences an upstream supply failure at launch. For several initial periods, no production is possible for any product, but customer demand already exists at the locations. The retailer must decide how much inventory to build before the disruption and how to ration demand while supply is temporarily unavailable. Unserved demand in the disruption window is lost and penalized; customers are not backordered.
Structure cues:
- The inventory, storage, and lost sales framework matches the base scenario: single-echelon, local inventories, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, production capacity for all products is set to zero in early periods. The model must respect this by not assigning any new production in those periods.
- Inventory remains non-negative and changes from period to period based on previous stock, any allowed production (zero during the disruption), sales, and waste.
- Substitution behavior and zero lead times remain unchanged from the baseline.
- Labor capacity is generous and does not bind.
- The objective is to minimize total cost while capturing the trade-off between carrying inventory into the supply failure (and paying holding or waste costs) and accepting lost sales during the disruption.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_early_stockout_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4171.280555421592, "DC2": 3917.0279714433823, "DC3": 3234.4142932396585, "DC4": 3071.2972056767253, "DC5": 2229.278578700469}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [0, 0, 0, 0, 0, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [0, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [0, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [315, 284, 294, 368, 455, 510, 612, 1034, 1009, 1380, 1416, 1165, 1102, 887, 674, 549, 426, 312, 311, 278], "SKU_Premium": [153, 176, 154, 171, 242, 263, 326, 407, 507, 695, 645, 645, 509, 478, 354, 279, 221, 208, 177, 164], "SKU_ShortLife": [124, 106, 131, 148, 153, 212, 256, 388, 392, 426, 562, 569, 472, 316, 308, 232, 153, 160, 140, 127]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 620,242.5
|
retail_f4_peak_failure_v0
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_peak_failure
Scenario ID: retail_f4_peak_failure_v0
[BUSINESS DESCRIPTION]
Business narrative:
An upstream supply failure occurs during a high-demand peak, such as a holiday season. Production capacity drops to zero only during the peak window, while demand for all products remains high. The retailer must build inventory before the peak, use it strategically during the failure, and accept some lost sales if necessary. Demand that cannot be served in the peak periods is lost and penalized.
Structure cues:
- The inventory, storage, and lost sales structure is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, production capacities are set to zero only during a mid-horizon block of periods that coincide with the demand peak. No new production can occur in those periods.
- Inventory at each location remains non-negative and is updated from period to period based on earlier production, sales, and waste.
- Substitution behavior, absence of transshipment, zero lead times, and generous labor capacity all remain in effect.
- The objective is to minimize total cost while planning around the temporary but strategically placed supply failure.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_peak_failure_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 0, 0, 0, 0, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 595,032
|
retail_f4_peak_failure_v1
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_peak_failure
Scenario ID: retail_f4_peak_failure_v1
[BUSINESS DESCRIPTION]
Business narrative:
An upstream supply failure occurs during a high-demand peak, such as a holiday season. Production capacity drops to zero only during the peak window, while demand for all products remains high. The retailer must build inventory before the peak, use it strategically during the failure, and accept some lost sales if necessary. Demand that cannot be served in the peak periods is lost and penalized.
Structure cues:
- The inventory, storage, and lost sales structure is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, production capacities are set to zero only during a mid-horizon block of periods that coincide with the demand peak. No new production can occur in those periods.
- Inventory at each location remains non-negative and is updated from period to period based on earlier production, sales, and waste.
- Substitution behavior, absence of transshipment, zero lead times, and generous labor capacity all remain in effect.
- The objective is to minimize total cost while planning around the temporary but strategically placed supply failure.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_peak_failure_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3842.963505762114, "DC2": 3032.539626957944, "DC3": 3307.966758582875, "DC4": 3172.0214228509362, "DC5": 2128.572036245721}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 0, 0, 0, 0, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [305, 288, 309, 358, 398, 497, 664, 838, 994, 1189, 1278, 1063, 943, 921, 769, 592, 430, 379, 318, 285], "SKU_Premium": [147, 132, 152, 166, 196, 288, 372, 393, 612, 699, 571, 632, 533, 387, 355, 250, 210, 197, 140, 143], "SKU_ShortLife": [132, 124, 135, 162, 177, 236, 264, 413, 421, 568, 579, 457, 489, 366, 264, 227, 157, 157, 149, 107]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 554,930
|
retail_f4_peak_failure_v2
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_peak_failure
Scenario ID: retail_f4_peak_failure_v2
[BUSINESS DESCRIPTION]
Business narrative:
An upstream supply failure occurs during a high-demand peak, such as a holiday season. Production capacity drops to zero only during the peak window, while demand for all products remains high. The retailer must build inventory before the peak, use it strategically during the failure, and accept some lost sales if necessary. Demand that cannot be served in the peak periods is lost and penalized.
Structure cues:
- The inventory, storage, and lost sales structure is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, production capacities are set to zero only during a mid-horizon block of periods that coincide with the demand peak. No new production can occur in those periods.
- Inventory at each location remains non-negative and is updated from period to period based on earlier production, sales, and waste.
- Substitution behavior, absence of transshipment, zero lead times, and generous labor capacity all remain in effect.
- The objective is to minimize total cost while planning around the temporary but strategically placed supply failure.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_peak_failure_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3684.5687806779442, "DC2": 3977.9533970885395, "DC3": 3294.8471264216587, "DC4": 3430.7165966846187, "DC5": 2308.8008948741203}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 0, 0, 0, 0, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [288, 268, 340, 388, 457, 571, 769, 986, 1024, 1341, 1454, 1143, 957, 880, 626, 488, 466, 367, 323, 295], "SKU_Premium": [137, 143, 173, 201, 203, 256, 387, 414, 575, 635, 701, 528, 581, 459, 354, 291, 185, 177, 171, 136], "SKU_ShortLife": [109, 140, 144, 144, 167, 189, 249, 376, 413, 512, 585, 467, 483, 374, 253, 207, 166, 132, 142, 123]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 596,084.5
|
retail_f4_peak_failure_v3
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_peak_failure
Scenario ID: retail_f4_peak_failure_v3
[BUSINESS DESCRIPTION]
Business narrative:
An upstream supply failure occurs during a high-demand peak, such as a holiday season. Production capacity drops to zero only during the peak window, while demand for all products remains high. The retailer must build inventory before the peak, use it strategically during the failure, and accept some lost sales if necessary. Demand that cannot be served in the peak periods is lost and penalized.
Structure cues:
- The inventory, storage, and lost sales structure is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, production capacities are set to zero only during a mid-horizon block of periods that coincide with the demand peak. No new production can occur in those periods.
- Inventory at each location remains non-negative and is updated from period to period based on earlier production, sales, and waste.
- Substitution behavior, absence of transshipment, zero lead times, and generous labor capacity all remain in effect.
- The objective is to minimize total cost while planning around the temporary but strategically placed supply failure.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_peak_failure_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4188.234877286609, "DC2": 3464.5118846516402, "DC3": 2988.5493969225336, "DC4": 2953.3808573936462, "DC5": 2434.665825536948}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 0, 0, 0, 0, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [310, 342, 298, 338, 388, 569, 703, 871, 1225, 1152, 1412, 1162, 1124, 998, 800, 629, 404, 402, 360, 310], "SKU_Premium": [161, 171, 157, 187, 214, 262, 327, 484, 511, 559, 719, 541, 489, 431, 364, 307, 246, 162, 145, 169], "SKU_ShortLife": [121, 120, 134, 165, 156, 194, 257, 308, 401, 503, 493, 514, 473, 353, 281, 247, 158, 153, 112, 132]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 585,244.5
|
retail_f4_peak_failure_v4
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_peak_failure
Scenario ID: retail_f4_peak_failure_v4
[BUSINESS DESCRIPTION]
Business narrative:
An upstream supply failure occurs during a high-demand peak, such as a holiday season. Production capacity drops to zero only during the peak window, while demand for all products remains high. The retailer must build inventory before the peak, use it strategically during the failure, and accept some lost sales if necessary. Demand that cannot be served in the peak periods is lost and penalized.
Structure cues:
- The inventory, storage, and lost sales structure is the same as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, production capacities are set to zero only during a mid-horizon block of periods that coincide with the demand peak. No new production can occur in those periods.
- Inventory at each location remains non-negative and is updated from period to period based on earlier production, sales, and waste.
- Substitution behavior, absence of transshipment, zero lead times, and generous labor capacity all remain in effect.
- The objective is to minimize total cost while planning around the temporary but strategically placed supply failure.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_peak_failure_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4451.845644718405, "DC2": 3925.6713814773, "DC3": 3057.9008382548413, "DC4": 3244.264987804345, "DC5": 2851.470849025485}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 0, 0, 0, 0, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 0, 0, 0, 0, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [274, 293, 348, 393, 495, 616, 675, 1040, 1182, 1221, 1435, 1352, 979, 999, 784, 559, 438, 385, 336, 283], "SKU_Premium": [130, 150, 168, 198, 239, 284, 311, 431, 605, 714, 676, 583, 533, 445, 318, 243, 205, 205, 162, 135], "SKU_ShortLife": [125, 128, 122, 148, 198, 244, 257, 374, 421, 458, 467, 471, 474, 412, 318, 191, 172, 138, 126, 138]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 621,889.5
|
retail_f4_quality_hold_v0
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_quality_hold
Scenario ID: retail_f4_quality_hold_v0
[BUSINESS DESCRIPTION]
Business narrative:
A quality issue forces the retailer to halt production of the basic product after a certain time. Existing units of that product can still be sold until they are exhausted or expire, but no new units can be produced during the hold window. Demand for other products is unaffected. Unserved demand for the basic product is lost and penalized, even if substitutes exist.
Structure cues:
- The inventory and production logic is the same as in the base scenario: single-echelon, local demand, local production, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, the production capacity for the basic product is set to zero after a specified time index, while other products retain their production capacities.
- Inventory for each product and location evolves from period to period based on previous stock, production (which is zero for the basic product during the hold), sales, and waste, and must remain non-negative.
- Any unmet demand for the basic product after considering allowed substitution becomes lost sales.
- Substitution behavior, zero lead times, and generous labor capacity remain as usual.
- The objective is to minimize total cost while capturing the effect of the asymmetric quality hold on the basic product.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_quality_hold_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 566,687.5
|
retail_f4_quality_hold_v1
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_quality_hold
Scenario ID: retail_f4_quality_hold_v1
[BUSINESS DESCRIPTION]
Business narrative:
A quality issue forces the retailer to halt production of the basic product after a certain time. Existing units of that product can still be sold until they are exhausted or expire, but no new units can be produced during the hold window. Demand for other products is unaffected. Unserved demand for the basic product is lost and penalized, even if substitutes exist.
Structure cues:
- The inventory and production logic is the same as in the base scenario: single-echelon, local demand, local production, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, the production capacity for the basic product is set to zero after a specified time index, while other products retain their production capacities.
- Inventory for each product and location evolves from period to period based on previous stock, production (which is zero for the basic product during the hold), sales, and waste, and must remain non-negative.
- Any unmet demand for the basic product after considering allowed substitution becomes lost sales.
- Substitution behavior, zero lead times, and generous labor capacity remain as usual.
- The objective is to minimize total cost while capturing the effect of the asymmetric quality hold on the basic product.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_quality_hold_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4037.457522743235, "DC2": 3858.434195054075, "DC3": 3111.000146727276, "DC4": 3387.56652945535, "DC5": 2839.6813587039137}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [328, 274, 347, 310, 380, 611, 792, 915, 1010, 1388, 1167, 1125, 1180, 918, 639, 487, 391, 318, 317, 311], "SKU_Premium": [159, 144, 186, 168, 212, 296, 305, 510, 616, 561, 562, 677, 585, 405, 333, 245, 201, 207, 186, 132], "SKU_ShortLife": [122, 119, 114, 142, 161, 232, 266, 352, 446, 555, 443, 435, 383, 414, 254, 248, 166, 150, 119, 116]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 546,510.5
|
retail_f4_quality_hold_v2
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_quality_hold
Scenario ID: retail_f4_quality_hold_v2
[BUSINESS DESCRIPTION]
Business narrative:
A quality issue forces the retailer to halt production of the basic product after a certain time. Existing units of that product can still be sold until they are exhausted or expire, but no new units can be produced during the hold window. Demand for other products is unaffected. Unserved demand for the basic product is lost and penalized, even if substitutes exist.
Structure cues:
- The inventory and production logic is the same as in the base scenario: single-echelon, local demand, local production, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, the production capacity for the basic product is set to zero after a specified time index, while other products retain their production capacities.
- Inventory for each product and location evolves from period to period based on previous stock, production (which is zero for the basic product during the hold), sales, and waste, and must remain non-negative.
- Any unmet demand for the basic product after considering allowed substitution becomes lost sales.
- Substitution behavior, zero lead times, and generous labor capacity remain as usual.
- The objective is to minimize total cost while capturing the effect of the asymmetric quality hold on the basic product.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_quality_hold_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3719.324171623398, "DC2": 3451.9614334146313, "DC3": 2872.8961546203122, "DC4": 3001.786707072527, "DC5": 2810.787383672959}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [336, 321, 368, 348, 486, 615, 673, 849, 1023, 1375, 1266, 1161, 1014, 881, 775, 596, 415, 394, 350, 275], "SKU_Premium": [150, 133, 146, 172, 229, 302, 318, 503, 539, 622, 561, 591, 519, 463, 303, 276, 248, 200, 184, 171], "SKU_ShortLife": [129, 128, 132, 154, 170, 244, 247, 308, 398, 467, 447, 449, 395, 343, 321, 192, 188, 144, 116, 139]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 556,194
|
retail_f4_quality_hold_v3
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_quality_hold
Scenario ID: retail_f4_quality_hold_v3
[BUSINESS DESCRIPTION]
Business narrative:
A quality issue forces the retailer to halt production of the basic product after a certain time. Existing units of that product can still be sold until they are exhausted or expire, but no new units can be produced during the hold window. Demand for other products is unaffected. Unserved demand for the basic product is lost and penalized, even if substitutes exist.
Structure cues:
- The inventory and production logic is the same as in the base scenario: single-echelon, local demand, local production, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, the production capacity for the basic product is set to zero after a specified time index, while other products retain their production capacities.
- Inventory for each product and location evolves from period to period based on previous stock, production (which is zero for the basic product during the hold), sales, and waste, and must remain non-negative.
- Any unmet demand for the basic product after considering allowed substitution becomes lost sales.
- Substitution behavior, zero lead times, and generous labor capacity remain as usual.
- The objective is to minimize total cost while capturing the effect of the asymmetric quality hold on the basic product.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_quality_hold_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4348.14731886087, "DC2": 3443.0263900360433, "DC3": 2786.2660090945456, "DC4": 3209.6500684028438, "DC5": 2800.508015690938}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [313, 270, 291, 350, 459, 500, 811, 963, 1254, 1251, 1210, 1388, 1148, 946, 684, 545, 408, 392, 371, 288], "SKU_Premium": [157, 167, 153, 173, 244, 252, 396, 388, 471, 531, 649, 621, 573, 416, 353, 243, 192, 195, 144, 133], "SKU_ShortLife": [110, 112, 112, 139, 158, 192, 306, 321, 428, 492, 579, 468, 378, 383, 265, 209, 168, 130, 117, 125]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 565,214
|
retail_f4_quality_hold_v4
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_quality_hold
Scenario ID: retail_f4_quality_hold_v4
[BUSINESS DESCRIPTION]
Business narrative:
A quality issue forces the retailer to halt production of the basic product after a certain time. Existing units of that product can still be sold until they are exhausted or expire, but no new units can be produced during the hold window. Demand for other products is unaffected. Unserved demand for the basic product is lost and penalized, even if substitutes exist.
Structure cues:
- The inventory and production logic is the same as in the base scenario: single-echelon, local demand, local production, and no transshipment.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, the production capacity for the basic product is set to zero after a specified time index, while other products retain their production capacities.
- Inventory for each product and location evolves from period to period based on previous stock, production (which is zero for the basic product during the hold), sales, and waste, and must remain non-negative.
- Any unmet demand for the basic product after considering allowed substitution becomes lost sales.
- Substitution behavior, zero lead times, and generous labor capacity remain as usual.
- The objective is to minimize total cost while capturing the effect of the asymmetric quality hold on the basic product.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_quality_hold_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4556.4980603070635, "DC2": 3190.1866711249513, "DC3": 3205.4948829719656, "DC4": 3387.4257588259015, "DC5": 2370.365958570004}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [339, 287, 349, 321, 423, 539, 750, 797, 1048, 1154, 1222, 1175, 1193, 916, 648, 601, 484, 401, 337, 346], "SKU_Premium": [133, 161, 171, 208, 217, 308, 308, 405, 485, 684, 610, 580, 543, 436, 372, 264, 227, 203, 142, 176], "SKU_ShortLife": [104, 124, 134, 163, 171, 216, 301, 368, 399, 473, 539, 424, 378, 387, 259, 233, 159, 160, 114, 117]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 550,111
|
retail_f4_robust_variance_v0
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_robust_variance
Scenario ID: retail_f4_robust_variance_v0
[BUSINESS DESCRIPTION]
Business narrative:
Demand alternates between high and low phases over the planning horizon, and lost sales are made very expensive. This mimics a robust-planning environment where the retailer must guard against demand variance rather than a single deterministic forecast. Demand is still exogenous and local at each location, with no backorders and no transshipment.
Structure cues:
- The inventory, storage, and production structure is the same single-echelon system as in the base scenario, with per-product production capacities and local inventories at each location.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, demand curves oscillate across periods, creating repeated high-demand and low-demand phases; lost sales penalties are increased for all products so that stockouts are very costly.
- Inventory at each product, location, and period remains non-negative and evolves from previous stock and current production, minus sales and waste.
- Substitution behavior, zero lead times, and generous labor capacity remain in effect as in other Family 4 archetypes.
- The objective is to minimize total cost including holding, waste, and large lost sales penalties, encouraging robust safety-stock style planning against the demand variance.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_robust_variance_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [454, 217, 492, 255, 652, 384, 1066, 634, 1650, 871, 1950, 871, 1650, 634, 1066, 384, 652, 255, 492, 217], "SKU_Premium": [226, 108, 246, 127, 325, 191, 532, 317, 825, 435, 975, 435, 825, 317, 532, 191, 325, 127, 246, 108], "SKU_ShortLife": [181, 86, 196, 102, 261, 153, 426, 253, 660, 348, 780, 348, 660, 253, 426, 153, 261, 102, 196, 86]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 125.0, "SKU_Premium": 200.0, "SKU_ShortLife": 100.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 586,968
|
retail_f4_robust_variance_v1
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_robust_variance
Scenario ID: retail_f4_robust_variance_v1
[BUSINESS DESCRIPTION]
Business narrative:
Demand alternates between high and low phases over the planning horizon, and lost sales are made very expensive. This mimics a robust-planning environment where the retailer must guard against demand variance rather than a single deterministic forecast. Demand is still exogenous and local at each location, with no backorders and no transshipment.
Structure cues:
- The inventory, storage, and production structure is the same single-echelon system as in the base scenario, with per-product production capacities and local inventories at each location.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, demand curves oscillate across periods, creating repeated high-demand and low-demand phases; lost sales penalties are increased for all products so that stockouts are very costly.
- Inventory at each product, location, and period remains non-negative and evolves from previous stock and current production, minus sales and waste.
- Substitution behavior, zero lead times, and generous labor capacity remain in effect as in other Family 4 archetypes.
- The objective is to minimize total cost including holding, waste, and large lost sales penalties, encouraging robust safety-stock style planning against the demand variance.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_robust_variance_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3690.5781657398916, "DC2": 3129.7560314876814, "DC3": 3025.632985653835, "DC4": 3340.4210014631576, "DC5": 2464.947660701796}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [476, 192, 445, 217, 635, 341, 1009, 696, 1880, 849, 1841, 1000, 1658, 618, 1197, 410, 584, 237, 475, 198], "SKU_Premium": [209, 120, 255, 118, 344, 169, 496, 334, 791, 410, 948, 448, 825, 323, 478, 196, 306, 128, 243, 121], "SKU_ShortLife": [155, 88, 224, 104, 239, 130, 368, 239, 659, 359, 665, 399, 740, 244, 384, 161, 237, 92, 219, 96]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 125.0, "SKU_Premium": 200.0, "SKU_ShortLife": 100.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 581,911
|
retail_f4_robust_variance_v2
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_robust_variance
Scenario ID: retail_f4_robust_variance_v2
[BUSINESS DESCRIPTION]
Business narrative:
Demand alternates between high and low phases over the planning horizon, and lost sales are made very expensive. This mimics a robust-planning environment where the retailer must guard against demand variance rather than a single deterministic forecast. Demand is still exogenous and local at each location, with no backorders and no transshipment.
Structure cues:
- The inventory, storage, and production structure is the same single-echelon system as in the base scenario, with per-product production capacities and local inventories at each location.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, demand curves oscillate across periods, creating repeated high-demand and low-demand phases; lost sales penalties are increased for all products so that stockouts are very costly.
- Inventory at each product, location, and period remains non-negative and evolves from previous stock and current production, minus sales and waste.
- Substitution behavior, zero lead times, and generous labor capacity remain in effect as in other Family 4 archetypes.
- The objective is to minimize total cost including holding, waste, and large lost sales penalties, encouraging robust safety-stock style planning against the demand variance.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_robust_variance_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3458.60192317133, "DC2": 3324.742954915987, "DC3": 2621.698502751688, "DC4": 2636.1542097279935, "DC5": 2835.361795125418}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [393, 238, 530, 264, 748, 328, 1002, 657, 1674, 971, 2198, 990, 1704, 592, 1128, 368, 682, 221, 506, 214], "SKU_Premium": [238, 105, 233, 111, 367, 193, 513, 296, 899, 445, 885, 424, 779, 324, 598, 211, 300, 109, 263, 107], "SKU_ShortLife": [161, 89, 211, 88, 231, 156, 457, 266, 639, 360, 739, 317, 635, 275, 389, 168, 240, 89, 181, 83]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 125.0, "SKU_Premium": 200.0, "SKU_ShortLife": 100.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 653,731
|
retail_f4_robust_variance_v3
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_robust_variance
Scenario ID: retail_f4_robust_variance_v3
[BUSINESS DESCRIPTION]
Business narrative:
Demand alternates between high and low phases over the planning horizon, and lost sales are made very expensive. This mimics a robust-planning environment where the retailer must guard against demand variance rather than a single deterministic forecast. Demand is still exogenous and local at each location, with no backorders and no transshipment.
Structure cues:
- The inventory, storage, and production structure is the same single-echelon system as in the base scenario, with per-product production capacities and local inventories at each location.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, demand curves oscillate across periods, creating repeated high-demand and low-demand phases; lost sales penalties are increased for all products so that stockouts are very costly.
- Inventory at each product, location, and period remains non-negative and evolves from previous stock and current production, minus sales and waste.
- Substitution behavior, zero lead times, and generous labor capacity remain in effect as in other Family 4 archetypes.
- The objective is to minimize total cost including holding, waste, and large lost sales penalties, encouraging robust safety-stock style planning against the demand variance.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_robust_variance_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3807.342214076429, "DC2": 3919.53090027197, "DC3": 3397.127516750158, "DC4": 3050.5506360588874, "DC5": 2418.224884989464}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [388, 235, 482, 260, 690, 352, 1149, 726, 1588, 943, 2110, 804, 1789, 648, 1058, 330, 563, 286, 445, 217], "SKU_Premium": [218, 113, 254, 136, 304, 215, 454, 291, 758, 387, 968, 467, 833, 294, 572, 197, 333, 145, 247, 93], "SKU_ShortLife": [194, 88, 223, 112, 246, 159, 383, 244, 678, 301, 816, 395, 642, 268, 416, 162, 231, 107, 188, 92]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 125.0, "SKU_Premium": 200.0, "SKU_ShortLife": 100.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 603,673.5
|
retail_f4_robust_variance_v4
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_robust_variance
Scenario ID: retail_f4_robust_variance_v4
[BUSINESS DESCRIPTION]
Business narrative:
Demand alternates between high and low phases over the planning horizon, and lost sales are made very expensive. This mimics a robust-planning environment where the retailer must guard against demand variance rather than a single deterministic forecast. Demand is still exogenous and local at each location, with no backorders and no transshipment.
Structure cues:
- The inventory, storage, and production structure is the same single-echelon system as in the base scenario, with per-product production capacities and local inventories at each location.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, demand curves oscillate across periods, creating repeated high-demand and low-demand phases; lost sales penalties are increased for all products so that stockouts are very costly.
- Inventory at each product, location, and period remains non-negative and evolves from previous stock and current production, minus sales and waste.
- Substitution behavior, zero lead times, and generous labor capacity remain in effect as in other Family 4 archetypes.
- The objective is to minimize total cost including holding, waste, and large lost sales penalties, encouraging robust safety-stock style planning against the demand variance.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_robust_variance_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4515.340161047244, "DC2": 3824.6710029835804, "DC3": 3360.1445864457164, "DC4": 3362.680926789409, "DC5": 2537.475499031382}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [396, 216, 559, 223, 689, 432, 984, 701, 1467, 958, 2047, 791, 1766, 609, 1174, 410, 627, 282, 526, 245], "SKU_Premium": [249, 109, 227, 120, 306, 180, 567, 323, 736, 497, 860, 432, 926, 319, 560, 183, 338, 115, 261, 101], "SKU_ShortLife": [157, 83, 181, 108, 267, 158, 409, 249, 712, 399, 867, 373, 726, 283, 454, 144, 256, 111, 189, 75]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 125.0, "SKU_Premium": 200.0, "SKU_ShortLife": 100.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 2.0, "SKU_Premium": 3.0, "SKU_ShortLife": 2.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 613,811
|
retail_f4_supply_risk_v0
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_supply_risk
Scenario ID: retail_f4_supply_risk_v0
[BUSINESS DESCRIPTION]
Business narrative:
The retailer faces persistent but moderate supply risk in the middle of the season. Production capacity is reduced over a mid-horizon band of periods, and waste becomes more expensive. Demand remains exogenous and local, with no backorders and no transshipment. The retailer must decide how much to build inventory before the risk window, balancing the danger of stockouts against the risk of obsolescence and waste.
Structure cues:
- The inventory, storage, and lost sales framework is the same single-echelon structure as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, per-product production capacities are reduced over a specified mid-horizon band of periods, but not set to zero. Outside this band, capacities are higher and should be used to build inventory when beneficial.
- Waste cost parameters are increased for all products so that discarding inventory is more expensive, making overbuilding before the risk window more costly.
- Inventory at each product, location, and period remains non-negative and is updated from previous stock, allowed production, sales, and waste.
- Substitution behavior, zero lead times, and generous labor capacity are unchanged from the baseline.
- The objective is to minimize total cost while trading off early inventory builds against the increased waste cost and mid-season supply risk.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_supply_risk_v0", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4000, "DC2": 3500, "DC3": 3000, "DC4": 3000, "DC5": 2500}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 320, 320, 320, 320, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 160, 160, 160, 160, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 200, 200, 200, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [303, 311, 328, 365, 435, 549, 711, 906, 1100, 1245, 1300, 1245, 1100, 906, 711, 549, 435, 365, 328, 311], "SKU_Premium": [151, 155, 164, 182, 217, 274, 355, 453, 550, 622, 650, 622, 550, 453, 355, 274, 217, 182, 164, 155], "SKU_ShortLife": [121, 124, 131, 146, 174, 219, 284, 362, 440, 498, 520, 498, 440, 362, 284, 219, 174, 146, 131, 124]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 6.0, "SKU_Premium": 9.0, "SKU_ShortLife": 6.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 484,996.5
|
retail_f4_supply_risk_v1
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_supply_risk
Scenario ID: retail_f4_supply_risk_v1
[BUSINESS DESCRIPTION]
Business narrative:
The retailer faces persistent but moderate supply risk in the middle of the season. Production capacity is reduced over a mid-horizon band of periods, and waste becomes more expensive. Demand remains exogenous and local, with no backorders and no transshipment. The retailer must decide how much to build inventory before the risk window, balancing the danger of stockouts against the risk of obsolescence and waste.
Structure cues:
- The inventory, storage, and lost sales framework is the same single-echelon structure as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, per-product production capacities are reduced over a specified mid-horizon band of periods, but not set to zero. Outside this band, capacities are higher and should be used to build inventory when beneficial.
- Waste cost parameters are increased for all products so that discarding inventory is more expensive, making overbuilding before the risk window more costly.
- Inventory at each product, location, and period remains non-negative and is updated from previous stock, allowed production, sales, and waste.
- Substitution behavior, zero lead times, and generous labor capacity are unchanged from the baseline.
- The objective is to minimize total cost while trading off early inventory builds against the increased waste cost and mid-season supply risk.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_supply_risk_v1", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 3615.226515295144, "DC2": 3960.4177892282714, "DC3": 2905.4633856970304, "DC4": 2644.980081532301, "DC5": 2228.6235235015124}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 320, 320, 320, 320, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 160, 160, 160, 160, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 200, 200, 200, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [277, 264, 371, 350, 399, 599, 767, 1010, 1207, 1067, 1449, 1297, 1227, 911, 746, 510, 481, 347, 340, 327], "SKU_Premium": [165, 173, 185, 168, 205, 309, 379, 426, 482, 619, 573, 669, 577, 398, 304, 247, 224, 165, 172, 148], "SKU_ShortLife": [104, 118, 128, 138, 152, 232, 287, 373, 416, 475, 589, 463, 409, 373, 267, 222, 169, 133, 129, 131]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 6.0, "SKU_Premium": 9.0, "SKU_ShortLife": 6.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 496,085
|
retail_f4_supply_risk_v2
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_supply_risk
Scenario ID: retail_f4_supply_risk_v2
[BUSINESS DESCRIPTION]
Business narrative:
The retailer faces persistent but moderate supply risk in the middle of the season. Production capacity is reduced over a mid-horizon band of periods, and waste becomes more expensive. Demand remains exogenous and local, with no backorders and no transshipment. The retailer must decide how much to build inventory before the risk window, balancing the danger of stockouts against the risk of obsolescence and waste.
Structure cues:
- The inventory, storage, and lost sales framework is the same single-echelon structure as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, per-product production capacities are reduced over a specified mid-horizon band of periods, but not set to zero. Outside this band, capacities are higher and should be used to build inventory when beneficial.
- Waste cost parameters are increased for all products so that discarding inventory is more expensive, making overbuilding before the risk window more costly.
- Inventory at each product, location, and period remains non-negative and is updated from previous stock, allowed production, sales, and waste.
- Substitution behavior, zero lead times, and generous labor capacity are unchanged from the baseline.
- The objective is to minimize total cost while trading off early inventory builds against the increased waste cost and mid-season supply risk.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_supply_risk_v2", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4483.315560571136, "DC2": 3606.5407916807635, "DC3": 2819.5786301383314, "DC4": 2948.8982552513794, "DC5": 2789.1397056477617}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 320, 320, 320, 320, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 160, 160, 160, 160, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 200, 200, 200, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [335, 281, 360, 397, 464, 605, 693, 866, 1212, 1334, 1258, 1258, 1160, 806, 634, 492, 403, 397, 334, 335], "SKU_Premium": [156, 143, 153, 194, 248, 263, 403, 410, 553, 678, 679, 678, 573, 507, 334, 297, 229, 192, 157, 167], "SKU_ShortLife": [136, 119, 128, 159, 164, 232, 248, 416, 494, 519, 543, 541, 424, 319, 301, 219, 156, 140, 146, 105]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 6.0, "SKU_Premium": 9.0, "SKU_ShortLife": 6.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 516,706.5
|
retail_f4_supply_risk_v3
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_supply_risk
Scenario ID: retail_f4_supply_risk_v3
[BUSINESS DESCRIPTION]
Business narrative:
The retailer faces persistent but moderate supply risk in the middle of the season. Production capacity is reduced over a mid-horizon band of periods, and waste becomes more expensive. Demand remains exogenous and local, with no backorders and no transshipment. The retailer must decide how much to build inventory before the risk window, balancing the danger of stockouts against the risk of obsolescence and waste.
Structure cues:
- The inventory, storage, and lost sales framework is the same single-echelon structure as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, per-product production capacities are reduced over a specified mid-horizon band of periods, but not set to zero. Outside this band, capacities are higher and should be used to build inventory when beneficial.
- Waste cost parameters are increased for all products so that discarding inventory is more expensive, making overbuilding before the risk window more costly.
- Inventory at each product, location, and period remains non-negative and is updated from previous stock, allowed production, sales, and waste.
- Substitution behavior, zero lead times, and generous labor capacity are unchanged from the baseline.
- The objective is to minimize total cost while trading off early inventory builds against the increased waste cost and mid-season supply risk.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_supply_risk_v3", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4099.018005363058, "DC2": 3737.8155386295125, "DC3": 3409.095382187711, "DC4": 3094.190919701873, "DC5": 2361.6437650828752}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 320, 320, 320, 320, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 160, 160, 160, 160, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 200, 200, 200, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [280, 305, 329, 344, 416, 493, 769, 828, 998, 1337, 1422, 1316, 1144, 886, 802, 536, 424, 412, 371, 311], "SKU_Premium": [165, 177, 168, 200, 216, 240, 318, 452, 536, 542, 612, 544, 522, 475, 330, 312, 230, 197, 185, 154], "SKU_ShortLife": [112, 111, 137, 135, 188, 243, 241, 396, 437, 570, 566, 500, 435, 397, 266, 212, 188, 160, 133, 142]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 6.0, "SKU_Premium": 9.0, "SKU_ShortLife": 6.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 476,425.5
|
retail_f4_supply_risk_v4
|
[SCENARIO]
Family: F4 (Dynamics and Disruptions)
Archetype: retail_f4_supply_risk
Scenario ID: retail_f4_supply_risk_v4
[BUSINESS DESCRIPTION]
Business narrative:
The retailer faces persistent but moderate supply risk in the middle of the season. Production capacity is reduced over a mid-horizon band of periods, and waste becomes more expensive. Demand remains exogenous and local, with no backorders and no transshipment. The retailer must decide how much to build inventory before the risk window, balancing the danger of stockouts against the risk of obsolescence and waste.
Structure cues:
- The inventory, storage, and lost sales framework is the same single-echelon structure as in the base scenario.
- Shelf life: Each product has a shelf life in periods. Inventory must be tracked by REMAINING LIFE.
VARIABLE DEFINITION: I[p,l,t,r] = inventory at START of period t with r periods remaining.
Convention: r=1 is OLDEST (sell first FIFO), r=shelf_life[p] is FRESHEST.
KEY EQUATIONS - implement EXACTLY as written, do NOT add or remove terms:
(1) Fresh inflow: I[p,l,t,SL] = Q[p,t] * demand_share[l]
- This is ONLY the inflow from production. Do NOT subtract sales here!
- Q is total production, demand_share distributes it to locations.
(2) Aging: I[p,l,t+1,r] = I[p,l,t,r+1] - sales[p,l,t,r+1] for r=1..SL-1
- Inventory tomorrow with r remaining = inventory today with r+1 remaining - sales
(3) Waste: W[p,l,t] = I[p,l,t,1] - sales[p,l,t,1]
- Items with r=1 that aren't sold become waste
(4) Sales availability: sales[p,l,t,r] <= I[p,l,t,r]
- Can only sell what you have in inventory
(5) Inventory holding cost: charged on (I[p,l,t,r] - sales[p,l,t,r]) for r >= 2
- Charge on END-of-period inventory (after sales), exclude expiring items (r=1)
- Storage capacity: sum over products of (cold_usage[p] * total_inventory[p,l,t]) <= cold_capacity[l]. These limits must be respected.
- In the JSON, per-product production capacities are reduced over a specified mid-horizon band of periods, but not set to zero. Outside this band, capacities are higher and should be used to build inventory when beneficial.
- Waste cost parameters are increased for all products so that discarding inventory is more expensive, making overbuilding before the risk window more costly.
- Inventory at each product, location, and period remains non-negative and is updated from previous stock, allowed production, sales, and waste.
- Substitution behavior, zero lead times, and generous labor capacity are unchanged from the baseline.
- The objective is to minimize total cost while trading off early inventory builds against the increased waste cost and mid-season supply risk.
[DATA SCHEMA]
{
"name": str, # scenario identifier
"periods": int, # number of time periods
"products": [str, ...], # list of product IDs
"locations": [str, ...], # list of location IDs
"shelf_life": {p: int}, # shelf life in periods per product
"lead_time": {p: int}, # order lead time per product (0 = same-period arrival)
"demand_curve": {p: [float, ...]}, # demand per product per period (0-indexed list)
"demand_share": {l: float}, # fraction of total demand at each location
"production_cap": {p: [float, ...]}, # max production per product per period (0-indexed list)
"cold_capacity": {l: float}, # storage capacity per location
"cold_usage": {p: float}, # storage units per unit of product
"labor_cap": {l: [float, ...]}, # labor hours per location per period (0-indexed list)
"labor_usage": {p: float}, # labor hours per unit sold
"return_rate": {p: float}, # fraction of sales returned next period
"costs": {
"purchasing": {p: float}, # cost per unit ordered
"inventory": {p: float}, # holding cost per unit per period
"waste": {p: float}, # cost per unit expired
"lost_sales": {p: float}, # penalty per unit of unmet demand
"fixed_order": float, # fixed cost per order placed
"transshipment": float # cost per unit transshipped
},
"constraints": {
"moq": float, # minimum order quantity (0 = no MOQ)
"pack_size": int, # order must be multiple of this (1 = no constraint)
"budget_per_period": float|null, # max purchasing cost per period
"waste_limit_pct": float|null # max waste as fraction of total demand
},
"network": {
"sub_edges": [[p_from, p_to], ...], # substitution: p_from's demand can be served by p_to
"trans_edges": [[l_from, l_to], ...]# transshipment: can ship from l_from to l_to
}
}
[DATA ACCESS]
- The variable `data` is pre-loaded. Do NOT use file I/O.
- Lists are 0-indexed (period t in model uses index [t-1] in data arrays)
CRITICAL - Network edges require tuple conversion for Gurobi:
sub_edges = [tuple(e) for e in data.get('network', {}).get('sub_edges', [])]
trans_edges = [tuple(e) for e in data.get('network', {}).get('trans_edges', [])]
[OUTPUT FORMAT]
- Import: import gurobipy as gp; from gurobipy import GRB
- Set Gurobi params: m.Params.OutputFlag = 0; m.Params.Threads = 1; m.Params.Seed = 0
- Print at end:
print(f"status: {{m.Status}}")
if m.Status == 2:
print(f"objective: {{m.ObjVal}}")
- Output ONLY executable Python code. No markdown, no explanations.
[TASK]
Write a GurobiPy script that models and solves this optimization problem.
|
{"name": "retail_f4_supply_risk_v4", "description": "Standard seasonal retail scenario.", "periods": 20, "products": ["SKU_Basic", "SKU_Premium", "SKU_ShortLife"], "locations": ["DC1", "DC2", "DC3", "DC4", "DC5"], "shelf_life": {"SKU_Basic": 10, "SKU_Premium": 8, "SKU_ShortLife": 4}, "lead_time": {"SKU_Basic": 0, "SKU_Premium": 0, "SKU_ShortLife": 0}, "cold_capacity": {"DC1": 4537.275036754515, "DC2": 3044.4506354810037, "DC3": 3163.599696417805, "DC4": 2913.458675798127, "DC5": 2149.257743710531}, "cold_usage": {"SKU_Basic": 1.0, "SKU_Premium": 3.0, "SKU_ShortLife": 1.2}, "production_cap": {"SKU_Basic": [800, 800, 800, 800, 800, 800, 320, 320, 320, 320, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800], "SKU_Premium": [400, 400, 400, 400, 400, 400, 160, 160, 160, 160, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400], "SKU_ShortLife": [500, 500, 500, 500, 500, 500, 200, 200, 200, 200, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]}, "labor_cap": {"DC1": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC2": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC3": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC4": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0], "DC5": [99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0, 99999.0]}, "labor_usage": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "return_rate": {"SKU_Basic": 0.0, "SKU_Premium": 0.0, "SKU_ShortLife": 0.0}, "demand_curve": {"SKU_Basic": [319, 299, 342, 413, 497, 500, 719, 966, 991, 1166, 1493, 1303, 1188, 1005, 674, 525, 433, 416, 312, 268], "SKU_Premium": [170, 138, 170, 185, 199, 273, 350, 453, 531, 653, 671, 560, 531, 514, 305, 233, 185, 174, 174, 156], "SKU_ShortLife": [120, 130, 118, 128, 181, 201, 304, 310, 459, 431, 464, 556, 422, 343, 320, 220, 160, 126, 144, 130]}, "demand_share": {"DC1": 0.25, "DC2": 0.2, "DC3": 0.2, "DC4": 0.2, "DC5": 0.15}, "costs": {"lost_sales": {"SKU_Basic": 50.0, "SKU_Premium": 80.0, "SKU_ShortLife": 40.0}, "inventory": {"SKU_Basic": 1.0, "SKU_Premium": 1.5, "SKU_ShortLife": 1.0}, "waste": {"SKU_Basic": 6.0, "SKU_Premium": 9.0, "SKU_ShortLife": 6.0}, "fixed_order": 0.0, "transshipment": 0.5, "purchasing": {"SKU_Basic": 10.0, "SKU_Premium": 20.0, "SKU_ShortLife": 15.0}}, "constraints": {"moq": 0, "pack_size": 1, "budget_per_period": null, "waste_limit_pct": null}, "network": {"sub_edges": [["SKU_Basic", "SKU_Premium"]], "trans_edges": []}}
|
OPTIMAL
| 498,825
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.