def generate_model(self, t_start=None):
        #
        # Setup
        #
        m = po.ConcreteModel()
        o = self.config_model
        d = self.data
        self.m = m
        self.t_start = t_start
        self.t_max_demand = self._get_t_max_demand()

        #
        # Sets
        #

        # Time steps
        if self.mode == 'plan':
            m.t = po.Set(initialize=d._dt.index, ordered=True)
        elif self.mode == 'operate':
            self._set_t_end()
            m.t = po.Set(initialize=d._dt.loc[self.t_start:self.t_end].index,
                         ordered=True)
        # Carriers
        m.c = po.Set(initialize=d._c, ordered=True)
        # Locations
        m.x = po.Set(initialize=d._x, ordered=True)
        # Cost classes
        m.k = po.Set(initialize=d._k, ordered=True)
        #
        # Technologies and various subsets of technologies
        #
        m.y = po.Set(initialize=d._y, ordered=True)
        # Production technologies
        m.y_prod = po.Set(initialize=d._y_prod, within=m.y, ordered=True)
        # Production technologies
        m.y_con = po.Set(initialize=d._y_con, within=m.y, ordered=True)
        # Production/consumption technologies
        m.y_pc = po.Set(initialize=d._y_pc, within=m.y, ordered=True)
        # Transmission technologies
        m.y_trans = po.Set(initialize=d._y_transmission, within=m.y,
                           ordered=True)
        # Conversion technologies
        m.y_conv = po.Set(initialize=d._y_conversion, within=m.y,
                          ordered=True)
        # Technologies with specified `r`
        m.y_def_r = po.Set(initialize=d._y_def_r, within=m.y)
        # Technologies with specified `e_eff`
        m.y_def_e_eff = po.Set(initialize=d._y_def_e_eff, within=m.y)
        # Technologies that allow `rb`
        m.y_rb = po.Set(initialize=d._y_rb, within=m.y)
        # Technologies with parasitics
        m.y_p = po.Set(initialize=d._y_p, within=m.y)
        # Technologies without parasitics
        m.y_np = po.Set(initialize=set(d._y) - set(d._y_p), within=m.y)

        #
        # Parameters
        #

        self.param_sets = {'r': m.y_def_r,
                           'a': m.y_def_r,
                           'e_eff': m.y_def_e_eff}
        for param in d.params:
            initializer = self._param_populator(d[param])
            y = self.param_sets[param]
            setattr(m, param, po.Param(y, m.x, m.t, initialize=initializer,
                                       mutable=True))

        s_init_initializer = lambda m, y, x: float(d.s_init.at[x, y])
        m.s_init = po.Param(m.y_pc, m.x, initialize=s_init_initializer,
                            mutable=True)

        #
        # Variables and constraints
        #

        # 1. Required
        constr = [constraints.base.node_resource,
                  constraints.base.node_energy_balance,
                  constraints.base.node_constraints_build,
                  constraints.base.node_constraints_operational,
                  constraints.base.node_constraints_transmission,
                  constraints.base.node_parasitics,
                  constraints.base.node_costs,
                  constraints.base.model_constraints]
        if self.mode == 'plan':
            constr += [constraints.planning.system_margin,
                       constraints.planning.node_constraints_build_total]
        for c in constr:
            self.add_constraint(c)

        # 2. Optional
        if o.get_key('constraints', default=False):
            for c in o.constraints:
                self.add_constraint(_load_function(c))

        # 3. Objective function
        default_obj = 'constraints.objective.objective_cost_minimization'
        objective = o.get_key('objective', default=default_obj)
        self.add_constraint(_load_function(objective))
Subclasses should call this method whenever change events occur.
dataset/ETHPy150Open calliope-project/calliope/calliope/core.py/Model.generate_model--crossover with--dataset/ETHPy150Open zzzeek/sqlalchemy/lib/sqlalchemy/ext/mutable.py/MutableComposite.changed