artofscience / SAOR

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

interface with `scipy` (updated version) #94

Closed Giannis1993 closed 2 years ago

Giannis1993 commented 2 years ago

This PR includes a 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, according to the above link, one 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})
Giannis1993 commented 2 years ago

After this is approved, I can change the files in the examples/ directory as well.