code: def test_cma_mixed_integer_1_p_20_with_constraint(self):
      def c1(individual):
          if individual[0] + individual[1] < 0.1:
              return True
          return False
  
      def c2(individual):
          if individual[3] < 0.1:
              return True
          return False
  
      N = 5
      NGEN = 15000
      optimum = 0.015
  
      toolbox = base.Toolbox()
      toolbox.register("evaluate", benchmarks.sphere)
      restarts = 10
  
      # Allow a couple of restarts
      while restarts > 0:
          parent = (numpy.random.rand(N) * 2) + 1
  
          strategy = cma.StrategyActiveOnePlusLambda(
              parent, 0.5, [0, 0, 0.1, 0, 0], lambda_=20
          )
  
          toolbox.register(
              "generate",
              strategy.generate,
              ind_init=creator.__dict__[INDCLSNAME],
          )
          toolbox.register("update", strategy.update)
  
          best = None
  
          for gen in range(NGEN):
              # Generate a new population
              population = toolbox.generate()
  
              # Evaluate the individuals
              for individual in population:
                  constraint_violation = c1(individual), c2(individual)
                  if not any(constraint_violation):
                      individual.fitness.values = toolbox.evaluate(
                          individual
                      )
                  individual.fitness.constraint_violation = (
                      constraint_violation
                  )
  
                  if best is None or individual.fitness >= best.fitness:
                      best = individual
  
              if best.fitness.values[0] - optimum < 1e-7:
                  restarts = 0
                  break
  
              # Stop when we've reached some kind of optimum
              toolbox.update(population)
  
              if strategy.condition_number > 10e12:
                  # We've become unstable
                  break
  
          restarts -= 1
  
      self.assertLess(best.fitness.values[0] - optimum, 1e-7)
  
imports: from itertools import islice
  import random
  import unittest
  from deap import algorithms
  from deap import base
  from deap import benchmarks
  from deap.benchmarks.tools import hypervolume
  from deap import cma
  from deap import creator
  from deap import tools
label_desc: Use image node_id 3 for calling the TestSingleObjectiveConstrained obj's underlying member method code with example usage: obj.test_cma_mixed_integer_1_p_20_with_constraint() and returns: False, False, True, True