Puzzle: Non-Linear Optimization

Puzzle: Non-Linear Optimization

In todays puzzle, we solve a simple non-linear optimization problem with only five variables. Can you do it?


In this post, Lee Chan Lye posed this question. One possible answer was given by Francesco Vissani, who used calculus to derive that extrema are present for:

  • u=v(1+v)
  • z=u(1+v²)
  • y=z(1+u v²)
  • x=y(1+z u v²)

 

This then means that we need to find the root of

We will probably want to use Wolfram Alpha at this point to find that the only real (and in fact: irrational) positive root is v=0.519362. The other variables then follow from there. Finally, we would need to check that this in fact leads to a minimum.

A much simpler way is to model the problem in InsideOpt Seeker. Consider using this Colab to solve this problem on your own. Can you do it?




Here is a potential solution. Note how we use the genotype trick to avoid the equality constraint: We choose variables with values between 0.1 and 5 and then normalize these by 5 times their sum to make the choice consistent with the side constraint.

import seeker as skr

# create environment
env = skr.Env("license.sio")

# declare decision variables
xi = [env.continuous(0.1, 5) for _ in range(5)]

# normalize decisions to sum to 5
sum_xi = env.sum(xi)
x = [5 * a / sum_xi for a in xi]

# compute objective
prod = [x[0]]
for i in range(1, 5):
    prod.append(prod[i - 1] * x[i])
rec = [1 / p for p in prod]
obj = env.sum(rec)

# minimize
env.set_report(0.004)
env.set_restart_likelihood(0.01)
env.minimize(obj, 0.02)

# report and clean up
print([a.get_value() for a in x])
env.end()

This produces:

At time 0.004170: Objective = 3.981216; Status = Feasible

At time 0.008311: Objective = 3.859061; Status = Feasible

At time 0.012592: Objective = 3.858593; Status = Feasible

At time 0.016713: Objective = 3.858593; Status = Feasible

[1.4744021370488531, 1.2151879939867523, 1.0019348635246512, 0.7890967993764137, 0.5193782060633303]


Does your business run linearly? Then why are you still using a linear solver?