Dataset Viewer
Auto-converted to Parquet Duplicate
scenario_id
stringlengths
17
34
prompt_schema
stringlengths
4.45k
7.03k
prompt_full
stringlengths
7.02k
13.4k
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.
[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] The following JSON contains all instance data. Parse it directly in your code. ```json { "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": [] } } ``` [OUTPUT FORMAT] - Import: import gurobipy as gp; from gurobipy import GRB; import json - 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: 1. Parses the JSON data above (use json.loads on the string) 2. Models and solves the optimization problem 3. Prints status and objective value
{"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.
[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] The following JSON contains all instance data. Parse it directly in your code. ```json { "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": [] } } ``` [OUTPUT FORMAT] - Import: import gurobipy as gp; from gurobipy import GRB; import json - 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: 1. Parses the JSON data above (use json.loads on the string) 2. Models and solves the optimization problem 3. Prints status and objective value
{"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.
[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] The following JSON contains all instance data. Parse it directly in your code. ```json { "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": [] } } ``` [OUTPUT FORMAT] - Import: import gurobipy as gp; from gurobipy import GRB; import json - 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: 1. Parses the JSON data above (use json.loads on the string) 2. Models and solves the optimization problem 3. Prints status and objective value
{"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.
[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] The following JSON contains all instance data. Parse it directly in your code. ```json { "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": [] } } ``` [OUTPUT FORMAT] - Import: import gurobipy as gp; from gurobipy import GRB; import json - 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: 1. Parses the JSON data above (use json.loads on the string) 2. Models and solves the optimization problem 3. Prints status and objective value
{"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.
[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] The following JSON contains all instance data. Parse it directly in your code. ```json { "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": [] } } ``` [OUTPUT FORMAT] - Import: import gurobipy as gp; from gurobipy import GRB; import json - 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: 1. Parses the JSON data above (use json.loads on the string) 2. Models and solves the optimization problem 3. Prints status and objective value
{"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.
[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] The following JSON contains all instance data. Parse it directly in your code. ```json { "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": [] } } ``` [OUTPUT FORMAT] - Import: import gurobipy as gp; from gurobipy import GRB; import json - 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: 1. Parses the JSON data above (use json.loads on the string) 2. Models and solves the optimization problem 3. Prints status and objective value
{"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.
[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] The following JSON contains all instance data. Parse it directly in your code. ```json { "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": [] } } ``` [OUTPUT FORMAT] - Import: import gurobipy as gp; from gurobipy import GRB; import json - 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: 1. Parses the JSON data above (use json.loads on the string) 2. Models and solves the optimization problem 3. Prints status and objective value
{"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.
[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] The following JSON contains all instance data. Parse it directly in your code. ```json { "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": [] } } ``` [OUTPUT FORMAT] - Import: import gurobipy as gp; from gurobipy import GRB; import json - 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: 1. Parses the JSON data above (use json.loads on the string) 2. Models and solves the optimization problem 3. Prints status and objective value
{"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]\nFamily: F1 (Core Operations)\nArchetype: retail_f1_base\nScenario ID: retail_f1_base_v3(...TRUNCATED)
"[SCENARIO]\nFamily: F1 (Core Operations)\nArchetype: retail_f1_base\nScenario ID: retail_f1_base_v3(...TRUNCATED)
"{\"name\": \"retail_f1_base_v3\", \"description\": \"Standard seasonal retail scenario.\", \"period(...TRUNCATED)
OPTIMAL
370,433.5
retail_f1_base_v4
"[SCENARIO]\nFamily: F1 (Core Operations)\nArchetype: retail_f1_base\nScenario ID: retail_f1_base_v4(...TRUNCATED)
"[SCENARIO]\nFamily: F1 (Core Operations)\nArchetype: retail_f1_base\nScenario ID: retail_f1_base_v4(...TRUNCATED)
"{\"name\": \"retail_f1_base_v4\", \"description\": \"Standard seasonal retail scenario.\", \"period(...TRUNCATED)
OPTIMAL
371,353
End of preview. Expand in Data Studio

RetailOpt-190: A Retail Supply Chain Benchmark for Text-to-Optimization

RetailOpt-190 is a solver-validated benchmark for evaluating semantic reliability in text-to-optimization. It tests whether LLM-based agents can reconstruct the intended optimization structure—not just produce runnable code.

Dataset Summary

RetailOpt-190 contains 190 retail supply chain optimization instances designed to test compositional consistency in LLM-generated optimization code. Each instance includes a natural-language problem description, structured JSON data, and ground truth solutions from a validated MILP solver.

The benchmark spans 8 scenario families and 38 archetypes covering core retail planning mechanisms:

Family Name Archetypes Key Mechanisms
F1 Core Operations 4 Multi-period inventory, seasonal demand, perishability
F2 Assortment & Substitution 6 Product substitution, promotions, ultra-short shelf life
F3 Resource Constraints 4 Storage bottleneck, supply bottleneck, volumetric limits
F4 Demand Dynamics 6 Demand surge, supply risk, peak failure
F5 Feasibility Stress 4 Impossible demand, storage overflow, strict service traps
F6 Discrete Logistics 4 Lead time, MOQ, pack size, fixed order cost
F7 Network & Multi-Echelon 6 Transshipment, hub-spoke, multi-sourcing
F8 Omni-channel 4 Reverse logistics, labor constraints, sustainability

Languages

English

Two Prompt Formats

RetailOpt-190 provides two prompt formats for different evaluation scenarios:

Format Field Data Location Use Case
Schema-based prompt_schema External (runtime) Large datasets, tests data access patterns
Data-embedded prompt_full In prompt Direct comparison with other benchmarks

Why Two Formats?

Most existing benchmarks (NL4Opt, MAMO, IndustryOR) embed data directly in prompts. RetailOpt-190 supports both approaches to enable:

  1. Fair comparison: Use prompt_full when comparing with other benchmarks in unified evaluation frameworks
  2. Scalability: Use prompt_schema for production scenarios with large datasets

Both formats provide the same semantic information—only the data delivery method differs.

Dataset Structure

Data Fields

Field Type Description
scenario_id string Unique scenario identifier (e.g., retail_f1_base_v0)
prompt_schema string Schema-based prompt (data loaded at runtime via data variable)
prompt_full string Data-embedded prompt (full JSON data in prompt)
data string JSON-formatted instance data (parse with json.loads())
reference_status string Ground truth solver status (OPTIMAL, INFEASIBLE, etc.)
reference_objective float Ground truth objective value (null if infeasible)

Data Splits

Split Examples
test 190

Usage

Loading the Dataset

from datasets import load_dataset
import json

dataset = load_dataset("Jacoblian/RetailOpt-190", split="test")
sample = dataset[0]

print(sample['scenario_id'])        # e.g., "retail_f1_base_v0"
print(sample['prompt_schema'][:200])  # Schema-based prompt
print(sample['prompt_full'][:200])    # Data-embedded prompt

Option A: Schema-based Evaluation

Use prompt_schema when you need external data loading (matches production scenarios):

from datasets import load_dataset
import json

dataset = load_dataset("Jacoblian/RetailOpt-190", split="test")

for sample in dataset:
    prompt = sample['prompt_schema']
    data = json.loads(sample['data'])

    generated_code = your_llm(prompt)
    exec(generated_code, {'data': data})  # Data pre-loaded

    print(f"Reference: {sample['reference_status']}, {sample['reference_objective']}")

Option B: Data-embedded Evaluation

Use prompt_full for direct text-to-solution evaluation (compatible with other benchmarks):

from datasets import load_dataset

dataset = load_dataset("Jacoblian/RetailOpt-190", split="test")

for sample in dataset:
    prompt = sample['prompt_full']  # Data is already in prompt

    generated_code = your_llm(prompt)
    exec(generated_code)  # Code parses JSON from prompt itself

    print(f"Reference: {sample['reference_status']}, {sample['reference_objective']}")

Evaluation Metrics

  • Execution Rate: Percentage of instances that run without error
  • Accuracy: Percentage matching ground truth (status + objective within tolerance)
  • Silent Failure Rate: Executable code with incorrect answer

Accuracy Tolerances

Family Problem Type Tolerance
F1-F5, F7-F8 LP / easy MIP 0.01%
F6 Hard MIP (MOQ, pack-size) 10%

Dataset Creation

Source Data

All instances are synthetically generated from 38 archetype specifications. Each archetype is instantiated with 5 numerical variants (v0-v4) via controlled parameter perturbations.

Annotations

Ground truth solutions are computed using a validated MILP solver (Gurobi) with the following settings:

  • TimeLimit: 60 seconds
  • MIPGap: 1%
  • Threads: 1

Additional Information

Citation

@article{lian2026reloop,
  author    = {Junbo Jacob Lian and Yujun Sun and Huiling Chen and Chaoyu Zhang and Chung-Piaw Teo},
  title     = {ReLoop: Detecting Silent Failures in LLM-Generated Optimization Code via Behavioral Verification},
  journal   = {arXiv preprint},
  year      = {2026}
}

License

  • Code: MIT
  • Data: CC BY 4.0

Related Resources

Downloads last month
30