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 {
102 : public cyclus::Facility,
103 public cyclus::toolkit::CommodityProducer,
104 public cyclus::toolkit::Position {
105 public:
107 Storage(cyclus::Context* ctx);
108
109 #pragma cyclus decl
110
111 #pragma cyclus note {"doc": "Storage is a simple facility which accepts any number of commodities " \
112 "and holds them for a user specified amount of time. The commodities accepted "\
113 "are chosen based on the specified preferences list. Once the desired amount of material "\
114 "has entered the facility it is passed into a 'processing' buffer where it is held until "\
115 "the residence time has passed. The material is then passed into a 'ready' buffer where it is "\
116 "queued for removal. Currently, all input commodities are lumped into a single output commodity. "\
117 "Storage also has the functionality to handle materials in discrete or continuous batches. Discrete "\
118 "mode, which is the default, does not split or combine material batches. Continuous mode, however, "\
119 "divides material batches if necessary in order to push materials through the facility as quickly "\
120 "as possible."}
121
123 virtual std::string str();
124
125 // --- Facility Members ---
126
127 // --- Agent Members ---
129 virtual void EnterNotify();
130
132 virtual void Tick();
133
135 virtual void Tock();
136
137 virtual std::string version() { return CYCAMORE_VERSION; }
138
139 protected:
145 void AddMat_(cyclus::Material::Ptr mat);
146
149
152 void ProcessMat_(double cap);
153
156 void ReadyMatl_(int time);
157
158 /* --- Storage Members --- */
159
161 inline double current_capacity() {
162 return (inventory_tracker.space()); }
163
165 inline double capacity() { return inventory_tracker.capacity(); }
166
168 int ready_time(){ return context()->time() - residence_time; }
169
170 /* --- Module Members --- */
171
172 #pragma cyclus var {"tooltip":"input commodity",\
173 "doc":"commodities accepted by this facility",\
174 "uilabel":"Input Commodities",\
175 "uitype":["oneormore","incommodity"]}
176 std::vector<std::string> in_commods;
177
178 #pragma cyclus var {"default": [],\
179 "doc":"preferences for each of the given commodities, in the same order."\
180 "Defauts to 1 if unspecified",\
181 "uilabel":"In Commody Preferences", \
182 "range": [None, [CY_NEAR_ZERO, CY_LARGE_DOUBLE]], \
183 "uitype":["oneormore", "range"]}
184 std::vector<double> in_commod_prefs;
185
186 #pragma cyclus var {"tooltip":"output commodity",\
187 "doc":"commodity produced by this facility. Multiple commodity tracking is"\
188 " currently not supported, one output commodity catches all input commodities.",\
189 "uilabel":"Output Commodities",\
190 "uitype":["oneormore","outcommodity"]}
191 std::vector<std::string> out_commods;
192
193 #pragma cyclus var {"default":"",\
194 "tooltip":"input recipe",\
195 "doc":"recipe accepted by this facility, if unspecified a dummy recipe is used",\
196 "uilabel":"Input Recipe",\
197 "uitype":"inrecipe"}
198 std::string in_recipe;
199
200 #pragma cyclus var {"default": 0,\
201 "tooltip":"residence time (timesteps)",\
202 "doc":"the minimum holding time for a received commodity (timesteps).",\
203 "units":"time steps",\
204 "uilabel":"Residence Time", \
205 "uitype": "range", \
206 "range": [0, 12000]}
207 int residence_time;
208
209 #pragma cyclus var {"default": 0,\
210 "tooltip":"sell quantity (kg)",\
211 "doc":"material will be sold in integer multiples of this quantity. If"\
212 " the buffer contains less than the sell quantity, no material will be"\
213 " offered", \
214 "uilabel":"Sell Quantity",\
215 "uitype": "range", \
216 "range": [0.0, CY_LARGE_DOUBLE], \
217 "units": "kg"}
218 double sell_quantity;
219
220 #pragma cyclus var {"default": CY_LARGE_DOUBLE,\
221 "tooltip":"throughput per timestep (kg)",\
222 "doc":"the max amount that can be moved through the facility per timestep (kg)",\
223 "uilabel":"Throughput",\
224 "uitype": "range", \
225 "range": [0.0, CY_LARGE_DOUBLE], \
226 "units":"kg"}
227 double throughput;
228
229 #pragma cyclus var {"default": CY_LARGE_DOUBLE,\
230 "tooltip":"maximum inventory size (kg)",\
231 "doc":"the maximum amount of material that can be in all storage buffer stages",\
232 "uilabel":"Maximum Inventory Size",\
233 "uitype": "range", \
234 "range": [0.0, CY_LARGE_DOUBLE], \
235 "units":"kg"}
236 double max_inv_size;
237
238 #pragma cyclus var {"default": False,\
239 "tooltip":"Bool to determine how Storage handles batches",\
240 "doc":"Determines if Storage will divide resource objects. Only controls material "\
241 "handling within this facility, has no effect on DRE material handling. "\
242 "If true, batches are handled as discrete quanta, neither split nor combined. "\
243 "Otherwise, batches may be divided during processing. Default to false (continuous))",\
244 "uilabel":"Batch Handling"}
246
247 #pragma cyclus var {"default": "Fixed",\
248 "tooltip": "Type of active buying frequency",\
249 "doc": "Options: Fixed, Uniform, Normal, Binomial, FixedWithDisruption. "\
250 "Fixed requires active_buying_val. Uniform "\
251 "requires active_buying_min and active_buying_max. Normal "\
252 "requires active_buying_mean and active_buying_std, with optional "\
253 "active_buying_min and active_buying_max. Binomial requires active_buying_end_probability."\
254 "FixedWithDisruption has a probability that any given cycle will have a disrupted, "\
255 "active length. Once per cycle, a Bernoulli distribution (Binomial dist "\
256 "with N=1) will be sampled to determine if typical or disrupted cycle. If typical, "\
257 "active_buying_val is cycle length. If disrupted, active_buying_disruption.",\
258 "uitype": "combobox",\
259 "categorical": ["Fixed", "Uniform", "Normal", "Binomial", "FixedWithDisruption"],\
260 "uilabel": "Active Buying Frequency Type"}
262
263 #pragma cyclus var {"default": -1,\
264 "tooltip": "Fixed active buying frequency",\
265 "doc": "The length in time steps of the active buying period. Required for fixed "\
266 "active_buying_frequency_type. Must be greater than or equal to 1 (i.e., agent "\
267 "cannot always be dormant)",\
268 "uitype": "range", \
269 "range": [1, CY_LARGE_INT], \
270 "uilabel": "Active Buying Frequency Value"}
272
273 #pragma cyclus var {"default": -1,\
274 "tooltip": "Active buying distribution minimum",\
275 "doc": "The minimum length in time steps of the active buying period. Required for "\
276 "Uniform and optional for Normal active_buying_frequency_type. Must be greater than "\
277 "or equal to 1 ",\
278 "uitype": "range", \
279 "range": [1, CY_LARGE_INT], \
280 "uilabel": "Active Buying Frequency Minimum"}
282
283 #pragma cyclus var {"default": -1,\
284 "tooltip": "Active buying distribution maximum",\
285 "doc": "The maximum length in time steps of the active buying period. Required for "\
286 "Uniform active_buying_frequency_type, optional for Normal. Must be greater than or equal to active_buying_min ",\
287 "uitype": "range", \
288 "range": [1, CY_LARGE_INT], \
289 "uilabel": "Active Buying Frequency Maximum"}
291
292 #pragma cyclus var {"default": -1,\
293 "tooltip": "Active buying distribution mean",\
294 "doc": "The mean length in time steps of the active buying period. Required for "\
295 "Normal active_buying_frequency_type. Must be greater than or equal to 1 ",\
296 "uitype": "range", \
297 "range": [1.0, CY_LARGE_DOUBLE], \
298 "uilabel": "Active Buying Frequency Mean"}
299 double active_buying_mean;
300
301 #pragma cyclus var {"default": -1,\
302 "tooltip": "Active buying distribution standard deviation",\
303 "doc": "The standard deviation of the length in time steps of the active buying period. "\
304 "Required for Normal active_buying_frequency_type. Must be greater than or equal to 0 ",\
305 "uitype": "range", \
306 "range": [0.0, CY_LARGE_DOUBLE], \
307 "uilabel": "Active Buying Frequency Standard Deviation"}
309
310 #pragma cyclus var {"default": 0,\
311 "tooltip": "Probability that agent will go offline during the next time step",\
312 "doc": "Binomial distribution has a fixed probability of going dormant at any given "\
313 "timestep, like a weighted coin flip. Required for Binomial active_buying_frequency_type. "\
314 "Must be between 0 and 1",\
315 "uitype": "range", \
316 "range": [0.0, 1.0], \
317 "uilabel": "Active Buying Offline Probability"}
319
320 #pragma cyclus var {"default": 0,\
321 "tooltip": "Probability that a cycle contains a disruption",\
322 "doc": "Probability that the agent undergoes a disruption (disrupted active period) "\
323 "during any given cycle. Required for FixedWithDisruption active_buying_frequency_type.",\
324 "uitype": "range",\
325 "range": [0.0, 1.0],\
326 "uilabel": "Active Buying Disruption Probability"}
328
329 #pragma cyclus var {"default": -1,\
330 "tooltip": "Fixed length of disrupted active cycle",\
331 "doc": "When a active cycle is disrupted, this is length of the active period instead "\
332 "of active_buying_val. Required for FixedWithDisruption active_buying_frequency_type",\
333 "uitype": "range",\
334 "range": [0, CY_LARGE_INT]}
336
337 #pragma cyclus var {"default": "Fixed",\
338 "tooltip": "Type of dormant buying frequency",\
339 "doc": "Options: Fixed, Uniform, Normal, Binomial, FixedWithDisruption. "\
340 "Fixed requires dormant_buying_val. "\
341 "Uniform requires dormant_buying_min and dormant_buying_max. Normal requires "\
342 "dormant_buying_mean and dormant_buying_std, with optional dormant_buying_min "\
343 "and dormant_buying_max. Binomial requires dormant_buying_end_probability. "\
344 "FixedWithDisruption has a probability that any given cycle will have a disrupted, "\
345 "or long, outage. Once per cycle, a Bernoulli distribution (Binomial dist "\
346 "with N=1) will be sampled to determine if typical or disrupted cycle. If typical, "\
347 "dormant_buying_val is cycle length. If disrupted, dormant_buying_disruption.",\
348 "uitype": "combobox",\
349 "categorical": ["Fixed", "Uniform", "Normal", "Binomial", "FixedWithDisruption"],\
350 "uilabel": "Dormant Buying Frequency Type"}
352
353 #pragma cyclus var {"default": -1,\
354 "tooltip": "Fixed dormant buying frequency",\
355 "doc": "The length in time steps of the dormant buying period. Required for fixed "\
356 "dormant_buying_frequency_type. Default is -1, agent has no dormant period and stays active.",\
357 "uitype": "range", \
358 "range": [-1, CY_LARGE_INT], \
359 "uilabel": "Dormant Buying Frequency Value"}
361
362 #pragma cyclus var {"default": -1,\
363 "tooltip": "Dormant buying distribution minimum",\
364 "doc": "The minimum length in time steps of the dormant buying period. Required for Uniform and optional for "\
365 "Normal dormant_buying_frequency_type.",\
366 "uitype": "range", \
367 "range": [0, CY_LARGE_INT], \
368 "uilabel": "Dormant Buying Frequency Minimum"}
370
371 #pragma cyclus var {"default": -1,\
372 "tooltip": "Dormant buying distribution maximum",\
373 "doc": "The maximum length in time steps of the dormant buying period. Required for "\
374 "Uniform dormant_buying_frequency_type, optional for Normal. Must be greater than or equal to dormant_buying_min ",\
375 "uitype": "range", \
376 "range": [0, CY_LARGE_INT], \
377 "uilabel": "Dormant Buying Frequency Maximum"}
379
380 #pragma cyclus var {"default": -1,\
381 "tooltip": "Dormant buying distribution mean",\
382 "doc": "The mean length in time steps of the dormant buying period. Required for "\
383 "Normal dormant_buying_frequency_type. Must be greater than or equal to 0 ",\
384 "uitype": "range", \
385 "range": [0.0, CY_LARGE_DOUBLE], \
386 "uilabel": "Dormant Buying Frequency Mean"}
387 double dormant_buying_mean;
388
389 #pragma cyclus var {"default": -1,\
390 "tooltip": "Dormant buying distribution standard deviation",\
391 "doc": "The standard deviation of the length in time steps of the dormant buying period. "\
392 "Required for Normal dormant_buying_frequency_type. Must be greater than or equal to 0 ",\
393 "uitype": "range", \
394 "range": [0.0, CY_LARGE_DOUBLE], \
395 "uilabel": "Dormant Buying Frequency Standard Deviation"}
397
398 #pragma cyclus var {"default": 0,\
399 "tooltip": "Probability that agent will return to active during the next time step",\
400 "doc": "Binomial distribution has a fixed probability of going active at any given "\
401 "timestep, like a weighted coin flip. Required for Binomial dormant_buying_frequency_type. "\
402 "Must be between 0 and 1",\
403 "uitype": "range", \
404 "range": [0.0, 1.0], \
405 "uilabel": "Dormant Buying Binomial Offline Probability"}
407
408 #pragma cyclus var {"default": 0,\
409 "tooltip": "Probability that a cycle contains a disruption",\
410 "doc": "Probability that the agent undergoes a disruption (longer offline period) "\
411 "during any given cycle. Required for FixedWithDisruption dormant_buying_frequency_type.",\
412 "uitype": "range",\
413 "range": [0.0, 1.0],\
414 "uilabel": "Dormant Buying Disruption Probability"}
416
417 #pragma cyclus var {"default": -1,\
418 "tooltip": "Fixed length of disrupted cycle",\
419 "doc": "When a dormant cycle is disrupted, this is length of the offline period instead "\
420 "of dormant_buying_val. Required for FixedWithDisruption dormant_buying_frequency_type",\
421 "uitype": "range",\
422 "range": [0, CY_LARGE_INT]}
424
425 #pragma cyclus var {"default": "Fixed",\
426 "tooltip": "Type of behavior used to determine size of buy request",\
427 "doc": "Behavior function used to determine the size of requests made. All values are "\
428 "a fraction of maximum capacity, determined by the throughput and capacity remaining."\
429 " Options: Fixed, Uniform, Normal. Fixed is default behavior. Uniform requires "\
430 "buying_size_min and buying_size_max. Normal requires "\
431 "buying_size_mean and buying_size_stddev, optional buying_size_min and "\
432 "buying_size_max.",\
433 "uitype": "combobox",\
434 "categorical": ["Fixed", "Uniform", "Normal"],\
435 "uilabel": "Buying Size Type"}
436 std::string buying_size_type;
437
438 #pragma cyclus var {"default": 1.0,\
439 "tooltip": "Fixed buying size",\
440 "doc": "The size of the buy request as a fraction of maximum capacity. Optional for Fixed "\
441 "buying_size_type. Must be greater than or equal to 0.0",\
442 "uitype": "range", \
443 "range": [0.0, 1.0], \
444 "uilabel": "Buying Size Value"}
445 double buying_size_val;
446
447 #pragma cyclus var {"default": -1.0,\
448 "tooltip": "Buying size distribution minimum",\
449 "doc": "The minimum size of the buy request as a fraction of maximum capacity. "\
450 "Required for Uniform and optional for Normal buying_size_type. Must be greater than "\
451 "or equal to zero.",\
452 "uitype": "range", \
453 "range": [0.0, 1.0], \
454 "uilabel": "Buying Size Minimum"}
455 double buying_size_min;
456
457 #pragma cyclus var {"default": -1.0,\
458 "tooltip": "Buying size distribution maximum",\
459 "doc": "The maximum size of the buy request as a fraction of maximum capacity. "\
460 "Required for Uniform buying_size_type, optional for Normal. Must be greater than "\
461 "or equal to buying_size_min ",\
462 "uitype": "range", \
463 "range": [0.0, 1.0], \
464 "uilabel": "Buying Size Maximum"}
465 double buying_size_max;
466
467 #pragma cyclus var {"default": -1.0,\
468 "tooltip": "Buying size distribution mean",\
469 "doc": "The mean size of the buy request as a fraction of maximum capacity. "\
470 "Required for Normal buying_size_type.",\
471 "uitype": "range", \
472 "range": [0.0, 1.0], \
473 "uilabel": "Buying Size Mean"}
474 double buying_size_mean;
475
476 #pragma cyclus var {"default": -1.0,\
477 "tooltip": "Buying size distribution standard deviation",\
478 "doc": "The standard deviation of the size of the buy request as a fraction of "\
479 "maximum capacity. Required for Normal buying_size_type.",\
480 "uitype": "range", \
481 "range": [0.0, 1.0], \
482 "uilabel": "Buying Size Standard Deviation"}
483 double buying_size_stddev;
484
485 #pragma cyclus var {"default": -1,\
486 "tooltip":"Reorder point",\
487 "doc":"The point at which the facility will request more material. "\
488 "Above this point, no request will be made. Must be less than max_inv_size."\
489 "If paired with reorder_quantity, this agent will have an (R,Q) inventory policy. "\
490 "If reorder_point is used alone, this agent will have an (s,S) inventory policy, "\
491 " with S (the maximum) being set at max_inv_size.",\
492 "uilabel":"Reorder Point"}
493 double reorder_point;
494
495 #pragma cyclus var {"default": -1,\
496 "tooltip":"Reorder amount (R,Q inventory policy)",\
497 "doc":"The amount of material that will be requested when the reorder point is reached. "\
498 "Exclusive request, so will demand exactly reorder_quantity."\
499 "Reorder_point + reorder_quantity must be less than max_inv_size.",\
500 "uilabel":"Reorder Quantity"}
501 double reorder_quantity;
502
503 #pragma cyclus var {"default": -1,\
504 "tooltip": "Total amount of material that can be recieved per cycle.",\
505 "doc": "After receiving this much material cumulatively, the agent will go dormant. "\
506 "Must be paired with dormant_buying_frequency_type and any other dormant parameters. "\
507 "The per-time step demand is unchanged except the cycle cap is almost reached.",\
508 "uilabel": "Cumulative Cap"}
509 double cumulative_cap;
510
511 #pragma cyclus var {"default": "unpackaged", \
512 "tooltip": "Output package", \
513 "doc": "Outgoing material will be packaged when trading.", \
514 "uitype": "package", \
515 "uilabel": "Package"}
516 std::string package;
517
518 #pragma cyclus var {"default": "unrestricted", \
519 "tooltip": "Output transport unit", \
520 "doc": "Outgoing material, after packaging, will be "\
521 "further restricted by transport unit when trading.", \
522 "uitype": "transportunit", \
523 "uilabel": "Transport Unit"}
524 std::string transport_unit;
525
526 #pragma cyclus var {"tooltip":"Incoming material buffer"}
527 cyclus::toolkit::ResBuf<cyclus::Material> inventory;
528
529 #pragma cyclus var {"tooltip":"Output material buffer"}
530 cyclus::toolkit::ResBuf<cyclus::Material> stocks;
531
532 #pragma cyclus var {"tooltip":"Buffer for material held for required residence_time"}
533 cyclus::toolkit::ResBuf<cyclus::Material> ready;
534
536 #pragma cyclus var{"default": [],\
537 "internal": True}
538 std::list<int> entry_times;
539
540 #pragma cyclus var {"tooltip":"Buffer for material still waiting for required residence_time"}
541 cyclus::toolkit::ResBuf<cyclus::Material> processing;
542
543 #pragma cyclus var {"tooltip": "Total Inventory Tracker to restrict maximum agent inventory"}
544 cyclus::toolkit::TotalInvTracker inventory_tracker;
545
547 cyclus::toolkit::MatlBuyPolicy buy_policy;
548
550 cyclus::toolkit::MatlSellPolicy sell_policy;
551
552 #pragma cyclus var { \
553 "default": 0.0, \
554 "uilabel": "Geographical latitude in degrees as a double", \
555 "doc": "Latitude of the agent's geographical position. The value should " \
556 "be expressed in degrees as a double." \
557 }
558 double latitude;
559
560 #pragma cyclus var { \
561 "default": 0.0, \
562 "uilabel": "Geographical longitude in degrees as a double", \
563 "doc": "Longitude of the agent's geographical position. The value should " \
564 "be expressed in degrees as a double." \
565 }
566 double longitude;
567
568 cyclus::IntDistribution::Ptr active_dist_ = NULL;
569 cyclus::IntDistribution::Ptr dormant_dist_ = NULL;
570 cyclus::DoubleDistribution::Ptr size_dist_ = NULL;
571
572 cyclus::toolkit::Position coordinates;
573
575
576 friend class StorageTest;
577};
578
579} // namespace cycamore
580
581#endif // CYCLUS_STORAGES_STORAGE_H_
#define CYCAMORE_VERSION
This Facility is intended to hold materials for a user specified amount of time in order to model a s...
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