Here is a concise guide on writing an optimization model. It is organized to
- Fit the natural flow of a technical interview discussion
- Serve as a practical reference when collaborating with business or production teams on real-world problems.
The structure combines ideas from software system design process and the AIMMS modeling handbook. See for reference:
1. Understand the Problem #
-
Pause and think. (Let the other person know you are thinking.)
-
Gather requirements. Try re-stating the following in your own words:
- Business Context: What is the real-world scenario — e.g., scheduling, routing, pricing?
- Key Objectives: What exactly needs to be optimized — e.g., cost, profit, load?
- Constraints: Are there regulatory constraints, capacity limits, budget constraints, etc.?
-
Ask clarifying questions and define scope. Consider:
- Functionality. Specify the precise format of the input and output.
- Time specification. Specify the precise time and order that events take place.
- Does this happen in the beginning of the period? or at the end?
- What is the frequency of execution?
- What is each element / terminology in the business context? Ask for examples.
- What is the realistic goal? Do we want approximation or exact solution?
- What is the data availability?
- Any edge cases?
Outcome:
A clear problem definition and scope.
Ensure all stakeholders share the same understanding.
2. Propose a Verbal Statement of the Model #
-
Call out the name of the model and method (if any).
-
Draft the Model in Plain Language, e.g., we aim to:
- optimize [primary metric]
- by choosing [key decisions]
- subject to [key constraints]
-
Secure Buy-In from Stakeholders. Collect feedback on feasibility and correctness before proceeding to a deeper, more technical design.
Outcome:
Stakeholder alignment on the high-level objective and constraints.
Ensure no major requirement is overlooked.
3. Design Deep Dive: Model Elements #
To move from verbal understanding to a formal mathematical representation, define the following:
- Notations
- Indices and sets. Examples:
- $i \in \mathcal{I}$: set of products
- $j \in \mathcal{J}$: set of warehouses
- $t \in \mathcal{T}$: set of time periods
- Parameters and Data:
- $C_{ij}$: unit shipping cost from $i$ to $j$
- $D_{i}$: product $i$ demand
- $M$: large constant for big-M constraints
- Decision Variables:
- $x_{ij}$: units shipped from $i$ to $j$
- $y_{j}$: 1 if warehouse $j$ is open, 0 otherwise
- Indices and sets. Examples:
- Constraints
- Balancing / linking constraints that tie decision variables together.
- Problem-specific constraints derived from business or domain logic.
- Variable type and bounds, e.g., binary, integer, non-negative, etc..
- Objective Function
Outcome:
A clear optimization model.
4. Summary and Wrap-Up #
- Mathematical statement: Combine the notations, objective, and constraints into a single cohesive,symbolic-indexed form.
- Optional: vectorized / tensorized form: Re-express the model using matrix/vector notation for more compact representation and faster computation.
- Implementation / Execution Plan
- Software Tools: Decide on solver frameworks (e.g., Python + CVXPY + Gurobi, etc.).
- Deployment: Integration with data pipelines, user interfaces, or scheduling systems.
- Verification: Plan test cases (minimal representative examples, edge cases, stress tests).
- Wrap Up
- Summarize key trade-offs.
- Revisit alignment with the business problem.
- Outline next steps for iteration or scale-up (e.g., more constraints, refined objective).
Final Notes #
- Keep it Clear: Use simple terms when presenting to non-technical stakeholders.
- Start Small: Begin with a basic model, test it, then expand.
- Stay Focused: Keep checking if the model meets business needs as they change.