Stefan-Endres / shgo

Simplicial Homology Global Optimization
https://stefan-endres.github.io/shgo
MIT License
44 stars 12 forks source link

Equality constraints not handled #27

Open ras9841 opened 5 years ago

ras9841 commented 5 years ago

It seems that the equality constraints, referenced in the documentation as eq, are not support. See https://github.com/Stefan-Endres/shgo/blob/master/shgo/_shgo.py#L495.

for cons in constraints:
  if cons['type'] is 'ineq':
    self.g_cons.append(cons['fun'])
    try:
      self.g_args.append(cons['args'])
    except KeyError:
      self.g_args.append(())
self.g_cons = tuple(self.g_cons)
self.g_args = tuple(self.g_args)

If I've missed how to specify, please let me know.

Stefan-Endres commented 5 years ago

The equality constraints are not used in the global sampling step of shgo, they are passed to the local solver routine (therefore they will only work if the chosen local minimization algorithm supports equality constraints, the default SLSQP (also the default of scipy.optimize.minimize) does support equality constraints).

If the final solutions of your problem instances are not KKT feasible points I would recommend trying different local solver methods from those available in scipy.optimize.minimize.

Ideally I would like to add methods to shgo reduce the dimensionality of the global problem by handling arbitrary equality constraints (through, for example, the implicit function theorem) since this will drastically speed up the problem and reduce sampling size, however, currently the only way to do this is to reformulate the objective function itself.

(I apologise for the late reply, annoyingly I have not been getting any of my feed notifications from Github lately).