Non-Linear Optimization

Non-Linear Optimization

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


Article content

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

Article content

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?



Article content


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?

Vaibhavnath J.

Operations Research Analyst at GAMS DEVELOPMENT CORPORATION

7mo

Too late to join the party?! Here's GAMSPy and Baron in action.

  • No alternative text description for this image
Michal Adamaszek

Optimization Specialist at MOSEK ApS

7mo

It is a convex conic problem which can be solved directly by any SOCP-capable solver (more natural with the power cone though), for example here is MOSEK called from CVXPY: import cvxpy as cp x=cp.Variable(5) prob = cp.Problem(cp.Minimize(cp.inv_pos(x[0]) + sum(cp.inv_prod(x[:i]) for i in range(2,6))), [cp.sum(x) == 5]) prob.solve(solver=cp.MOSEK, verbose=True) print(x.value)

Bill Tubbs

Management consultant / process optimization specialist

7mo

What's the background to this problem? I didn't think about it too much but plugged it into CasADi and got this solution in 8 ms after 6 iterations of IPOPT. Is this a global optimum or just one local minimum?

  • No alternative text description for this image
Like
Reply
Daniel Darabos

Chief Software Architect at LynxKite

7mo

I love all the different solutions! Here's a pure Python option with Newton's method.

  • No alternative text description for this image
Mark Tolani

Systematic Trading Quant Lead | Software Engineering Lead | Equities Trading System Development, Backtesting, Portfolio Optimization, Fixed Income, Credit

7mo

16ms using scipy.optimize

  • No alternative text description for this image

To view or add a comment, sign in

More articles by Meinolf Sellmann

  • Ant Race

    This year's Edelman Winners were US Cycling. Using optimization in sports has become a staple for teams that want to…

  • Precision Farming

    Farmer Ben from DS City needs help deciding what crops to plant and what treatments to use. He is thinking about next…

    2 Comments
  • Tariffs

    In these weeks, a lot of supply planners are grappling with the uncertainty of potential tariffs. The fundamental…

    3 Comments
  • Balancing Supply and Demand

    We have three factories from where we service three clients. The first factory can provide 400 units, the second 300…

    2 Comments
  • OR 2025-2030

    We asked 25 AI/OR researchers, tool makers, developers, and practitioners what they expect the second half of this…

    14 Comments
  • Game of Life

    In Conway's game of life (https://en.wikipedia.

    1 Comment
  • More Needles, More Haystack: Or The Irony of Optimization

    In this article, we discuss examples where an increase in performance potential frequently leads to a decline in actual…

    8 Comments
  • Can Simulation Entice Cooperation in Non-Zero-Sum Games?

    In honor of Joe Halpern's 70ies Birthday, a year ago Vincent Conitzer posted this puzzle: https://www.cs.

  • The Unquantified Risk

    In decision science pipelines, we typically first estimate data, such as demand, travel times, price sensitivity etc…

    1 Comment
  • A Problem Larger Than the Universe

    In this puzzle, you are not asked to solve a concrete optimization problem, but to provide an estimate. Easy? The…

Explore topics