forked from iss4e/Robust_Sizing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_snc_eue.cc
61 lines (48 loc) · 1.68 KB
/
run_snc_eue.cc
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
#include <fstream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <iomanip>
#include <limits>
#include "snc_eue_pertrace.h"
#include "common.h"
using namespace std;
// run_snc_eue
// load_filename: filename, each line in file contains electricity consumption value
// solar_filename: filename, each line in file contains solar generation value
// id: request id
// metric: 0 for LOLP, 1 for unmet load
// epsilon: number in range [0,1] representing LOLP or unmet load fraction.
// chunk_size: length of time (in days)
SimulationResult run_snc_eue(vector <double> &load, vector <double> &solar, double epsilon, double confidence, int chunk_size) {
// use this random seed
// srand(10);
// get number of timeslots in each chunk
int t_chunk_size = chunk_size*(24/T_u);
vector <int> chunk_starts;
vector <int> chunk_ends;
for (int chunk_num = 0; chunk_num < number_of_chunks; chunk_num += 1) {
int chunk_start = rand() % solar.size();
int chunk_end = chunk_start + t_chunk_size;
chunk_starts.push_back(chunk_start);
chunk_ends.push_back(chunk_end);
double sum_solar = 0;
double sum_load = 0;
for (int index = chunk_start; index < chunk_end; index++) {
sum_solar += solar[index % solar.size()];
sum_load += load[index % solar.size()];
}
}
return snc_eue(load, solar, chunk_starts, chunk_ends, epsilon, confidence, t_chunk_size);
}
int main(int argc, char ** argv) {
int input_process_status = process_input(argv, false);
if (input_process_status) {
return 1;
}
SimulationResult sr = run_snc_eue(load, solar, epsilon, confidence, days_in_chunk);
cout << sr.B << "\t" << sr.C << "\t" << sr.cost << endl;
return 0;
}