artofscience / SAOR

Sequential Approximate Optimization Repository
GNU General Public License v3.0
5 stars 1 forks source link

Interface with `scipy` #93

Closed Giannis1993 closed 2 years ago

Giannis1993 commented 2 years ago

A working wrapper function for scipy. Related link can be found below: https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html#constrained-minimization-of-multivariate-scalar-functions-minimize One thing I am not 100% sure about is why defining the inequality constraints as a NonlinearConstraint object (instead of a dictionary that is currently implemented) gives a warning but still works. Note that in the above link it says you can define it both ways.

ineq_cons = optimize.NonlinearConstraint(self.constraints, -np.inf, 0, jac=self.constraints_der)
solution = optimize.minimize(self.objective, x0, bounds=bounds, method='trust-constr',
                                     jac=self.objective_der, constraints=ineq_cons, options={'gtol': 1e-6})