1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """Tests for code in C{totcost}.
18 """
19
20 from numpy import array
21
22 from pypower.totcost import totcost
23
24 from pypower.t.t_begin import t_begin
25 from pypower.t.t_is import t_is
26 from pypower.t.t_end import t_end
27
28
30 """Tests for code in C{totcost}.
31
32 @author: Ray Zimmerman (PSERC Cornell)
33 @author: Richard Lincoln
34 """
35 n_tests = 22
36
37 t_begin(n_tests, quiet)
38
39
40
41
42 gencost = array([
43 [2, 0, 0, 3, 0.01, 0.1, 1, 0, 0, 0, 0, 0],
44 [2, 0, 0, 5, 0.0006, 0.005, 0.04, 0.3, 2, 0, 0, 0],
45 [1, 0, 0, 4, 0, 0, 10, 200, 20, 600, 30, 1200],
46 [1, 0, 0, 4, -30, -2400, -20, -1800, -10, -1000, 0, 0]
47 ])
48
49 t = 'totcost - quadratic'
50 t_is(totcost(gencost, array([0, 0, 0, 0])), [1, 2, 0, 0], 8, t)
51 t_is(totcost(gencost, array([1, 0, 0, 0])), [1.11, 2, 0, 0], 8, t)
52 t_is(totcost(gencost, array([2, 0, 0, 0])), [1.24, 2, 0, 0], 8, t)
53
54 t = 'totcost - 4th order polynomial'
55 t_is(totcost(gencost, array([0, 0, 0, 0])), [1, 2, 0, 0], 8, t)
56 t_is(totcost(gencost, array([0, 1, 0, 0])), [1, 2.3456, 0, 0], 8, t)
57 t_is(totcost(gencost, array([0, 2, 0, 0])), [1, 2.8096, 0, 0], 8, t)
58
59 t = 'totcost - pwl (gen)'
60 t_is(totcost(gencost, array([0, 0, -10, 0 ])), [1, 2, -200, 0], 8, t)
61 t_is(totcost(gencost, array([0, 0, 5, 0 ])), [1, 2, 100, 0], 8, t)
62 t_is(totcost(gencost, array([0, 0, 10, 0])), [1, 2, 200, 0], 8, t)
63 t_is(totcost(gencost, array([0, 0, 15, 0])), [1, 2, 400, 0], 8, t)
64 t_is(totcost(gencost, array([0, 0, 20, 0])), [1, 2, 600, 0], 8, t)
65 t_is(totcost(gencost, array([0, 0, 25, 0])), [1, 2, 900, 0], 8, t)
66 t_is(totcost(gencost, array([0, 0, 30, 0])), [1, 2, 1200, 0], 8, t)
67 t_is(totcost(gencost, array([0, 0, 35, 0])), [1, 2, 1500, 0], 8, t)
68
69 t = 'totcost - pwl (load)'
70 t_is(totcost(gencost, array([0, 0, 0, 10 ])), [1, 2, 0, 1000], 8, t)
71 t_is(totcost(gencost, array([0, 0, 0, -5 ])), [1, 2, 0, -500], 8, t)
72 t_is(totcost(gencost, array([0, 0, 0, -10])), [1, 2, 0, -1000], 8, t)
73 t_is(totcost(gencost, array([0, 0, 0, -15])), [1, 2, 0, -1400], 8, t)
74 t_is(totcost(gencost, array([0, 0, 0, -20])), [1, 2, 0, -1800], 8, t)
75 t_is(totcost(gencost, array([0, 0, 0, -25])), [1, 2, 0, -2100], 8, t)
76 t_is(totcost(gencost, array([0, 0, 0, -30])), [1, 2, 0, -2400], 8, t)
77 t_is(totcost(gencost, array([0, 0, 0, -35])), [1, 2, 0, -2700], 8, t)
78
79 t_end()
80
81
82 if __name__ == '__main__':
83 t_totcost(quiet=False)
84