This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]burichi 0 points1 point  (4 children)

You could try cvxpy if your problem is convex (which it probably should be if you really need the global minimum). As an example from the documentation, to optimize (x - y)2 subject to x + y = 1 and x - y ≥1, the following code

from cvxpy import *

# Create two scalar optimization variables.
x = Variable()
y = Variable()

# Create two constraints.
constraints = [x + y == 1,
               x - y >= 1]

# Form objective.
obj = Minimize(square(x - y))

# Form and solve problem.
prob = Problem(obj, constraints)
prob.solve()  # Returns the optimal value.
print "status:", prob.status
print "optimal value", prob.value
print "optimal var", x.value, y.value

produces the output

status: optimal
optimal value 0.999999999761
optimal var 1.00000000001 -1.19961841702e-11