Search spaces and the problem zoo#

An IEC problem has three parts: a search space (a Box of real, integer, log-scaled and categorical genes), a rendering that turns a genome into something a person can judge, and optionally a ground-truth utility that simulated users and benchmarks use. easyiec ships 25 problems from engineering, image processing, generative art, design, music and text.

A search space#

Strategies work in the unit cube; the box maps to and from the physical units.

import matplotlib.pyplot as plt
import numpy as np

import easyiec as ei
from easyiec.problems import list_problems, make
space = ei.Box(
    lower=[0.1, 1.0, 0, 0],
    upper=[10.0, 100.0, 5, 3],
    names=["gain", "time_constant", "filter_order", "mode"],
    kinds=["real", "real", "int", "cat"],
    log=[True, True, False, False],
    categories={3: ["P", "PI", "PID"]},
    units=["", "s", "", ""],
)
x = space.denormalize(np.array([0.5, 0.5, 0.5, 0.9]))
print(space.describe(x))        # gain and time constant at the geometric mean
- gain = 1 (range 0.1 .. 10)
- time_constant = 10 s (range 1 .. 100)
- filter_order = 2 (range 0 .. 5)
- mode = PID (range 0 .. 3)

The problem zoo#

list_problems() lists the registry; every problem renders a random genome in the same way, so a gallery can show any of them.

table = list_problems()
print(table[["name", "domain", "genes", "modality"]].to_string(index=False))

names = list(table["name"])
rng = np.random.default_rng(7)
ncols = 6
nrows = int(np.ceil(len(names) / ncols))
fig, axes = plt.subplots(nrows, ncols, figsize=(1.55 * ncols, 1.75 * nrows))
for ax, name in zip(axes.flat, names):
    p = make(name)
    x = p.presets().get("default", p.random(rng))
    ax.imshow(p.to_image(x, 160))
    ax.set_title(p.name, fontsize=7)
    ax.axis("off")
for ax in list(axes.flat)[len(names):]:
    ax.axis("off")
fig.tight_layout()
plt.show()
synthetic, curve, pid, cstr, beer, fuzzy, path, photo, segmentation, julia, attractor, ifs, flame, cppn, harmonograph, biomorph, lsystem, automaton, supershape, palette, chart, face, graph, melody, slogan
        name              domain genes modality
   synthetic           benchmark     5    image
       curve           benchmark     8    image
         pid     process control     5    image
        cstr     process control     4    image
        beer process engineering     6    image
       fuzzy     fuzzy modelling    10    image
        path            robotics    10    image
       photo    image processing    11    image
segmentation    image processing     7    image
       julia      generative art    10    image
   attractor      generative art    10    image
         ifs      generative art    27    image
       flame      generative art    44    image
        cppn      generative art    99    image
harmonograph      generative art    16    image
    biomorph     artificial life    11    image
     lsystem     artificial life    10    image
   automaton     complex systems    11    image
  supershape      graphic design    13    image
     palette      graphic design    15    image
       chart  data visualization    11    image
        face    human perception    13    image
       graph     network science    10    image
      melody               music    19    image
      slogan       communication  text     text

Total running time of the script: (0 minutes 1.941 seconds)

Gallery generated by Sphinx-Gallery