Package pypower :: Package t :: Module t_off2case
[hide private]
[frames] | no frames]

Source Code for Module pypower.t.t_off2case

  1  # Copyright (C) 2005-2011 Power System Engineering Research Center (PSERC) 
  2  # Copyright (C) 2011 Richard Lincoln 
  3  # 
  4  # PYPOWER is free software: you can redistribute it and/or modify 
  5  # it under the terms of the GNU General Public License as published 
  6  # by the Free Software Foundation, either version 3 of the License, 
  7  # or (at your option) any later version. 
  8  # 
  9  # PYPOWER is distributed in the hope that it will be useful, 
 10  # but WITHOUT ANY WARRANTY], without even the implied warranty of 
 11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 12  # GNU General Public License for more details. 
 13  # 
 14  # You should have received a copy of the GNU General Public License 
 15  # along with PYPOWER. If not, see <http://www.gnu.org/licenses/>. 
 16   
 17  """Tests for code in C{off2case}. 
 18  """ 
 19   
 20  from numpy import array, zeros, ix_, r_, c_, flatnonzero as find 
 21   
 22  from pypower.isload import isload 
 23  from pypower.idx_cost import NCOST 
 24  from pypower.idx_gen import QMAX, QMIN, GEN_STATUS, PMIN, PMAX, QG 
 25   
 26  from pypower.t.t_begin import t_begin 
 27  from pypower.t.t_is import t_is 
 28  from pypower.t.t_skip import t_skip 
 29  from pypower.t.t_end import t_end 
 30   
 31   
32 -def t_off2case(quiet=False):
33 """Tests for code in C{off2case}. 34 35 @author: Ray Zimmerman (PSERC Cornell) 36 @author: Richard Lincoln 37 """ 38 n_tests = 35 39 40 t_begin(n_tests, quiet) 41 42 ## generator data 43 # bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 44 gen0 = array([ 45 [1, 10, 0, 60, -15, 1, 100, 1, 60, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 46 [2, 10, 0, 60, -15, 1, 100, 1, 60, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 47 [7, -30, -15, 0, -15, 1, 100, 1, 0, -30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 48 [13, 10, 0, 60, -15, 1, 100, 1, 60, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 49 [30, -30, 7.5, 7.5, 0, 1, 100, 1, 0, -30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 50 ], float) 51 ## generator cost data 52 # 1 startup shutdown n x1 y1 ... xn yn 53 # 2 startup shutdown n c(n-1) ... c0 54 gencost0 = array([ 55 [1, 0, 0, 4, 0, 0, 12, 240, 36, 1200, 60, 2400], 56 [1, 100, 0, 4, 0, 0, 12, 240, 36, 1200, 60, 2400], 57 [1, 0, 0, 4, -30, 0, -20, 1000, -10, 2000, 0, 3000], 58 [1, 0, 0, 4, 0, 0, 12, 240, 36, 1200, 60, 2400], 59 [1, 0, 50, 4, -30, 0, -20, 1000, -10, 2000, 0, 3000] 60 ], float) 61 62 try: 63 from pypower.extras.smartmarket import off2case 64 except ImportError: 65 t_skip(n_tests, 'smartmarket code not available') 66 return 67 68 t = 'isload()' 69 t_is(isload(gen0), array([0, 0, 1, 0, 1], bool), 8, t) 70 71 G = find( ~isload(gen0) ) 72 L = find( isload(gen0) ) 73 nGL = len(G) + len(L) 74 75 t = 'P offers only'; 76 offers = {'P': {}} 77 offers['P']['qty'] = array([[25], [26], [27]], float) 78 offers['P']['prc'] = array([[10], [50], [100]], float) 79 gen, gencost = off2case(gen0, gencost0, offers) 80 81 gen1 = gen0.copy() 82 gen1[G, PMAX] = offers['P']['qty'].flatten() 83 gen1[L, GEN_STATUS] = 0 84 t_is( gen, gen1, 8, [t, ' - gen'] ) 85 86 gencost1 = gencost0.copy() 87 gencost1[ix_(G, range(NCOST, NCOST + 9))] = c_[array([ 88 [2, 0, 0, 25, 250], 89 [2, 0, 0, 26, 1300], 90 [2, 0, 0, 27, 2700], 91 ]), zeros((3, 4))] 92 93 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 94 95 offers['P']['qty'] = array([[25], [26], [0], [27], [0]], float) 96 offers['P']['prc'] = array([[10], [50], [0], [100], [0]], float) 97 gen, gencost = off2case(gen0, gencost0, offers) 98 t_is( gen, gen1, 8, [t, ' (all rows in offer) - gen'] ) 99 t_is( gencost, gencost1, 8, [t, ' (all rows in offer) - gencost'] ) 100 101 t = 'P offers only (GEN_STATUS=0 for 0 qty offer)'; 102 offers['P']['qty'] = array([ [0], [26], [27]], float) 103 offers['P']['prc'] = array([[10], [50], [100]], float) 104 gen, gencost = off2case(gen0, gencost0, offers) 105 106 gen1 = gen0.copy() 107 gen1[G[1:3], PMAX] = offers['P']['qty'].flatten()[1:3] 108 gen1[G[0], GEN_STATUS] = 0 109 gen1[L, GEN_STATUS] = 0 110 t_is( gen, gen1, 8, [t, ' - gen'] ) 111 112 gencost1 = gencost0.copy() 113 gencost1[ix_(G[1:3], range(NCOST, NCOST + 9))] = c_[array([ 114 [2, 0, 0, 26, 1300], 115 [2, 0, 0, 27, 2700] 116 ]), zeros((2, 4))] 117 118 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 119 120 t = 'P offers, lim[\'P\'][\'max_offer\']'; 121 offers['P']['qty'] = array([[25], [26], [27]], float) 122 offers['P']['prc'] = array([[10], [50], [100]], float) 123 lim = {'P': {'max_offer': 75}} 124 gen, gencost = off2case(gen0, gencost0, offers, lim=lim) 125 126 gen1 = gen0.copy() 127 gen1[G[:2], PMAX] = offers['P']['qty'].flatten()[:2, :] 128 gen1[r_[G[2], L], GEN_STATUS] = 0 129 t_is( gen, gen1, 8, [t, ' - gen'] ) 130 131 gencost1 = gencost0.copy() 132 gencost1[ix_(G[:2], range(NCOST, NCOST + 9))] = c_[array([ 133 [2, 0, 0, 25, 250], 134 [2, 0, 0, 26, 1300] 135 ]), zeros((2, 4))] 136 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 137 138 t = 'P offers & P bids'; 139 bids = {'P': {'qty': array([ [20], [28]], float), 140 'prc': array([[100], [10]], float)}} 141 gen, gencost = off2case(gen0, gencost0, offers, bids) 142 143 gen1 = gen0.copy() 144 gen1[G, PMAX] = offers['P']['qty'] 145 gen1[ix_(L, [PMIN, QMIN, QMAX])] = array([ 146 [-20, -10, 0], 147 [-28, 0, 7] 148 ]) 149 t_is( gen, gen1, 8, [t, ' - gen'] ) 150 151 gencost1 = gencost0[:, :8].copy() 152 gencost1[ix_(G, range(NCOST, NCOST + 4))] = array([ 153 [2, 0, 0, 25, 250], 154 [2, 0, 0, 26, 1300], 155 [2, 0, 0, 27, 2700] 156 ]) 157 gencost1[ix_(L, range(NCOST, NCOST + 4))] = array([ 158 [2, -20, -2000, 0, 0], 159 [2, -28, -280, 0, 0] 160 ]) 161 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 162 163 t = 'P offers & P bids (all rows in bid)'; 164 bids['P']['qty'] = array([[0], [0], [20], [0], [28]], float) 165 bids['P']['prc'] = array([[0], [0], [100], [0], [10]], float) 166 gen, gencost = off2case(gen0, gencost0, offers, bids) 167 168 t_is( gen, gen1, 8, [t, ' - gen'] ) 169 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 170 171 t = 'P offers & P bids (GEN_STATUS=0 for 0 qty bid)'; 172 bids['P']['qty'] = array([ [0], [28]], float) 173 bids['P']['prc'] = array([[100], [10]], float) 174 gen, gencost = off2case(gen0, gencost0, offers, bids) 175 176 gen1 = gen0.copy() 177 gen1[G, PMAX] = offers['P']['qty'] 178 gen1[L[0], GEN_STATUS] = 0 179 gen1[L[1], [PMIN, QMIN, QMAX]] = array([-28, 0, 7]) 180 t_is( gen, gen1, 8, [t, ' - gen'] ) 181 182 gencost1 = gencost0.copy() 183 gencost1[ix_(G, range(NCOST, NCOST + 9))] = c_[array([ 184 [2, 0, 0, 25, 250], 185 [2, 0, 0, 26, 1300], 186 [2, 0, 0, 27, 2700] 187 ]), zeros((3, 4))] 188 gencost1[L[1], NCOST:NCOST + 8] = c_[array([ 189 [2, -28, -280, 0, 0] 190 ]), zeros((1, 4))] 191 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 192 193 t = 'P offers & P bids (1 gen with both)'; 194 gen2 = gen0.copy() 195 gen2[1, PMIN] = -5 196 bids['P']['qty'] = array([[0], [3], [20], [0], [28]], float) 197 bids['P']['prc'] = array([[0], [50], [100], [0], [10]], float) 198 gen, gencost = off2case(gen2, gencost0, offers, bids) 199 200 gen1 = gen2.copy() 201 gen1[G, PMAX] = offers['P']['qty'] 202 gen1[1, PMIN] = -sum( bids['P']['qty'][1, :] ) 203 gen1[ix_(L, [PMIN, QMIN, QMAX])] = array([ 204 [-20, -10, 0], 205 [-28, 0, 7] 206 ]) 207 t_is( gen, gen1, 8, [t, ' - gen'] ) 208 209 gencost1 = gencost0[:, :10].copy() 210 gencost1[ix_(G, range(NCOST, NCOST + 7))] = array([ 211 [2, 0, 0, 25, 250, 0, 0], 212 [3, -3, -150, 0, 0, 26, 1300], 213 [2, 0, 0, 27, 2700, 0, 0] 214 ]) 215 gencost1[ix_(L, range(NCOST, NCOST + 7))] = c_[array([ 216 [2, -20, -2000, 0, 0], 217 [2, -28, -280, 0, 0] 218 ]), zeros((2, 2))] 219 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 220 221 t = 'P offers & P bids, lim[\'P\'][\'max_offer\']/[\'min_bid\']' 222 bids['P']['qty'] = array([[20], [28]], float) 223 bids['P']['prc'] = array([[100], [10]], float) 224 lim['P']['min_bid'] = 50.0 225 gen, gencost = off2case(gen0, gencost0, offers, bids, lim) 226 227 gen1 = gen0.copy() 228 gen1[G[:2], PMAX] = offers['P']['qty'][:2, :] 229 gen1[r_[G[2], L[1]], GEN_STATUS] = 0 230 gen1[L[0], [PMIN, QMIN, QMAX]] = array([-20, -10, 0]) 231 t_is( gen, gen1, 8, [t, ' - gen'] ) 232 233 gencost1 = gencost0.copy() 234 gencost1[ix_(G[:2], range(NCOST, NCOST + 9))] = c_[array([ 235 [2, 0, 0, 25, 250], 236 [2, 0, 0, 26, 1300] 237 ]), zeros((2, 4))] 238 gencost1[L[0], NCOST:NCOST + 9] = array([2, -20, -2000, 0, 0, 0, 0, 0, 0]) 239 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 240 241 t = 'P offers & P bids, lim[\'P\'][\'max_offer\']/[\'min_bid\'], multi-block' 242 offers['P']['qty'] = array([[10, 40], [20, 30], [25, 25]], float) 243 offers['P']['prc'] = array([[10, 100], [25, 65], [50, 90]], float) 244 bids['P']['qty'] = array([[ 20, 10], [12, 18]], float) 245 bids['P']['prc'] = array([[100, 60], [70, 10]], float) 246 gen, gencost = off2case(gen0, gencost0, offers, bids, lim) 247 248 gen1 = gen0.copy() 249 gen1[G, PMAX] = array([10, 50, 25]) 250 gen1[ix_(L, [PMIN, QMIN, QMAX])] = array([ 251 [-30, -15, 0], 252 [-12, 0, 3] 253 ]) 254 t_is( gen, gen1, 8, [t, ' - gen'] ) 255 256 gencost1 = gencost0[:, :10].copy() 257 gencost1[ix_(G, range(NCOST, NCOST + 7))] = array([ 258 [2, 0, 0, 10, 100, 0, 0], 259 [3, 0, 0, 20, 500, 50, 2450], 260 [2, 0, 0, 25, 1250, 0, 0] 261 ]) 262 gencost1[ix_(L, range(NCOST, NCOST + 7))] = array([ 263 [3, -30, -2600, -20, -2000, 0, 0], 264 [2, -12, -840, 0, 0, 0, 0] 265 ]) 266 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 267 268 ##----- reactive ----- 269 ## generator cost data 270 # 1 startup shutdown n x1 y1 ... xn yn 271 # 2 startup shutdown n c(n-1) ... c0 272 gencost0 = array([ 273 [1, 0, 0, 4, 0, 0, 12, 240, 36, 1200, 60, 2400], 274 [1, 100, 0, 4, 0, 0, 12, 240, 36, 1200, 60, 2400], 275 [1, 0, 0, 4, -30, 0, -20, 1000, -10, 2000, 0, 3000], 276 [1, 0, 0, 4, 0, 0, 12, 240, 36, 1200, 60, 2400], 277 [1, 0, 50, 4, -30, 0, -20, 1000, -10, 2000, 0, 3000], 278 [1, 0, 0, 4, -15, -150, 0, 0, 30, 150, 60, 450], 279 [1, 100, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0], 280 [1, 0, 0, 3, -20, -15, -10, -10, 0, 0, 0, 0], 281 [1, 0, 0, 3, 0, 0, 40, 80, 60, 180, 0, 0], 282 [1, 0, 50, 2, 0, 0, 0, 0, 0, 0, 0, 0] 283 ], float) 284 285 t = 'PQ offers only'; 286 offers['P']['qty'] = array([[25], [26], [27]], float) 287 offers['P']['prc'] = array([[10], [50], [100]], float) 288 offers['Q']['qty'] = array([[10], [20], [30]], float) 289 offers['Q']['prc'] = array([[10], [5], [1]], float) 290 gen, gencost = off2case(gen0, gencost0, offers) 291 292 gen1 = gen0.copy() 293 gen1[G, PMAX] = offers['P']['qty'] 294 gen1[G, QMAX] = offers['Q']['qty'] 295 gen1[G, QMIN] = 0 296 gen1[L, GEN_STATUS] = 0 297 t_is( gen, gen1, 8, [t, ' - gen'] ) 298 299 gencost1 = gencost0.copy() 300 gencost1[ix_(G, range(NCOST, NCOST + 9))] = c_[array([ 301 [2, 0, 0, 25, 250], 302 [2, 0, 0, 26, 1300], 303 [2, 0, 0, 27, 2700] 304 ]), zeros((3, 4))] 305 gencost1[ix_(G + nGL - 1, range(NCOST, NCOST + 9))] = c_[array([ 306 [2, 0, 0, 10, 100], 307 [2, 0, 0, 20, 100], 308 [2, 0, 0, 30, 30] 309 ]), zeros((3, 4))] 310 311 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 312 313 t = 'PQ offers & PQ bids, lim.P/Q.max_offer/min_bid, multi-block'; 314 offers['P']['qty'] = array([[10, 40], [20, 30], [25, 25]], float) 315 offers['P']['prc'] = array([[10, 100], [25, 65], [50, 90]], float) 316 bids['P']['qty'] = array([[ 20, 10], [12, 18]], float) 317 bids['P']['prc'] = array([[100, 60], [70, 10]], float) 318 offers['Q']['qty'] = array([[ 5, 5], [10, 10], [15, 15]], float) 319 offers['Q']['prc'] = array([[10, 20], [ 5, 60], [ 1, 10]], float) 320 bids['Q']['qty'] = array([ 15, 10, 15, 15, 0], float) 321 bids['Q']['prc'] = array([-10, 0, 5, -20, 10], float) 322 lim['Q']['max_offer'] = 50.0 323 lim['Q']['min_bid'] = -15.0 324 gen, gencost = off2case(gen0, gencost0, offers, bids, lim) 325 326 gen1 = gen0.copy() 327 gen1[:, [GEN_STATUS, PMIN, PMAX, QMIN, QMAX]] = array([ 328 [1, 10, 10, -15, 10], 329 [1, 12, 50, -10, 10], 330 [1, -10, 0, -5, 0], 331 [1, 12, 25, 0, 30], 332 [0, -30, 0, 0, 7.5] 333 ]) 334 t_is( gen, gen1, 8, [t, ' - gen'] ) 335 336 gencost1 = gencost0[:, :12].copy() 337 gencost1[:, NCOST - 1:NCOST + 9] = array([ 338 [2, 0, 0, 10, 100, 0, 0, 0, 0], 339 [3, 0, 0, 20, 500, 50, 2450, 0, 0], 340 [3, -30, -2600, -20, -2000, 0, 0, 0, 0], 341 [2, 0, 0, 25, 1250, 0, 0, 0, 0], 342 [4, -30, 0, -20, 1000, -10, 2000, 0, 3000], 343 [4, -15, 150, 0, 0, 5, 50, 10, 150], 344 [3, -10, 0, 0, 0, 10, 50, 0, 0], 345 [2, -15, -75, 0, 0, 0, 0, 0, 0], 346 [3, 0, 0, 15, 15, 30, 165, 0, 0], 347 [2, 0, 0, 0, 0, 0, 0, 0, 0] 348 ]) 349 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 350 351 t = 'PQ offers & PQ bids, for gen, no P, no shutdown'; 352 gen2 = gen0.copy() 353 gen2[0, PMIN] = 0 354 offers['P']['qty'] = array([[0, 40], [20, 30], [25, 25]], float) 355 gen, gencost = off2case(gen2, gencost0, offers, bids, lim) 356 357 gen1[0, [PMIN, PMAX, QMIN, QMAX]] = array([0, 0, -15, 10]) 358 t_is( gen, gen1, 8, [t, ' - gen'] ) 359 360 gencost1[0, NCOST:NCOST + 9] = gencost0[0, NCOST:NCOST + 9] 361 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 362 363 t = 'PQ offers & PQ bids, for gen, no Q, no shutdown'; 364 offers['P']['qty'] = array([[10, 40], [20, 30], [25, 25]], float) 365 offers['Q']['qty'] = array([[ 5, 5], [ 0, 10], [15, 15]], float) 366 bids['Q']['qty'] = array([15, 0, 15, 15, 0], float) 367 gen, gencost = off2case(gen0, gencost0, offers, bids, lim) 368 369 gen1[0, [PMIN, PMAX, QMIN, QMAX]] = array([10, 10, -15, 10]) ## restore original 370 gen1[1, [PMIN, PMAX, QMIN, QMAX]] = array([12, 50, 0, 0]) 371 t_is( gen, gen1, 8, [t, ' - gen'] ) 372 373 gencost1[ix_([0, 1, 6], range(NCOST, NCOST + 9))] = array([ 374 [2, 0, 0, 10, 100, 0, 0, 0, 0], 375 [3, 0, 0, 20, 500, 50, 2450, 0, 0], 376 [2, 0, 0, 0, 0, 0, 0, 0, 0] 377 ]) 378 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 379 380 t = 'PQ offers & PQ bids, lim.P/Q.max_offer/min_bid, multi-block'; 381 offers['P']['qty'] = array([[10, 40], [20, 30], [25, 25]], float) 382 offers['P']['prc'] = array([[10, 100], [25, 65], [50, 90]], float) 383 bids['P']['qty'] = array([[10, 0], [12, 18]], float) 384 bids['P']['prc'] = array([[100, 60], [70, 10]], float) 385 offers['Q']['qty'] = array([[5, 5], [10, 10], [15, 15]], float) 386 offers['Q']['prc'] = array([[10, 20], [5, 60], [1, 10]], float) 387 bids['Q']['qty'] = array([15, 10, 10, 15, 0], float) 388 bids['Q']['prc'] = array([-10, 0, 5, -20, 10], float) 389 lim['Q']['max_offer'] = 50.0 390 lim['Q']['min_bid'] = -15.0 391 gen, gencost = off2case(gen0, gencost0, offers, bids, lim) 392 393 gen1 = gen0.copy() 394 gen1[:, [GEN_STATUS, PMIN, PMAX, QMIN, QMAX]] = array([ 395 [1, 10, 10, -15, 10], 396 [1, 12, 50, -10, 10], 397 [1, -10, 0, -5, 0], 398 [1, 12, 25, 0, 30], 399 [0, -30, 0, 0, 7.5] 400 ]) 401 t_is( gen, gen1, 8, [t, ' - gen'] ) 402 403 gencost1 = gencost0[:, :12].copy() 404 gencost1[:, NCOST:NCOST + 9] = array([ 405 [2, 0, 0, 10, 100, 0, 0, 0, 0], 406 [3, 0, 0, 20, 500, 50, 2450, 0, 0], 407 [2, -10, -1000, 0, 0, 0, 0, 0, 0], 408 [2, 0, 0, 25, 1250, 0, 0, 0, 0], 409 [4, -30, 0, -20, 1000, -10, 2000, 0, 3000], 410 [4, -15, 150, 0, 0, 5, 50, 10, 150], 411 [3, -10, 0, 0, 0, 10, 50, 0, 0], 412 [2, -10, -50, 0, 0, 0, 0, 0, 0], 413 [3, 0, 0, 15, 15, 30, 165, 0, 0], 414 [2, 0, 0, 0, 0, 0, 0, 0, 0] 415 ]) 416 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 417 418 t = 'PQ offers & PQ bids, zero Q load w/P bid, shutdown bugfix'; 419 gen1 = gen0.copy() 420 gen1[4, [QG, QMIN, QMAX]] = 0 421 gen, gencost = off2case(gen1, gencost0, offers, bids, lim) 422 423 gen1[:, [PMIN, PMAX, QMIN, QMAX]] = array([ 424 [ 10, 10, -15, 10], 425 [ 12, 50, -10, 10], 426 [-10, 0, -5, 0], 427 [ 12, 25, 0, 30], 428 [-12, 0, 0, 0] 429 ]) 430 t_is( gen, gen1, 8, [t, ' - gen'] ) 431 432 gencost1 = gencost0[:, :12].copy() 433 gencost1[:, NCOST - 1:NCOST + 9] = array([ 434 [2, 0, 0, 10, 100, 0, 0, 0, 0], 435 [3, 0, 0, 20, 500, 50, 2450, 0, 0], 436 [2, -10, -1000, 0, 0, 0, 0, 0, 0], 437 [2, 0, 0, 25, 1250, 0, 0, 0, 0], 438 [2, -12, -840, 0, 0, 0, 0, 0, 0], 439 [4, -15, 150, 0, 0, 5, 50, 10, 150], 440 [3, -10, 0, 0, 0, 10, 50, 0, 0], 441 [2, -10, -50, 0, 0, 0, 0, 0, 0], 442 [3, 0, 0, 15, 15, 30, 165, 0, 0], 443 [2, 0, 0, 0, 0, 0, 0, 0, 0] 444 ]) 445 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 446 447 t = 'PQ offers & PQ bids, non-zero Q load w/no P bid, shutdown bugfix'; 448 offers['P']['qty'] = array([[10, 40], [20, 30], [25, 25]], float) 449 offers['P']['prc'] = array([[10, 100], [25, 65], [50, 90]], float) 450 bids['P']['qty'] = array([[0, 10], [12, 18]], float) 451 bids['P']['prc'] = array([[100, 40], [70, 10]], float) 452 offers['Q']['qty'] = array([[ 5, 5], [10, 10], [15, 15]], float) 453 offers['Q']['prc'] = array([[10, 20], [ 5, 60], [ 1, 10]], float) 454 bids['Q']['qty'] = array([ 15, 10, 15, 15, 0], float) 455 bids['Q']['prc'] = array([-10, 0, 5, -20, 10], float) 456 lim['Q']['max_offer'] = 50.0 457 lim['Q']['min_bid'] = -15.0 458 gen, gencost = off2case(gen0, gencost0, offers, bids, lim) 459 460 gen1 = gen0.copy() 461 gen1[:, [GEN_STATUS, PMIN, PMAX, QMIN, QMAX]] = array([ 462 [1, 10, 10, -15, 10], 463 [1, 12, 50, -10, 10], 464 [0, -30, 0, -15, 0], 465 [1, 12, 25, 0, 30], 466 [0, -30, 0, 0, 7.5] 467 ]) 468 t_is( gen, gen1, 8, [t, ' - gen'] ) 469 470 gencost1 = gencost0[:, :12].copy() 471 gencost1[:, NCOST - 1:NCOST + 9] = array([ 472 [2, 0, 0, 10, 100, 0, 0, 0, 0], 473 [3, 0, 0, 20, 500, 50, 2450, 0, 0], 474 [4, -30, 0, -20, 1000, -10, 2000, 0, 3000], 475 [2, 0, 0, 25, 1250, 0, 0, 0, 0], 476 [4, -30, 0, -20, 1000, -10, 2000, 0, 3000], 477 [4, -15, 150, 0, 0, 5, 50, 10, 150], 478 [3, -10, 0, 0, 0, 10, 50, 0, 0], 479 [3, -20, -15, -10, -10, 0, 0, 0, 0], 480 [3, 0, 0, 15, 15, 30, 165, 0, 0], 481 [2, 0, 0, 0, 0, 0, 0, 0, 0] 482 ]) 483 t_is( gencost, gencost1, 8, [t, ' - gencost'] ) 484 485 t_end()
486 487 488 if __name__ == '__main__': 489 t_off2case(quiet=False) 490