-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathcep27.rst
More file actions
313 lines (254 loc) · 8.13 KB
/
cep27.rst
File metadata and controls
313 lines (254 loc) · 8.13 KB
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
CEP 27 - |Cyclus| Database Restructuring
********************************************
:CEP: 27
:Title: |Cyclus| Database Restructuring
:Last-Modified: 2017-09-11
:Author: Jin whan Bae & Anthony Scopatz
:Status: Draft
:Type: Standards Track
:Created: 2013-09-11
Abstract
============
This CEP proposes to restructure the |Cyclus| output database structure in order to
reduce the number of tables and redundancy of data, and ultimately reduce the number
of ``joins`` required for data analysis. Doing so would reduce the computing time
for end-user analysis, and allow for a clearer, more concise output database.
Motivation
==========
The current output database requires the user to join multiple tables to acquire
meaningful material data, such as quantity and composition. This causes long
analysis computing times and confusion for the user.
Rationale
=========
The proposed restructure aims to reduce the number of tables the user has to query
for analysis. This can be done by two methods:
1. Combine redundant tables
2. Reduce a table (``Compositions`` table) into a column with variable-type map.
Additionally, this CEP proposes to store both **Inventories** and **Transactions**
by default. Either table may be backed out of the other (with additional
information coming from **Materials** etc). However, this backing out process has proven
extraordinarily expensive, exploding the number of operations needed to back out non-present
by millions to billions. Even for small databases, this has proven prohibitive.
While storing both **Inventories** and **Transactions** may seem inefficient, consider
that:
* Data storage is cheap,
* Material inventories are what most analysis tasks require, and
* This is precisely double-entry bookkeeping, as applied to the nuclear fuel cycle.
Double-entry bookkeeping was huge innovation in accounting systems. When implemented
correctly and without fraud, it leads to a self-consistent system. This enables errors
to be discovered and corrected earlier. This CEP argues that |Cyclus| should provide
the information needed to verify the mass balances, if requested.
Specification \& Implementation
===============================
The following tables that are currently in output are considered for editing:
1. Compositions
2. Transactions
3. Recipes
4. ExplicitInventory
5. ExplicitInventoryCompact
6. Info
7. InfoExplicitInv
8. ResCreators
9. Resources
Material and Product
--------------------
Currently, both **Material** and **Product** are in the Resources Table.
The internal state of **Material** is stored in **Compositions**, and
the internal state of **Product** is stored in **Products** table.
This requires the user to make joins to acquire the internal state
of the resources.
We can avoid unnecessary joins by creating a **Materials** and
**Products** table, with the internal state (composition and quality)
as a column.
In short, we propose to replace **Compositions**, **Products**, and
**Resources** table with **Materials** and **Products** Table. In the
process, the **QualId** column would be removed.
Currently:
============ ==========
Resources
------------------------
Column Type
============ ==========
SimId uuid
ResourceId int
ObjId int
Type string
TimeCreated int
Quantity double
Units string
QualId int
Parent1 int
Parent2 int
============ ==========
============ ==========
Products
------------------------
Column Type
============ ==========
SimId uuid
QualId int
Quality string
============ ==========
============ ==========
Compositions
------------------------
Column Type
============ ==========
Simid uuid
QualId int
NucId int
MassFrac double
============ ==========
Would be restructured to:
============ ==========
Materials
------------------------
Column Type
============ ==========
SimId uuid
ResourceId int
ObjId int
TimeCreated int
Parent1 int
Parent2 int
Units string
Quantity double
Composition map<int,double>
============ ==========
Where the composition column would map <NucId, MassFrac>
============ ==========
Products
------------------------
Column Type
============ ==========
SimId uuid
ResourceId int
ObjId int
TimeCreated int
Parent1 int
Parent2 int
Units string
Quantity double
Quality string
============ ==========
Also, since **QualId** is removed, the **Recipes** Table
also needs to be edited:
============ ==========
Recipes
------------------------
Column Type
============ ==========
SimId uuid
Recipes string
Composition map<int,double>
============ ==========
Transactions
------------
The transactions table would be modified to have an integer flag for whether
the commodity is a material or a product. This flag let's anyone inspecting
the transaction table know which resource table (either **Materials** or
**Products**) to go to to find the actual concrete resource.
**Current:**
============ ==========
Transactions
------------------------
Column Type
============ ==========
SimId uuid
TransactionId int
SenderId int
ReceiverId int
ResourceId int
Commodity string
Time int
============ ==========
**Proposed**
================ ==========
Transactions
----------------------------
Column Type
================ ==========
SimId uuid
TransactionId int
SenderId int
ReceiverId int
**ResourceType** **int**
ResourceId int
Commodity string
Time int
================ ==========
This table will now be optionally written to the database. The default will be to
write this table (true).
ResCreators
-----------
Along with **Transactions**, the **ResCreators**
table would need another column, ResourceType:
============ ==========
ResCreators
------------------------
Column Type
============ ==========
Simid uuid
Resourceid int
AgentId int
ResourceType int
============ ==========
Merge ExplicitInventory & ExplicitInventoryCompact
----------------------------------------------------
The **ExplicitInventory** table and **ExplicitInventoryCompact**
table should be merged to a single table, called **Inventories**.
The current **ExplicitInventory** table and **ExplicitInventoryCompact**
table has a structure as such:
============ ==========
ExplicitInventory
------------------------
Column Type
============ ==========
Simid uuid
Agentid int
Time int
InventoryName string
NucId int
Quantity double
============ ==========
============ ==========
ExplicitInventoryCompact
------------------------
Column Type
============ ==========
Simid uuid
Agentid int
Time int
InventoryName string
Quantity double
Composition map<int,double>
============ ==========
============ ==========
Inventories
------------------------
Column Type
============ ==========
Simid uuid
Agentid int
Time int
InventoryName string
Quantity double
Composition int
============ ==========
This table will be optionally written to the database. The default will be to
write this table (true).
Merge Info & InfoExplicitInv
----------------------------
We saw little reason to separate the two tables. Combining them is a matter of cleanliness.
Additionally, the single **Info** table will have to contain an extra column, **RecordTransactions**.
Furthermore, the **RecordInventory** column is no longer needed and will be removed.
Other informational tables may also be merged into the single table.
Backwards Compatibility
=======================
This CEP is not backwards compatible.
Document History
================
This document is released under the CC-BY 3.0 license.
References and Footnotes
========================
.. rubric:: References