1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """Splits the gencost variable into two pieces if costs are given for Qg.
18 """
19
20 from sys import stderr
21
22 from numpy import array, arange
23
24
25 -def pqcost(gencost, ng, on=None):
26 """Splits the gencost variable into two pieces if costs are given for Qg.
27
28 Checks whether C{gencost} has cost information for reactive power
29 generation (rows C{ng+1} to C{2*ng}). If so, it returns the first C{ng}
30 rows in C{pcost} and the last C{ng} rows in C{qcost}. Otherwise, leaves
31 C{qcost} empty. Also does some error checking.
32 If C{on} is specified (list of indices of generators which are on line)
33 it only returns the rows corresponding to these generators.
34
35 @author: Ray Zimmerman (PSERC Cornell)
36 @author: Richard Lincoln
37 """
38 if on is None:
39 on = arange(ng)
40
41 if gencost.shape[0] == ng:
42 pcost = gencost[on, :]
43 qcost = array([])
44 elif gencost.shape[0] == 2 * ng:
45 pcost = gencost[on, :]
46 qcost = gencost[on + ng, :]
47 else:
48 stderr.write('pqcost: gencost has wrong number of rows\n')
49
50 return pcost, qcost
51