Search code examples
pythonoptimizationscipyscipy-optimizeminimization

Scipy optimise minimize


I am trying to solve the optimization problem with 4 variables. I have to give constraint in the scipy.optimize, the constraint is x[1] < x[2] < x[3] < x[4]. Is there any methodology to solve this problem in scipy.optimise


Solution

  • You can do a variable transformation, for example,

    y[1]=x[1]

    y[2] = x[2]-x[1]

    y[3] = x[3]-x[2]

    y[4] = x[4]-x[3]

    Then you can use constraints like y[2] > 0, y[3] > 0, etc.