Ejemplo n.º 1
0
        grad[1] = 0.

    return grad


Infinity = numpy.inf

# Create an instance of an NLPModel
nlp = NLPModel(n=2, m=2, name='Rosenbrock',
        Lvar=numpy.array([-1000,-Infinity]), Uvar=numpy.array([Infinity,1000]),
        Lcon=numpy.array([-2000,-1000]), Ucon=numpy.array([2000,1000]),
        x0 = numpy.array([-1.2, 1]))


# Assign an objective function and its gradient
nlp.obj = rosenbrock
nlp.grad = gradient_rosenbrock

# Assign constraints and its gradients
nlp.cons = constraint
nlp.igrad = gradient_constraint


# Translate this NLPy problem in a pyOpt problem

opt_prob = PyOpt_From_NLPModel(nlp)
print opt_prob

# Call the imported solver SNOPT
snopt = SNOPT()