A Concise Manual on How to Write an Optimization Model

A Concise Manual on How to Write an Optimization Model

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 #

  1. Pause and think. (Let the other person know you are thinking.)

  2. 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.?
  3. 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 #

  1. Call out the name of the model and method (if any).

  2. Draft the Model in Plain Language, e.g., we aim to:

    • optimize [primary metric]
    • by choosing [key decisions]
    • subject to [key constraints]
  3. 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:

  1. Notations
    1. 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
    2. Parameters and Data:
      • $C_{ij}$: unit shipping cost from $i$ to $j$
      • $D_{i}$: product $i$ demand
      • $M$: large constant for big-M constraints
    3. Decision Variables:
      • $x_{ij}$: units shipped from $i$ to $j$
      • $y_{j}$: 1 if warehouse $j$ is open, 0 otherwise
  2. Constraints
    1. Balancing / linking constraints that tie decision variables together.
    2. Problem-specific constraints derived from business or domain logic.
    3. Variable type and bounds, e.g., binary, integer, non-negative, etc..
  3. Objective Function

Outcome:
A clear optimization model.



4. Summary and Wrap-Up #

  1. Mathematical statement: Combine the notations, objective, and constraints into a single cohesive,symbolic-indexed form.
  2. Optional: vectorized / tensorized form: Re-express the model using matrix/vector notation for more compact representation and faster computation.
  3. 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).
  4. 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.