Designing a beer fermentation temperature profile#

The temperature profile of a lager fermentation trades batch time against flavour: warm fermentation is fast but produces diacetyl and esters, cold fermentation is clean but slow (de Andrés-Toro et al., 1998). The model of the Simulink library used in the EASY-IEC paper describes sugar, ethanol, biomass, diacetyl and ethyl acetate. The profile is a piecewise-linear curve through six knots between 9 and 16 °C; the evaluator sees the profile and the predicted concentrations and can drag the knots directly (the Lamarckian edit protocol of EASY-IEC).

Presets and their outcomes#

import matplotlib.pyplot as plt

import easyiec as ei
from easyiec.problems import BeerFermentation
from easyiec.strategies import InteractiveGA

problem = BeerFermentation()
for name, x in problem.presets().items():
    o = problem.objectives(x)
    print(f"{name:18s} ethanol {o['ethanol']:.1f} g/L, batch time {o['batch_time']:.0f} h, "
          f"diacetyl {o['diacetyl']:.2f} ppm, ethyl acetate {o['ethyl_acetate']:.2f} ppm")
isothermal 13 °C   ethanol 55.9 g/L, batch time 98 h, diacetyl 0.35 ppm, ethyl acetate 0.57 ppm
warm start         ethanol 58.0 g/L, batch time 75 h, diacetyl 0.62 ppm, ethyl acetate 1.51 ppm
free rise          ethanol 53.5 g/L, batch time 180 h, diacetyl 0.07 ppm, ethyl acetate 0.25 ppm
industrial-like    ethanol 55.8 g/L, batch time 97 h, diacetyl 0.35 ppm, ethyl acetate 0.57 ppm

Selections plus direct manipulation#

The simulated brewer occasionally drags a knot of the chosen profile towards its own ideal (edit_prob); edited profiles enter the population as new individuals (origin "edit").

user = ei.SimulatedUser(problem, target="industrial-like", noise=0.04, edit_prob=0.3, edit_step=0.4, seed=5)
result = ei.run(problem, InteractiveGA(pop_size=8), user, generations=12, seed=5)
edits = [i for i in result.log.individuals.values() if i.origin == "edit"]
print(len(edits), "edited profiles;", problem.describe(result.best.genome))
ei.viz.plot_history(result.log, problem, steps=[0, 5, 11], max_items=8, size=1.3)
plot 03 beer fermentation
3 edited profiles; Temperature knots every 30 h: [13.4, 12.8, 12.6, 11.6, 11.3, 11.8] °C. Batch time 90 h, final ethanol 54.4 g/L, diacetyl 0.46 (limit 0.5), ethyl acetate 0.47 (band 0.5–1.5), profile variation 2.4 °C.

<Figure size 1040x410 with 24 Axes>

The best profile#

fig, ax = plt.subplots(figsize=(6, 5))
problem.render(result.best.genome, ax=ax)
plot 03 beer fermentation
<Axes: >

The genealogy shows where the edits entered#

plot 03 beer fermentation

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

Gallery generated by Sphinx-Gallery