forked from samgdotson/bakery-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mydata.sql
388 lines (388 loc) · 21.4 KB
/
mydata.sql
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "time_season" (
"t_season" text,
PRIMARY KEY("t_season")
);
INSERT INTO time_season VALUES('S1');
INSERT INTO time_season VALUES('S2');
INSERT INTO time_season VALUES('S3');
INSERT INTO time_season VALUES('S4');
CREATE TABLE IF NOT EXISTS "time_period_labels" (
"t_period_labels" text,
"t_period_labels_desc" text,
PRIMARY KEY("t_period_labels")
);
INSERT INTO time_period_labels VALUES('e','existing vintages');
INSERT INTO time_period_labels VALUES('f','future vintages');
CREATE TABLE IF NOT EXISTS "time_periods" (
"t_periods" integer,
"flag" text,
PRIMARY KEY("t_periods"),
FOREIGN KEY("flag") REFERENCES "time_period_labels"("t_period_labels")
);
INSERT INTO time_periods VALUES(2019,'e');
INSERT INTO time_periods VALUES(2020,'f');
INSERT INTO time_periods VALUES(2021,'f');
INSERT INTO time_periods VALUES(2022,'f');
CREATE TABLE IF NOT EXISTS "time_of_day" (
"t_day" text,
PRIMARY KEY("t_day")
);
INSERT INTO time_of_day VALUES('H1');
INSERT INTO time_of_day VALUES('H2');
INSERT INTO time_of_day VALUES('H3');
INSERT INTO time_of_day VALUES('H4');
INSERT INTO time_of_day VALUES('H5');
INSERT INTO time_of_day VALUES('H6');
INSERT INTO time_of_day VALUES('H7');
INSERT INTO time_of_day VALUES('H8');
INSERT INTO time_of_day VALUES('H9');
INSERT INTO time_of_day VALUES('H10');
INSERT INTO time_of_day VALUES('H11');
INSERT INTO time_of_day VALUES('H12');
INSERT INTO time_of_day VALUES('H13');
INSERT INTO time_of_day VALUES('H14');
INSERT INTO time_of_day VALUES('H15');
INSERT INTO time_of_day VALUES('H16');
INSERT INTO time_of_day VALUES('H17');
INSERT INTO time_of_day VALUES('H18');
INSERT INTO time_of_day VALUES('H19');
INSERT INTO time_of_day VALUES('H20');
INSERT INTO time_of_day VALUES('H21');
INSERT INTO time_of_day VALUES('H22');
INSERT INTO time_of_day VALUES('H23');
INSERT INTO time_of_day VALUES('H24');
CREATE TABLE IF NOT EXISTS "SegFrac" (
"season_name" text,
"time_of_day_name" text,
"segfrac" real CHECK("segfrac" >= 0 AND "segfrac" <= 1),
"segfrac_notes" text,
PRIMARY KEY("season_name","time_of_day_name"),
FOREIGN KEY("season_name") REFERENCES "time_season"("t_season"),
FOREIGN KEY("time_of_day_name") REFERENCES "time_of_day"("t_day")
);
INSERT INTO SegFrac VALUES('S1','H1',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H2',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H3',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H4',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H5',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H6',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H7',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H8',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H9',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H10',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H11',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H12',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H13',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H14',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H15',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H16',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H17',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H18',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H19',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H20',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H21',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H22',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H23',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S1','H24',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H1',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H2',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H3',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H4',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H5',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H6',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H7',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H8',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H9',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H10',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H11',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H12',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H13',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H14',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H15',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H16',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H17',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H18',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H19',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H20',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H21',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H22',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H23',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S2','H24',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H1',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H2',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H3',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H4',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H5',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H6',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H7',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H8',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H9',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H10',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H11',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H12',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H13',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H14',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H15',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H16',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H17',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H18',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H19',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H20',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H21',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H22',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H23',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S3','H24',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H1',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H2',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H3',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H4',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H5',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H6',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H7',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H8',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H9',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H10',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H11',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H12',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H13',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H14',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H15',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H16',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H17',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H18',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H19',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H20',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H21',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H22',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H23',0.010416666666666666088,'fraction of year');
INSERT INTO SegFrac VALUES('S4','H24',0.010416666666666666088,'fraction of year');
CREATE TABLE IF NOT EXISTS "regions" (
"regions" TEXT,
"region_note" TEXT,
PRIMARY KEY("regions")
);
INSERT INTO regions VALUES('MyBakery','');
CREATE TABLE IF NOT EXISTS "commodity_labels" (
"comm_labels" text,
"comm_labels_desc" text,
PRIMARY KEY("comm_labels")
);
INSERT INTO commodity_labels VALUES('p','physical commodity');
INSERT INTO commodity_labels VALUES('d','demand commodity');
INSERT INTO commodity_labels VALUES('e','emissions commodity');
CREATE TABLE IF NOT EXISTS "commodities" (
"comm_name" text,
"flag" text,
"comm_desc" text,
PRIMARY KEY("comm_name"),
FOREIGN KEY("flag") REFERENCES "commodity_labels"("comm_labels")
);
INSERT INTO commodities VALUES('NH3_DEM','d','Total cookie demand of all types, one cookie');
INSERT INTO commodities VALUES('H2','p','Refined Hydrogen, litres');
INSERT INTO commodities VALUES('NH3','p','Refined Hydrogen, litres');
INSERT INTO commodities VALUES('ELC','p','Refined Hydrogen, litres');
CREATE TABLE IF NOT EXISTS "EmissionLimit" (
"regions" text,
"periods" integer,
"emis_comm" text,
"emis_limit" real,
"emis_limit_units" text,
"emis_limit_notes" text,
PRIMARY KEY("periods","emis_comm"),
FOREIGN KEY("periods") REFERENCES "time_periods"("t_periods"),
FOREIGN KEY("emis_comm") REFERENCES "commodities"("comm_name")
);
CREATE TABLE IF NOT EXISTS "GlobalDiscountRate" (
"rate" real
);
INSERT INTO GlobalDiscountRate VALUES(0.0010000000000000000208);
CREATE TABLE IF NOT EXISTS "PlanningReserveMargin" (
`regions` text,
`reserve_margin` REAL,
PRIMARY KEY(regions),
FOREIGN KEY(`regions`) REFERENCES regions
);
INSERT INTO PlanningReserveMargin VALUES('MyBakery',0.020000000000000000416);
CREATE TABLE IF NOT EXISTS "Demand" (
"regions" text,
"periods" integer,
"demand_comm" text,
"demand" real,
"demand_units" text,
"demand_notes" text,
PRIMARY KEY("regions","periods","demand_comm"),
FOREIGN KEY("periods") REFERENCES "time_periods"("t_periods"),
FOREIGN KEY("demand_comm") REFERENCES "commodities"("comm_name")
);
INSERT INTO Demand VALUES('MyBakery',2020,'NH3_DEM',4800.0,'one cookie','');
INSERT INTO Demand VALUES('MyBakery',2021,'NH3_DEM',4800.0,'one cookie','');
CREATE TABLE IF NOT EXISTS "DemandSpecificDistribution" (
"regions" text,
"season_name" text,
"time_of_day_name" text,
"demand_name" text,
"dds" real CHECK("dds" >= 0 AND "dds" <= 1),
"dds_notes" text,
PRIMARY KEY("regions","season_name","time_of_day_name","demand_name"),
FOREIGN KEY("season_name") REFERENCES "time_season"("t_season"),
FOREIGN KEY("time_of_day_name") REFERENCES "time_of_day"("t_day"),
FOREIGN KEY("demand_name") REFERENCES "commodities"("comm_name")
);
CREATE TABLE IF NOT EXISTS "technology_labels" (
"tech_labels" text,
"tech_labels_desc" text,
PRIMARY KEY("tech_labels")
);
INSERT INTO technology_labels VALUES('p','production technology');
INSERT INTO technology_labels VALUES('pb','baseload production technology');
INSERT INTO technology_labels VALUES('ps','storage production technology');
INSERT INTO technology_labels VALUES('r','resource technology');
CREATE TABLE IF NOT EXISTS "sector_labels" (
"sector" text,
PRIMARY KEY("sector")
);
INSERT INTO sector_labels VALUES('bakery');
INSERT INTO sector_labels VALUES('store');
CREATE TABLE IF NOT EXISTS "technologies" (
"tech" text,
"flag" text,
"sector" text,
"tech_desc" text,
"tech_category" text,
PRIMARY KEY("tech"),
FOREIGN KEY("flag") REFERENCES "technology_labels"("tech_labels"),
FOREIGN KEY("sector") REFERENCES "sector_labels"("sector")
);
INSERT INTO technologies VALUES('IMP_ELC','p','store','store bought butter, stick butter','grocery');
INSERT INTO technologies VALUES('IMP_H2','p','store','store bought sugar, pound sugar','grocery');
INSERT INTO technologies VALUES('MIXER_ELC','p','bakery','Electric mixer, lbs of dough per hour','fancy kitchen');
INSERT INTO technologies VALUES('STORE','p','bakery','where cookies get sold, number of storefronts','fancy kitchen');
CREATE TABLE IF NOT EXISTS "CapacityToActivity" (
"regions" text,
"tech" text,
"c2a" real,
"c2a_notes" TEXT,
PRIMARY KEY("regions","tech"),
FOREIGN KEY("tech") REFERENCES "technologies"("tech")
);
INSERT INTO CapacityToActivity VALUES('MyBakery','IMP_H2',1.0,'');
INSERT INTO CapacityToActivity VALUES('MyBakery','MIXER_ELC',52560.0,'');
INSERT INTO CapacityToActivity VALUES('MyBakery','STORE',1.0,'');
CREATE TABLE IF NOT EXISTS "LifetimeTech" (
"regions" text,
"tech" text,
"life" real,
"life_notes" text,
PRIMARY KEY("regions","tech"),
FOREIGN KEY("tech") REFERENCES "technologies"("tech")
);
INSERT INTO LifetimeTech VALUES('MyBakery','IMP_H2',1000.0,'NULL');
INSERT INTO LifetimeTech VALUES('MyBakery','MIXER_ELC',25.0,'NULL');
INSERT INTO LifetimeTech VALUES('MyBakery','STORE',1000.0,'NULL');
CREATE TABLE IF NOT EXISTS "LifetimeLoanTech" (
"regions" text,
"tech" text,
"loan" real,
"loan_notes" text,
PRIMARY KEY("regions","tech"),
FOREIGN KEY("tech") REFERENCES "technologies"("tech")
);
CREATE TABLE IF NOT EXISTS "tech_reserve" (
"tech" text,
"notes" text,
PRIMARY KEY("tech")
);
CREATE TABLE IF NOT EXISTS "tech_ramping" (
"tech" text,
"notes" text,
PRIMARY KEY("tech")
);
CREATE TABLE RampUp(
"regions" text,
"tech" text,
"ramp_up" real,
FOREIGN KEY("tech") REFERENCES "technologies"("tech"),
PRIMARY KEY ("regions", "tech")
);
CREATE TABLE RampDown(
"regions" text,
"tech" text,
"ramp_down" real,
FOREIGN KEY("tech") REFERENCES "technologies"("tech"),
PRIMARY KEY ("regions", "tech")
);
CREATE TABLE IF NOT EXISTS "StorageDuration" (
"regions" text,
"tech" text,
"duration" real,
"duration_notes" text,
PRIMARY KEY("regions","tech")
);
CREATE TABLE IF NOT EXISTS "tech_curtailment" (
"tech" text,
"notes" TEXT,
PRIMARY KEY("tech"),
FOREIGN KEY("tech") REFERENCES "technologies"("tech")
);
CREATE TABLE IF NOT EXISTS "tech_exchange" (
"tech" text,
"notes" TEXT,
PRIMARY KEY("tech"),
FOREIGN KEY("tech") REFERENCES "technologies"("tech")
);
CREATE TABLE IF NOT EXISTS "MaxCapacity" (
"regions" text,
"periods" integer,
"tech" text,
"maxcap" real,
"maxcap_units" text,
"maxcap_notes" text,
PRIMARY KEY("regions","periods","tech"),
FOREIGN KEY("periods") REFERENCES "time_periods"("t_periods"),
FOREIGN KEY("tech") REFERENCES "technologies"("tech")
);
CREATE TABLE IF NOT EXISTS "MinCapacity" (
"regions" text,
"periods" integer,
"tech" text,
"maxcap" real,
"maxcap_units" text,
"maxcap_notes" text,
PRIMARY KEY("regions","periods","tech"),
FOREIGN KEY("periods") REFERENCES "time_periods"("t_periods"),
FOREIGN KEY("tech") REFERENCES "technologies"("tech")
);
INSERT INTO MinCapacity VALUES('MyBakery',2020,'MIXER_ELC',1.0,'lbs of dough per hour','');
CREATE TABLE IF NOT EXISTS "TechInputSplit" (
"regions" TEXT,
"periods" integer,
"input_comm" text,
"tech" text,
"ti_split" real,
"ti_split_notes" text,
PRIMARY KEY("regions","periods","input_comm","tech"),
FOREIGN KEY("tech") REFERENCES "technologies"("tech"),
FOREIGN KEY("input_comm") REFERENCES "commodities"("comm_name"),
FOREIGN KEY("periods") REFERENCES "time_periods"("t_periods")
);
INSERT INTO TechInputSplit VALUES('MyBakery',2020,'ELC','MIXER_ELC',0.11100000000000000144,'');
INSERT INTO TechInputSplit VALUES('MyBakery',2021,'ELC','MIXER_ELC',0.11100000000000000144,'');
INSERT INTO TechInputSplit VALUES('MyBakery',2020,'H2','MIXER_ELC',0.88900000000000001243,'');
INSERT INTO TechInputSplit VALUES('MyBakery',2021,'H2','MIXER_ELC',0.88900000000000001243,'');
CREATE TABLE IF NOT EXISTS "Efficiency" (
"regions" text,
"input_comm" text,
"tech" text,
"vintage" integer,
"output_comm" text,
"efficiency" real CHECK("efficiency" > 0),
"eff_notes" text,
PRIMARY KEY("regions","input_comm","tech","vintage","output_comm"),
FOREIGN KEY("output_comm") REFERENCES "commodities"("comm_name"),
FOREIGN KEY("tech") REFERENCES "technologies"("tech"),
FOREIGN KEY("vintage") REFERENCES "time_periods"("t_periods"),
FOREIGN KEY("input_comm") REFERENCES "commodities"("comm_name")
);
COMMIT;