Monday, March 29, 2021

Mathematical Notation

I often tell beginners in optimization modeling that before starting to code, they should get a piece of paper and write down the mathematical model. There are several reasons for this:


  • A mathematical model is a high-abstraction-level, compact expression of the problem. It should fit on one piece of paper for all but the most complex models (even then I would say the core of the model should fit on one piece of paper). If you are unable to write this down, you are not ready yet, and you are also unlikely to succeed in coding things up.
  • Mentally, it is easier to throw away some scribbled equations and start afresh than once you have invested time and effort into code. Code is not cast in stone, but sometimes it almost is. Psychologically, throwing away code is not always easy. (I believe it was Donald Knuth who said: a good approach is: write a program, throw it away and start over).  
  • When I am working on a model, I can reproduce the mathematical model from memory at any time on a piece of paper, on a blackboard, or on a PowerPoint sheet. I often find the physical process of writing down the model equations helps. This has something to do with different parts of the brain being involved in writing vs typing in and looking at some code on a screen.
  • I try to stick to the usual conventions. Like using \(x_i\) and never something like \(j_x\). It is amazing how much these conventions are hardwired in my brain and how much more difficult things become when we stray from these habits. In principle, a name is just a name, but clearly, that is not the case here. Mathematics loses its power as a communication tool when we don't use these conventions.
  • Of course, not everyone is wired the same way or has the same skills and experience. It is to be expected that different people work best in different ways. 
But sometimes I see math, which is really more confusing than it helps me. Like [1]:

# Mathematical representation Y[X,Y] - X[X,Y] <= 0 X[X,Y] - M*Y[X,Y] <= 0

This throws me off completely. What does this even mean? 

(Using X and Y as variable and as index can not be right here. Using an integer variable as index is used in Constraint Programming -- the element constraint but that is not the purpose here. Here it almost reads like a recursion).


References


3 comments:

  1. I agree that clear mathematical notation is essential to facilitating understanding. In the example you cite, I have no idea what Y[X,Y] - X[X,Y] <= 0 is supposed to mean.
    But even "standard" notation can be difficult to understand for people not familiar with interpreting math symbols. Published formulations seldom define their notation, which can make them difficult to understand.
    To help people struggling with notation, we recently wrote a blog post that explains the notation used in a simple formulation. The notation is made more concrete by then implementing the model in Excel. See https://www.solvermax.com/examples/on-the-shoulders-of-giants

    ReplyDelete
  2. My best bet is that the brackets represent commutators (https://en.wikipedia.org/wiki/Commutator) but it is hard to be sure about what exactly was meant without some context.

    ReplyDelete