Computes total cost for the generator at the given output level.
778329
def total_cost(self, p=None, p_cost=None, pcost_model=None):
        
        p = self.p if p is None else p
        p_cost = self.p_cost if p_cost is None else p_cost
        pcost_model = self.pcost_model if pcost_model is None else pcost_model

        p = 0.0 if not self.online else p

        if pcost_model == PW_LINEAR:
            n_segments = len(p_cost) - 1
            # Iterate over the piece-wise linear segments.
            for i in range(n_segments):
                x1, y1 = p_cost[i]
                x2, y2 = p_cost[i + 1]
                m = (y2 - y1) / (x2 - x1)
                c = y1 - m * x1
                if x1 <= p <= x2:
                    result = m*p + c
                    break
            else:
#                print "TOTC:", self.name, p, self.p_max, p_cost

#                raise ValueError, "Value [%f] outwith pwl cost curve." % p

                # Use the last segment for values outwith the cost curve.
                logger.error("Value [%f] outside pwl cost curve [%s]." %
                             (p, p_cost[-1][0]))
                result = m*p + c
        elif pcost_model == POLYNOMIAL:
#            result = p_cost[-1]
#            for i in range(1, len(p_cost)):
#                result += p_cost[-(i + 1)] * p**i
            result = polyval(p_cost, p)
        else:
            raise ValueError

        if self.is_load:
            return -result
        else:
            return result
1132840
def compute_total(self, precision=None):
        '''
        
        '''
        return quantize((self.compute_gross(precision) +
                        self.compute_taxes(precision) -
                        self.compute_discounts(precision)),
                        places=precision)
1014407
def _offbidToCase(self):
        
        generators = [g for g in self.case.generators if not g.is_load]
        vLoads = [g for g in self.case.generators if g.is_load]

        # Convert offers into piecewise linear segments and update limits.
        for g in generators:
#            print "G: ", g.p_min, g.p_max, g.p_cost, g.pcost_model

            g.offers_to_pwl(self.offers)

#            print "GG:", g.p_min, g.p_max, g.p_cost, g.pcost_model

        for vl in vLoads:
#            print "L: ", vl.p_min, vl.p_max, vl.p_cost

            vl.bids_to_pwl(self.bids)

#            print "VL:", vl.p_min, vl.p_max, g.q_min, g.q_max, vl.p_cost

        # Move p_min and p_max limits out slightly to avoid problems with
        # lambdas caused by rounding errors when corner point of cost function
        # lies at exactly p_min or p_max.
        for g in generators: # Skip dispatchable loads.
            g.p_min -= 100 * self.violation
            g.p_max += 100 * self.violation
1100552
def compute_total(self, precision=None):
        '''
        
        '''
        return quantize(sum([group.compute_total(precision) for group
                             in self.__groups]), places=precision) or ZERO
882588
def total_energy(self):
        
        return sum(sum(self._recip)) + sum(sum(self._real)) + sum(self._point) + self._charged_cell_energy
346814
def _cost_method(self, *args, **kwargs):
        
        return self.prox_op.cost(self.linear_op.op(args[0]), **kwargs)
983943
def finish_level(self):
        

        # assumptions to remove
        self.garbage = set()

        # sum of weights of the remaining levels
        sumw = sum([w * len(self.wstr[w]) for w in self.blop[(self.levl + 1):]])

        # trying to harden selectors and sums
        for s in self.sels + self.sums:
            if self.wght[s] > sumw:
                self.oracle.add_clause([s])
                self.garbage.add(s)

        if self.verbose > 1:
            print('c hardened:', len(self.garbage))

        # remove unnecessary assumptions
        self.filter_assumps()
73971
def calculate_energy(self, energies):
        
        return sum([amt * energies[c] for amt, c in zip(self._coeffs,
                                                        self._all_comp)])
124981
def compute_partial_energy(self, removed_indices):
        
        total_energy_matrix = self.total_energy_matrix.copy()
        for i in removed_indices:
            total_energy_matrix[i, :] = 0
            total_energy_matrix[:, i] = 0
        return sum(sum(total_energy_matrix))
204069
public void setWithTotal() throws IOException {
    if (collectorType.equals(DataCollector.COLLECTOR_TYPE_LIST)) {
      if (segmentName != null) {
        throw new IOException("can't get total with segmentRegistration");
      } else {
        withTotal = true;
      }
    } else {
      throw new IOException(
          "can't get total for dataCollector of type " + collectorType);
    }
  }
873339
def total_power(self):
        
        power = self.average_current * self.voltage
        return round(power, self.sr)
949648
def generator(self, t):
        """"""
        return np.power(-np.log(t), self.theta)
69986
def build_cost(self, labels, logits):
    
    op = logits.op
    if "softmax" in str(op).lower():
      logits, = op.inputs

    with tf.variable_scope('costs'):
      xent = tf.nn.softmax_cross_entropy_with_logits(
          logits=logits, labels=labels)
      cost = tf.reduce_mean(xent, name='xent')
      cost += self._decay()
      cost = cost

    return cost
1341378
def totals(iter, keyfunc, sumfunc):
    
    data = sorted(iter, key=keyfunc)
    res = {}

    for k, group in groupby(data, keyfunc):
        res[k] = sum([sumfunc(entry) for entry in group])

    return res
910583
def _quadratic_costs(self, generators, ipol, nxyz, base_mva):
        
        npol = len(ipol)
        rnpol = range(npol)
        gpol = [g for g in generators if g.pcost_model == POLYNOMIAL]

        if [g for g in gpol if len(g.p_cost) > 3]:
            logger.error("Order of polynomial cost greater than quadratic.")

        iqdr = [i for i, g in enumerate(generators)
                if g.pcost_model == POLYNOMIAL and len(g.p_cost) == 3]
        ilin = [i for i, g in enumerate(generators)
                if g.pcost_model == POLYNOMIAL and len(g.p_cost) == 2]

        polycf = zeros((npol, 3))
        if npol > 0:
            if len(iqdr) > 0:
                polycf[iqdr, :] = array([list(g.p_cost)
                                         for g in generators])#[iqdr, :].T
            if len(ilin) > 0:
                polycf[ilin, 1:] = array([list(g.p_cost[:2])
                                          for g in generators])#[ilin, :].T
            # Convert to per-unit.
            polycf = polycf * array([base_mva**2, base_mva, 1])
            Pg = self.om.get_var("Pg")
            Npol = csr_matrix((ones(npol), (rnpol, Pg.i1 + array(ipol))),
                              (npol, nxyz))
            Hpol = csr_matrix((2 * polycf[:, 0], (rnpol, rnpol)), (npol, npol))
            Cpol = polycf[:, 1]
            fparm_pol = (ones(npol) * array([[1], [0], [0], [1]])).T
        else:
            Npol = Hpol = None
            Cpol = array([])
            fparm_pol = zeros((0, 4))

        return Npol, Hpol, Cpol, fparm_pol, polycf, npol
1196407
def generator(self, t):
        """"""
        a = (np.exp(-self.theta * t) - 1) / (np.exp(-self.theta) - 1)
        return -np.log(a)
1324724
@Override
    public Integer getCharge() {
        Integer charge = 0;
        Iterator<IMolecularFormula> componentIterator = components.iterator();
        while (componentIterator.hasNext()) {
            charge += componentIterator.next().getCharge();
        }
        return charge;
    }