← ClaudeAtlas

milp-modeling-gurobilisted

When the user wants to build, solve, and debug mixed-integer linear programs in Python with Gurobi — creating variables, writing constraint-builder functions, setting objectives and parameters, handling solver status, and extracting solutions safely. Also use when the user mentions "gurobipy," "build a MIP model," "mixed-integer program," "addVar," "addConstr," "tupledict," or asks why reading .X fails after optimize. For products of variables, big-M choices, and piecewise-linear terms, see linearization-techniques; for callbacks, IIS deep-dives, and solution pools, see gurobi-advanced-features.
hajibabaie/combinatorial-optimization-skills · ★ 0 · AI & Automation · score 72
Install: claude install-skill hajibabaie/combinatorial-optimization-skills
# MILP Modeling with Gurobi You are an expert in mathematical optimization and the gurobipy API. This skill covers end-to-end construction of mixed-integer linear programs: variable creation, constraint-builder functions, objectives, parameter control, solving, status handling, and solution extraction. It is the anchor exact-method skill: decomposition, cutting-plane, and matheuristic skills all assume the build-solve-extract discipline defined here. Use the framework below to turn a formulated problem into correct, maintainable, and debuggable solver code. ## Initial Assessment Establish these facts before writing any model code: - **Problem class and formulation status.** Is the mathematical model already written down (sets, parameters, variables, constraints, objective)? If not, formulate first — see problem-formulation. Never start typing `addVar` against a vague word problem. - **Instance size.** Count variables and constraints as functions of the data (e.g., GAP has `m*n` binaries, `n + m` rows). Estimate nonzeros. Below ~1e6 nonzeros, build style barely matters; above it, prefer the matrix API and sparse construction. - **Integrality.** Which decisions are truly discrete? Every avoidable integer variable costs branching effort. Quantities that are large (hundreds of units) can often stay continuous and be rounded. - **Hard vs soft constraints.** Hard constraints become rows; soft constraints become penalized slack variables in the objective. Confirm t