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

Tuesday, February 5, 2019

Logs made linear


Logarithm table

Nonlinear model


In [1] a question is asked about a nonlinear model:

How to solve:


Nonlinear model
minixiiailogxicxi{b1,b2,,bm}

where we have n variables xi, i=1,,n. This model looks nonlinear because of the logarithms.

Linear model


The condition xi{b1,b2,,bm} is essentially a table lookup. This can be modeled using binary variables: yi,j={1if xi=bj0otherwise With this definition we can write xi=jyi,jbjjyi,j=1iyi,j{0,1}

Maybe somewhat surprisingly, we can also calculate logxi using these yi,j: logxi=jyi,jlog(bj) This is very fortunate! We get the logs essentially for free! So our complete model can look like:

Linear model
minixixi=jyi,jbjlogxi=jyi,jlog(bj)jyi,j=1iiailogxicyi,j{0,1}

This model is now completely linear and we can use a standard Mixed Integer Programming (MIP) solver to solve it.

More compact models


If we want we can save a few variables and equations by substituting out the variable logxi.  It would make the model a bit more difficult to read: i,jailog(bj)yi,jc may not be completely obvious. Furthermore we can substitute out the variables xi and just keep the yi,j variables. Of course, you would need to recover, after the solve, the values for xi from the optimal values yi,j. That model would be very compact, but would need some explanation, as it is not completely self-explanatory.

Polynomial constraints?


In [1] someone suggested to form the polynomial equations (xib1)(xib2)(xibm)=0 and solve as a Nonlinear Programming (NLP) problem. This is surely not a good approach. If this was really a great idea, we would no longer need MIP solvers! Instead of binary variables, we just could form x(x1)=0 For an integer variable x{0,1,,n} we could write x(x1)(x2)(xn)=0 The reason why this does not work, is that we create a very difficult non-convex problem. Unless you use a global solver, an NLP solver will just get stuck in a local optimum (or may not find a feasible solution). Don't throw away your MIP solver yet.

Final remarks


Using random data I was able to solve a problem with n=m=100 in a few seconds. Of course this depends on the data: other instances may take more time.

This discussion reminds me a little bit of linear regression problems. In many cases, non-linearities appear in the data only, and although the regression model looks non-linear, it can actually be handled by linear regression approaches.

References


  1. How to solve the following optimization problem of mathematical programming?, https://math.stackexchange.com/questions/3090493/how-to-solve-the-following-optimization-problem-of-mathematical-programming
  2. MIP Modeling: from Sudoku to KenKen via Logarithms, https://yetanothermathprogrammingconsultant.blogspot.com/2016/10/mip-modeling-from-sudoku-to-kenken.html. The model to solve KenKen puzzles uses a similar approach.

No comments:

Post a Comment