<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _gh(self, x):
 """ Evaluates the constraint function values. """

        Pgen = x[self._Pg.i1:self._Pg.iN + 1] # Active generation in p.u.
        Qgen = x[self._Qg.i1:self._Qg.iN + 1] # Reactive generation in p.u.

        for i, gen in enumerate(self._gn):
            gen.p = Pgen[i] * self._base_mva # active generation in MW
            gen.q = Qgen[i] * self._base_mva # reactive generation in MVAr

        # Rebuild the net complex bus power injection vector in p.u.
        Sbus = self.om.case.getSbus(self._bs)

        Vang = x[self._Va.i1:self._Va.iN + 1]
        Vmag = x[self._Vm.i1:self._Vm.iN + 1]
        V = Vmag * exp(1j * Vang)

        # Evaluate the power flow equations.
        mis = V * conj(self._Ybus * V) - Sbus

        # Equality constraints (power flow).
        g = r_[mis.real,  # active power mismatch for all buses
               mis.imag]  # reactive power mismatch for all buses

        # Inequality constraints (branch flow limits).
        # (line constraint is actually on square of limit)
        flow_max = array([(l.rate_a / self._base_mva)**2 for l in self._ln])
        # FIXME: There must be a more elegant method for this.
        for i, v in enumerate(flow_max):
            if v == 0.0:
                flow_max[i] = Inf

        if self.flow_lim == IFLOW:
            If = self._Yf * V
            It = self._Yt * V
            # Branch current limits.
            h = r_[(If * conj(If)) - flow_max,
                   (It * conj(It)) - flow_max]
        else:
            i_fbus = [e.from_bus._i for e in self._ln]
            i_tbus = [e.to_bus._i for e in self._ln]
            # Complex power injected at "from" bus (p.u.).
            Sf = V[i_fbus] * conj(self._Yf * V)
            # Complex power injected at "to" bus (p.u.).
            St = V[i_tbus] * conj(self._Yt * V)
            if self.flow_lim == PFLOW: # active power limit, P (Pan Wei)
                # Branch real power limits.
                h = r_[Sf.real()**2 - flow_max,
                       St.real()**2 - flow_max]
            elif self.flow_lim == SFLOW: # apparent power limit, |S|
                # Branch apparent power limits.
                h = r_[(Sf * conj(Sf)) - flow_max,
                       (St * conj(St)) - flow_max].real
            else:
                raise ValueError

        return h, g