CYCAMORE
Loading...
Searching...
No Matches
src/storage.h
Go to the documentation of this file.
1#ifndef CYCLUS_STORAGES_STORAGE_H_
2#define CYCLUS_STORAGES_STORAGE_H_
3
4#include <string>
5#include <list>
6#include <vector>
7
8#include "cyclus.h"
9#include "cycamore_version.h"
10
11#include "boost/shared_ptr.hpp"
12
13#pragma cyclus exec from cyclus.system import CY_LARGE_DOUBLE, CY_LARGE_INT, CY_NEAR_ZERO
14
15namespace cycamore {
89class Storage
90 : public cyclus::Facility,
91 public cyclus::toolkit::CommodityProducer,
92 public cyclus::toolkit::Position {
93 public:
95 Storage(cyclus::Context* ctx);
96
97 #pragma cyclus decl
98
99 #pragma cyclus note {"doc": "Storage is a simple facility which accepts any number of commodities " \
100 "and holds them for a user specified amount of time. The commodities accepted "\
101 "are chosen based on the specified preferences list. Once the desired amount of material "\
102 "has entered the facility it is passed into a 'processing' buffer where it is held until "\
103 "the residence time has passed. The material is then passed into a 'ready' buffer where it is "\
104 "queued for removal. Currently, all input commodities are lumped into a single output commodity. "\
105 "Storage also has the functionality to handle materials in discrete or continuous batches. Discrete "\
106 "mode, which is the default, does not split or combine material batches. Continuous mode, however, "\
107 "divides material batches if necessary in order to push materials through the facility as quickly "\
108 "as possible."}
109
111 virtual std::string str();
112
113 // --- Facility Members ---
114
115 // --- Agent Members ---
117 virtual void EnterNotify();
118
120 virtual void Tick();
121
123 virtual void Tock();
124
125 virtual std::string version() { return CYCAMORE_VERSION; }
126
127 protected:
133 void AddMat_(cyclus::Material::Ptr mat);
134
137
140 void ProcessMat_(double cap);
141
144 void ReadyMatl_(int time);
145
146 /* --- Storage Members --- */
147
149 inline double current_capacity() {
150 return (inventory_tracker.space()); }
151
153 inline double capacity() { return inventory_tracker.capacity(); }
154
156 int ready_time(){ return context()->time() - residence_time; }
157
158 /* --- Module Members --- */
159
160 #pragma cyclus var {"tooltip":"input commodity",\
161 "doc":"commodities accepted by this facility",\
162 "uilabel":"Input Commodities",\
163 "uitype":["oneormore","incommodity"]}
164 std::vector<std::string> in_commods;
165
166 #pragma cyclus var {"default": [],\
167 "doc":"preferences for each of the given commodities, in the same order."\
168 "Defauts to 1 if unspecified",\
169 "uilabel":"In Commody Preferences", \
170 "range": [None, [CY_NEAR_ZERO, CY_LARGE_DOUBLE]], \
171 "uitype":["oneormore", "range"]}
172 std::vector<double> in_commod_prefs;
173
174 #pragma cyclus var {"tooltip":"output commodity",\
175 "doc":"commodity produced by this facility. Multiple commodity tracking is"\
176 " currently not supported, one output commodity catches all input commodities.",\
177 "uilabel":"Output Commodities",\
178 "uitype":["oneormore","outcommodity"]}
179 std::vector<std::string> out_commods;
180
181 #pragma cyclus var {"default":"",\
182 "tooltip":"input recipe",\
183 "doc":"recipe accepted by this facility, if unspecified a dummy recipe is used",\
184 "uilabel":"Input Recipe",\
185 "uitype":"inrecipe"}
186 std::string in_recipe;
187
188 #pragma cyclus var {"default": 0,\
189 "tooltip":"residence time (timesteps)",\
190 "doc":"the minimum holding time for a received commodity (timesteps).",\
191 "units":"time steps",\
192 "uilabel":"Residence Time", \
193 "uitype": "range", \
194 "range": [0, 12000]}
195 int residence_time;
196
197 #pragma cyclus var {"default": 0,\
198 "tooltip":"sell quantity (kg)",\
199 "doc":"material will be sold in integer multiples of this quantity. If"\
200 " the buffer contains less than the sell quantity, no material will be"\
201 " offered", \
202 "uilabel":"Sell Quantity",\
203 "uitype": "range", \
204 "range": [0.0, CY_LARGE_DOUBLE], \
205 "units": "kg"}
206 double sell_quantity;
207
208 #pragma cyclus var {"default": CY_LARGE_DOUBLE,\
209 "tooltip":"throughput per timestep (kg)",\
210 "doc":"the max amount that can be moved through the facility per timestep (kg)",\
211 "uilabel":"Throughput",\
212 "uitype": "range", \
213 "range": [0.0, CY_LARGE_DOUBLE], \
214 "units":"kg"}
215 double throughput;
216
217 #pragma cyclus var {"default": CY_LARGE_DOUBLE,\
218 "tooltip":"maximum inventory size (kg)",\
219 "doc":"the maximum amount of material that can be in all storage buffer stages",\
220 "uilabel":"Maximum Inventory Size",\
221 "uitype": "range", \
222 "range": [0.0, CY_LARGE_DOUBLE], \
223 "units":"kg"}
224 double max_inv_size;
225
226 #pragma cyclus var {"default": False,\
227 "tooltip":"Bool to determine how Storage handles batches",\
228 "doc":"Determines if Storage will divide resource objects. Only controls material "\
229 "handling within this facility, has no effect on DRE material handling. "\
230 "If true, batches are handled as discrete quanta, neither split nor combined. "\
231 "Otherwise, batches may be divided during processing. Default to false (continuous))",\
232 "uilabel":"Batch Handling"}
234
235 #pragma cyclus var {"default": "Fixed",\
236 "tooltip": "Type of active buying frequency",\
237 "doc": "Options: Fixed, Uniform, Normal. Fixed requires active_buying_val. Uniform "\
238 "requires active_buying_min and active_buying_max. Normal "\
239 "requires active_buying_mean and active_buying_std, with optional "\
240 "active_buying_min and active_buying_max.",\
241 "uitype": "combobox",\
242 "categorical": ["Fixed", "Uniform", "Normal"],\
243 "uilabel": "Active Buying Frequency Type"}
245
246 #pragma cyclus var {"default": -1,\
247 "tooltip": "Fixed active buying frequency",\
248 "doc": "The length in time steps of the active buying period. Required for fixed "\
249 "active_buying_frequency_type. Must be greater than or equal to 1 (i.e., agent "\
250 "cannot always be dormant)",\
251 "uitype": "range", \
252 "range": [1, CY_LARGE_INT], \
253 "uilabel": "Active Buying Frequency Value"}
255
256 #pragma cyclus var {"default": -1,\
257 "tooltip": "Active buying distribution minimum",\
258 "doc": "The minimum length in time steps of the active buying period. Required for "\
259 "Uniform and optional for Normal active_buying_frequency_type. Must be greater than "\
260 "or equal to 1 ",\
261 "uitype": "range", \
262 "range": [1, CY_LARGE_INT], \
263 "uilabel": "Active Buying Frequency Minimum"}
265
266 #pragma cyclus var {"default": -1,\
267 "tooltip": "Active buying distribution maximum",\
268 "doc": "The maximum length in time steps of the active buying period. Required for "\
269 "Uniform active_buying_frequency_type, optional for Normal. Must be greater than or equal to active_buying_min ",\
270 "uitype": "range", \
271 "range": [1, CY_LARGE_INT], \
272 "uilabel": "Active Buying Frequency Maximum"}
274
275 #pragma cyclus var {"default": -1,\
276 "tooltip": "Active buying distribution mean",\
277 "doc": "The mean length in time steps of the active buying period. Required for "\
278 "Normal active_buying_frequency_type. Must be greater than or equal to 1 ",\
279 "uitype": "range", \
280 "range": [1.0, CY_LARGE_DOUBLE], \
281 "uilabel": "Active Buying Frequency Mean"}
282 double active_buying_mean;
283
284 #pragma cyclus var {"default": -1,\
285 "tooltip": "Active buying distribution standard deviation",\
286 "doc": "The standard deviation of the length in time steps of the active buying period. "\
287 "Required for Normal active_buying_frequency_type. Must be greater than or equal to 0 ",\
288 "uitype": "range", \
289 "range": [0.0, CY_LARGE_DOUBLE], \
290 "uilabel": "Active Buying Frequency Standard Deviation"}
292
293 #pragma cyclus var {"default": "Fixed",\
294 "tooltip": "Type of dormant buying frequency",\
295 "doc": "Options: Fixed, Uniform, Normal. Fixed requires dormant_buying_val. Uniform "\
296 "requires dormant_buying_min and dormant_buying_max. Normal requires "\
297 "dormant_buying_mean and dormant_buying_std, with optional dormant_buying_min "\
298 "and dormant_buying_max.",\
299 "uitype": "combobox",\
300 "categorical": ["Fixed", "Uniform", "Normal"],\
301 "uilabel": "Dormant Buying Frequency Type"}
303
304 #pragma cyclus var {"default": -1,\
305 "tooltip": "Fixed dormant buying frequency",\
306 "doc": "The length in time steps of the dormant buying period. Required for fixed "\
307 "dormant_buying_frequency_type. Default is -1, agent has no dormant period and stays active.",\
308 "uitype": "range", \
309 "range": [-1, CY_LARGE_INT], \
310 "uilabel": "Dormant Buying Frequency Value"}
312
313 #pragma cyclus var {"default": -1,\
314 "tooltip": "Dormant buying distribution minimum",\
315 "doc": "The minimum length in time steps of the dormant buying period. Required for Uniform and optional for "\
316 "Normal dormant_buying_frequency_type.",\
317 "uitype": "range", \
318 "range": [0, CY_LARGE_INT], \
319 "uilabel": "Dormant Buying Frequency Minimum"}
321
322 #pragma cyclus var {"default": -1,\
323 "tooltip": "Dormant buying distribution maximum",\
324 "doc": "The maximum length in time steps of the dormant buying period. Required for "\
325 "Uniform dormant_buying_frequency_type, optional for Normal. Must be greater than or equal to dormant_buying_min ",\
326 "uitype": "range", \
327 "range": [0, CY_LARGE_INT], \
328 "uilabel": "Dormant Buying Frequency Maximum"}
330
331 #pragma cyclus var {"default": -1,\
332 "tooltip": "Dormant buying distribution mean",\
333 "doc": "The mean length in time steps of the dormant buying period. Required for "\
334 "Normal dormant_buying_frequency_type. Must be greater than or equal to 0 ",\
335 "uitype": "range", \
336 "range": [0.0, CY_LARGE_DOUBLE], \
337 "uilabel": "Dormant Buying Frequency Mean"}
338 double dormant_buying_mean;
339
340 #pragma cyclus var {"default": -1,\
341 "tooltip": "Dormant buying distribution standard deviation",\
342 "doc": "The standard deviation of the length in time steps of the dormant buying period. "\
343 "Required for Normal dormant_buying_frequency_type. Must be greater than or equal to 0 ",\
344 "uitype": "range", \
345 "range": [0.0, CY_LARGE_DOUBLE], \
346 "uilabel": "Dormant Buying Frequency Standard Deviation"}
348
349 #pragma cyclus var {"default": "Fixed",\
350 "tooltip": "Type of behavior used to determine size of buy request",\
351 "doc": "Behavior function used to determine the size of requests made. All values are "\
352 "a fraction of maximum capacity, determined by the throughput and capacity remaining."\
353 " Options: Fixed, Uniform, Normal. Fixed is default behavior. Uniform requires "\
354 "buying_size_min and buying_size_max. Normal requires "\
355 "buying_size_mean and buying_size_stddev, optional buying_size_min and "\
356 "buying_size_max.",\
357 "uitype": "combobox",\
358 "categorical": ["Fixed", "Uniform", "Normal"],\
359 "uilabel": "Buying Size Type"}
360 std::string buying_size_type;
361
362 #pragma cyclus var {"default": 1.0,\
363 "tooltip": "Fixed buying size",\
364 "doc": "The size of the buy request as a fraction of maximum capacity. Optional for Fixed "\
365 "buying_size_type. Must be greater than or equal to 0.0",\
366 "uitype": "range", \
367 "range": [0.0, 1.0], \
368 "uilabel": "Buying Size Value"}
369 double buying_size_val;
370
371 #pragma cyclus var {"default": -1.0,\
372 "tooltip": "Buying size distribution minimum",\
373 "doc": "The minimum size of the buy request as a fraction of maximum capacity. "\
374 "Required for Uniform and optional for Normal buying_size_type. Must be greater than "\
375 "or equal to zero.",\
376 "uitype": "range", \
377 "range": [0.0, 1.0], \
378 "uilabel": "Buying Size Minimum"}
379 double buying_size_min;
380
381 #pragma cyclus var {"default": -1.0,\
382 "tooltip": "Buying size distribution maximum",\
383 "doc": "The maximum size of the buy request as a fraction of maximum capacity. "\
384 "Required for Uniform buying_size_type, optional for Normal. Must be greater than "\
385 "or equal to buying_size_min ",\
386 "uitype": "range", \
387 "range": [0.0, 1.0], \
388 "uilabel": "Buying Size Maximum"}
389 double buying_size_max;
390
391 #pragma cyclus var {"default": -1.0,\
392 "tooltip": "Buying size distribution mean",\
393 "doc": "The mean size of the buy request as a fraction of maximum capacity. "\
394 "Required for Normal buying_size_type.",\
395 "uitype": "range", \
396 "range": [0.0, 1.0], \
397 "uilabel": "Buying Size Mean"}
398 double buying_size_mean;
399
400 #pragma cyclus var {"default": -1.0,\
401 "tooltip": "Buying size distribution standard deviation",\
402 "doc": "The standard deviation of the size of the buy request as a fraction of "\
403 "maximum capacity. Required for Normal buying_size_type.",\
404 "uitype": "range", \
405 "range": [0.0, 1.0], \
406 "uilabel": "Buying Size Standard Deviation"}
407 double buying_size_stddev;
408
409 #pragma cyclus var {"default": -1,\
410 "tooltip":"Reorder point",\
411 "doc":"The point at which the facility will request more material. "\
412 "Above this point, no request will be made. Must be less than max_inv_size."\
413 "If paired with reorder_quantity, this agent will have an (R,Q) inventory policy. "\
414 "If reorder_point is used alone, this agent will have an (s,S) inventory policy, "\
415 " with S (the maximum) being set at max_inv_size.",\
416 "uilabel":"Reorder Point"}
417 double reorder_point;
418
419 #pragma cyclus var {"default": -1,\
420 "tooltip":"Reorder amount (R,Q inventory policy)",\
421 "doc":"The amount of material that will be requested when the reorder point is reached. "\
422 "Exclusive request, so will demand exactly reorder_quantity."\
423 "Reorder_point + reorder_quantity must be less than max_inv_size.",\
424 "uilabel":"Reorder Quantity"}
425 double reorder_quantity;
426
427 #pragma cyclus var {"default": -1,\
428 "tooltip": "Total amount of material that can be recieved per cycle.",\
429 "doc": "After receiving this much material cumulatively, the agent will go dormant. "\
430 "Must be paired with dormant_buying_frequency_type and any other dormant parameters. "\
431 "The per-time step demand is unchanged except the cycle cap is almost reached.",\
432 "uilabel": "Cumulative Cap"}
433 double cumulative_cap;
434
435 #pragma cyclus var {"default": "unpackaged", \
436 "tooltip": "Output package", \
437 "doc": "Outgoing material will be packaged when trading.", \
438 "uitype": "package", \
439 "uilabel": "Package"}
440 std::string package;
441
442 #pragma cyclus var {"default": "unrestricted", \
443 "tooltip": "Output transport unit", \
444 "doc": "Outgoing material, after packaging, will be "\
445 "further restricted by transport unit when trading.", \
446 "uitype": "transportunit", \
447 "uilabel": "Transport Unit"}
448 std::string transport_unit;
449
450 #pragma cyclus var {"tooltip":"Incoming material buffer"}
451 cyclus::toolkit::ResBuf<cyclus::Material> inventory;
452
453 #pragma cyclus var {"tooltip":"Output material buffer"}
454 cyclus::toolkit::ResBuf<cyclus::Material> stocks;
455
456 #pragma cyclus var {"tooltip":"Buffer for material held for required residence_time"}
457 cyclus::toolkit::ResBuf<cyclus::Material> ready;
458
460 #pragma cyclus var{"default": [],\
461 "internal": True}
462 std::list<int> entry_times;
463
464 #pragma cyclus var {"tooltip":"Buffer for material still waiting for required residence_time"}
465 cyclus::toolkit::ResBuf<cyclus::Material> processing;
466
467 #pragma cyclus var {"tooltip": "Total Inventory Tracker to restrict maximum agent inventory"}
468 cyclus::toolkit::TotalInvTracker inventory_tracker;
469
471 cyclus::toolkit::MatlBuyPolicy buy_policy;
472
474 cyclus::toolkit::MatlSellPolicy sell_policy;
475
476 #pragma cyclus var { \
477 "default": 0.0, \
478 "uilabel": "Geographical latitude in degrees as a double", \
479 "doc": "Latitude of the agent's geographical position. The value should " \
480 "be expressed in degrees as a double." \
481 }
482 double latitude;
483
484 #pragma cyclus var { \
485 "default": 0.0, \
486 "uilabel": "Geographical longitude in degrees as a double", \
487 "doc": "Longitude of the agent's geographical position. The value should " \
488 "be expressed in degrees as a double." \
489 }
490 double longitude;
491
492 cyclus::IntDistribution::Ptr active_dist_ = NULL;
493 cyclus::IntDistribution::Ptr dormant_dist_ = NULL;
494 cyclus::DoubleDistribution::Ptr size_dist_ = NULL;
495
496 cyclus::toolkit::Position coordinates;
497
499
500 friend class StorageTest;
501};
502
503} // namespace cycamore
504
505#endif // CYCLUS_STORAGES_STORAGE_H_
#define CYCAMORE_VERSION
Storage(cyclus::Context *ctx)
void AddMat_(cyclus::Material::Ptr mat)
adds a material into the incoming commodity inventory
double current_capacity()
current maximum amount that can be added to processing
cyclus::IntDistribution::Ptr active_dist_
cyclus::toolkit::MatlSellPolicy sell_policy
cyclus::toolkit::ResBuf< cyclus::Material > ready
cyclus::DoubleDistribution::Ptr size_dist_
std::vector< double > in_commod_prefs
virtual void Tick()
The handleTick function specific to the Storage.
cyclus::toolkit::ResBuf< cyclus::Material > processing
cyclus::toolkit::TotalInvTracker inventory_tracker
virtual std::string str()
A verbose printer for the Storage Facility.
std::vector< std::string > in_commods
cyclus::IntDistribution::Ptr dormant_dist_
void InitBuyPolicyParameters()
sets up the distributions for the buy policy
std::string active_buying_frequency_type
virtual std::string version()
std::string dormant_buying_frequency_type
cyclus::toolkit::ResBuf< cyclus::Material > inventory
int ready_time()
returns the time key for ready materials
void ProcessMat_(double cap)
Move as many ready resources as allowable into stocks.
virtual void Tock()
The handleTick function specific to the Storage.
std::vector< std::string > out_commods
std::list< int > entry_times
virtual void EnterNotify()
Sets up the Storage Facility's trade requests.
void ReadyMatl_(int time)
move ready resources from processing to ready at a certain time
void BeginProcessing_()
Move all unprocessed inventory to processing.
cyclus::toolkit::ResBuf< cyclus::Material > stocks
cyclus::toolkit::Position coordinates
double capacity()
returns total capacity
cyclus::toolkit::MatlBuyPolicy buy_policy