Loading [MathJax]/jax/output/CommonHTML/jax.js

Tuesday, February 25, 2025

Small MIP, proving optimality is difficult

This is a simple, smallish MIP model that is difficult to solve to proven optimality. The problem is stated as [1]:

I have grid of dimensions H and W of boolean variables. The only constraint is that if a variable is false then at least one of the adjacent variables (top, right, left, bottom, diagonals don't count) must be true. The goal is to minimize the number of true values in the grid.

A high-level mathematical representation of this can be:

High-level model
mini,jxi,jxi,j=0xi1,j+xi+1,j+xi,j1+xi,j+11xi,j{0,1}

Monday, February 24, 2025

Programming vs Modeling

I found another interesting GAMS model. Here, I wanted to demonstrate the difference between programming (implementing algorithms in a programming language) and modeling (building models and implementing them in a modeling tool). The problem is solving a shortest path problem given a sparse network with random costs. We compare three strategies:

  1. Implement Dijkstra's shortest path algorithm in GAMS,
  2. implement Dijkstra's shortest path algorithm in Python and
  3. use a simple LP model.  

One of the practical problems is how to represent and display the optimal shortest path in a meaningful and compact way. In some cases, this is more difficult than implementing the pure shortest path algorithm or model. 

Saturday, February 15, 2025

Network models with node capacities

Min-cost flow network model


A standard min-cost flow network model, formulated as a linear programming model, can look like:

Model 1: standard min-cost flow network model
min(i,j)Aci,jfi,jj|(j,i)Afj,i+supplyi=j|(i,j)Afi,j+demandiifi,j[0,capacityi,j]