-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_data.h
143 lines (113 loc) · 5.09 KB
/
read_data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef READ_DATA_H_
#define READ_DATA_H_
#include <iostream>
#include <vector>
#include "csv.h"
#define ucmd ublas::compressed_matrix<double>
using namespace std;
/***************************************************
Global Variables
*****************************************************/
// Bus data
extern vector<double> Volt, VoltMax, VoltMin, VoltAng, RealPowerDemand, ReactPowerDemand;
// Generator Data
extern vector<double> RealPower, ReactPower, RealPowerMax, RealPowerMin, ReactPowerMax, ReactPowerMin, BusID_Gen;
// Generator Cost Data
extern vector<double> a, b, c;
// Branch Data
extern vector<double> VoltAngMax, VoltAngMin, Gvec, Bvec, FromBus, ToBus;
// declare temp vectors for REG Data
extern vector<double> Real_P_REG, React_P_REG, BusID_REG;
extern int Nb, sizeY, sizeX;
namespace ublas = boost::numeric::ublas;
void load_data()
{
/*********************************************** Declare Filenames ***********************************************/
char filename1[] = "./data/Case 14 Bus.csv";
char filename2[] = "./data/Case 14 Generator.csv";
char filename3[] = "./data/Case 14 Generator Cost.csv";
char filename4[] = "./data/Case 14 Branch.csv";
char filename5[] = "./data/Case 14 REG one scen.csv";
/*********************************************** Read Bus Data ***********************************************/
// declare temp vectors for Bus Data
// following code is to read Bus data
{
io::CSVReader<7> in(filename1);
in.read_header(io::ignore_extra_column, "Bus ID", "Real Power Demand", "React Power Demand", "Volt Magnitude", "Max Volt Magnitude", "Min Volt Magnitude", "Volt Angle");
double Bus; double Pd; double Qd; double V; double Vmax; double Vmin; double Vang;
while(in.read_row(Bus, Pd, Qd, V, Vmax, Vmin, Vang)){
// get Voltages and Voltage Angles
VoltAng.insert(VoltAng.end(), Vang);
Volt.insert(Volt.end(), V);
VoltMax.insert(VoltMax.end(), Vmax);
VoltMin.insert(VoltMin.end(), Vmin);
RealPowerDemand.push_back(Pd);
ReactPowerDemand.push_back(Qd);
}
}
/*********************************************** Read Generator Data ***********************************************/
// declare temp vectors for Generator Data
// following code is to read Generator data
{
io::CSVReader<7> in(filename2);
in.read_header(io::ignore_extra_column, "Bus ID", "Real Power Output", "React Power Output", "Max Real Power Output", "Min Real Power Output", "Max React Power Output", "Min React Power Output");
double Bus; double Po; double Qo; double Pmax; double Pmin; double Qmax; double Qmin;
while(in.read_row(Bus, Po, Qo, Pmax, Pmin, Qmax, Qmin)){
// get Real and React power output
RealPower.insert(RealPower.end(), Po);
ReactPower.insert(ReactPower.end(), Qo);
RealPowerMax.insert(RealPowerMax.end(), Pmax);
RealPowerMin.insert(RealPowerMin.end(), Pmin);
ReactPowerMax.insert(ReactPowerMax.end(), Qmax);
ReactPowerMin.insert(ReactPowerMin.end(), Qmin);
BusID_Gen.push_back(Bus);
}
}
/*********************************************** Read Generator Cost Data ***********************************************/
// following code is to read Generator Cost data
{
io::CSVReader<3> in(filename3);
in.read_header(io::ignore_extra_column, "Coef1", "Coef2", "Coef3");
double coef1; double coef2; double coef3;
while(in.read_row(coef1, coef2, coef3)){
// get a, b, and c coefficients for cost function
a.insert(a.end(), coef1);
b.insert(b.end(), coef2);
c.insert(c.end(), coef3);
}
}
/*********************************************** Read Branch Data ***********************************************/
// declare temp vectors for Branch Data
// following code is to read Branch Data
{
io::CSVReader<6> in(filename4);
in.read_header(io::ignore_extra_column, "From Bus", "To Bus", "Max Angle Difference", "Min Angle Difference", "G" , "B");
int FBus, TBus;
double MaxAng, MinAng, Gij, Bij;
while(in.read_row(FBus, TBus, MaxAng, MinAng, Gij, Bij)){
// get From Bus, To Bus, and Voltage Angle Max and Min values
FromBus.insert(FromBus.end(), FBus);
ToBus.insert(ToBus.end(), TBus);
VoltAngMax.insert(VoltAngMax.end(), MaxAng);
VoltAngMin.insert(VoltAngMin.end(), MinAng);
Gvec.push_back(Gij);
Bvec.push_back(Bij);
}
}
/*********************************************** Read REG Data ***********************************************/
// following code is to read REG Data
{
io::CSVReader<7> in(filename5);
in.read_header(io::ignore_extra_column, "Bus ID", "Real Power Output", "React Power Output", "Max Real Power Output", "Min Real Power Output", "Max React Power Output", "Min React Power Output");
double REG_ID, n,o,m,l, P, Q;
while(in.read_row(REG_ID, n,o,m,l, P, Q)){
// get Bus ID, Real Power, and React Power values
BusID_REG.push_back(REG_ID);
Real_P_REG.push_back(P);
React_P_REG.push_back(Q);
}
}
Nb = FromBus.size();
sizeY = 2*RealPowerMax.size() + 2*ReactPowerMax.size() + 2*VoltMax.size() + 2*FromBus.size();
}
#endif