How do I combine a linear equality constraint with a linear inequality constraint using Mystic?

45 Views Asked by At

I'm looking to use the Mystic library to try a bunch of different optimization algorithms for my problem. I am unfortunately unable to share the code for replication, but I can provide a skeleton here to get the idea across :-

import numpy as np

x0 = np.random.random(186)

# Require that the vector output of ineq <= 0
def ineq(x, *args):
  return np.random.random(30)

# Require that the vector output of eq == 0
def eq(x, *args):
  return np.random.random(20)

def objective(x, *args):
  return np.random.random()

from mystic.solvers import diffev2
from mystic.monitors import VerboseMonitor

# Parameter space is [0, Infinity)
bounds = [(0, None)] * len(x0)
result = diffev2(objective, x0=bounds, ...)

I have seen multiple examples of chaining decorators into a single penalty, and using the _and operator for combining constraints using symbolic equations, but I am unable to find the exact combination to enforce an equality and inequality constraint in functional form (within some tolerance of course).

Since I am relatively new to the library, I've not had much success searching the documentation as I am yet to get a feel for the style of the API. I'm pretty hopeful I can turn this experiment into a fruitful result. I would also appreciate being pointed to the right documentation/examples if this is something that is covered somewhere.

0

There are 0 best solutions below