# Path: cameo/config.py

# 
# Path: cameo/strain_design/heuristic/evolutionary/objective_functions.py
# class MultiObjectiveFunction(ObjectiveFunction):
#     def __init__(self, objectives, *args, **kwargs):
#         super(MultiObjectiveFunction, self).__init__(*args, **kwargs)
#         failed = []
#         for i, objective in enumerate(objectives):
#             if not isinstance(objective, ObjectiveFunction):
#                 failed.append(i)
# 
#         if len(failed) > 0:
#             raise ValueError("Objectives %s are not instance of ObjectiveFunction" %
#                              ", ".join(str(objectives[i]) for i in failed))
# 
#         self.objectives = objectives
# 
#     def __getitem__(self, item):
#         return self.objectives[item]
# 
#     def __call__(self, model, solution, targets):
#         return Pareto(values=[o(model, solution, targets) for o in self.objectives])
# 
#     def worst_fitness(self, maximize=True):
#         return Pareto(values=[o.worst_fitness(maximize) for o in self.objectives], maximize=maximize)
# 
#     @property
#     def reactions(self):
#         return set(sum([o.reactions for o in self.objectives], []))
# 
#     def __len__(self):
#         return len(self.objectives)
# 
#     @property
#     def name(self):
#         return "MO: " + "|".join([of.name for of in self.objectives])
# 
#     def _repr_latex_(self):
#         return "\\begin{gather}\n" + "\\\\".join(o._repr_latex_() for o in self.objectives) + "\n\\end{gather}\n"


import numpy as np
import scipy
from cameo import config
from cameo.strain_design.heuristic.evolutionary.objective_functions import MultiObjectiveFunction
    from bokeh.plotting import show, figure
    from bokeh.models import ColumnDataSource
    from bokeh.io import push_notebook
if config.use_bokeh:


class IPythonBokehFitnessPlotter(object):
    __name__ = "IPython Bokeh Fitness Plot"

    def __init__(self, window_size=1000):
        self.iteration = 0
        self.window_size = window_size
        self.iterations = []
        self.fitness = []
        self.uuid = None
        self.plotted = False
        self.handle = None

    def _set_plot(self):
        self.plot = figure(title="Fitness plot", tools='', plot_height=400, plot_width=650)
        self.plot.xaxis.axis_label = "Iteration"
        self.plot.yaxis.axis_label = "Fitness"
        self.ds = ColumnDataSource(data=dict(x=[], y=[]))
        self.plot.circle('x', 'y', source=self.ds)
        self.handle = show(self.plot, notebook_handle=True)
        self.plotted = True

    def __call__(self, population, num_generations, num_evaluations, args):
        if not self.plotted:
            self._set_plot()

        self.iteration += 1
        self.iterations.append(self.iteration)

# Path: cameo/config.py

# 
# Path: cameo/strain_design/heuristic/evolutionary/objective_functions.py
# class MultiObjectiveFunction(ObjectiveFunction):
#     def __init__(self, objectives, *args, **kwargs):
#         super(MultiObjectiveFunction, self).__init__(*args, **kwargs)
#         failed = []
#         for i, objective in enumerate(objectives):
#             if not isinstance(objective, ObjectiveFunction):
#                 failed.append(i)
# 
#         if len(failed) > 0:
#             raise ValueError("Objectives %s are not instance of ObjectiveFunction" %
#                              ", ".join(str(objectives[i]) for i in failed))
# 
#         self.objectives = objectives
# 
#     def __getitem__(self, item):
#         return self.objectives[item]
# 
#     def __call__(self, model, solution, targets):
#         return Pareto(values=[o(model, solution, targets) for o in self.objectives])
# 
#     def worst_fitness(self, maximize=True):
#         return Pareto(values=[o.worst_fitness(maximize) for o in self.objectives], maximize=maximize)
# 
#     @property
#     def reactions(self):
#         return set(sum([o.reactions for o in self.objectives], []))
# 
#     def __len__(self):
#         return len(self.objectives)
# 
#     @property
#     def name(self):
#         return "MO: " + "|".join([of.name for of in self.objectives])
# 
#     def _repr_latex_(self):
#         return "\\begin{gather}\n" + "\\\\".join(o._repr_latex_() for o in self.objectives) + "\n\\end{gather}\n"


# Path: cameo/strain_design/heuristic/evolutionary/plotters.py
import numpy as np
import scipy
from cameo import config
from cameo.strain_design.heuristic.evolutionary.objective_functions import MultiObjectiveFunction
    from bokeh.plotting import show, figure
    from bokeh.models import ColumnDataSource
    from bokeh.io import push_notebook

if config.use_bokeh:


class IPythonBokehFitnessPlotter(object):
    __name__ = "IPython Bokeh Fitness Plot"

    def __init__(self, window_size=1000):
        self.iteration = 0
        self.window_size = window_size
        self.iterations = []
        self.fitness = []
        self.uuid = None
        self.plotted = False
        self.handle = None

    def _set_plot(self):
        self.plot = figure(title="Fitness plot", tools='', plot_height=400, plot_width=650)
        self.plot.xaxis.axis_label = "Iteration"
        self.plot.yaxis.axis_label = "Fitness"
        self.ds = ColumnDataSource(data=dict(x=[], y=[]))
        self.plot.circle('x', 'y', source=self.ds)
        self.handle = show(self.plot, notebook_handle=True)
        self.plotted = True

    def __call__(self, population, num_generations, num_evaluations, args):
        if not self.plotted:
            self._set_plot()

        self.iteration += 1
        self.iterations.append(self.iteration)

        if len(population) > 0: