MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
ItemSet.cs
1using MyCaffe.basecode;
3using SimpleGraphing;
4using System;
5using System.Collections.Generic;
6using System.Diagnostics;
7using System.Drawing;
8using System.IO;
9using System.Linq;
10using System.Text;
11using System.Threading.Tasks;
13
14namespace MyCaffe.db.temporal
15{
19 [Serializable]
20 public class ItemSet
21 {
22 CryptoRandom m_random;
23 int m_nValIdx = 0;
25 ValueItem m_item = null;
27 int m_nColCount = 0;
28 List<int> m_rgRowCount = new List<int>(8);
29 int m_nTargetStreamNumIdx = 0;
30 RawValueSet m_data = null;
31 SimpleDatum m_sdStaticNum = null;
32 SimpleDatum m_sdStaticCat = null;
33
41 public ItemSet(CryptoRandom random, DatabaseTemporal db, ValueItem item, OrderedValueStreamDescriptorSet rgStrm)
42 {
43 m_random = random;
44 m_db = db;
45 m_item = item;
46 m_rgStrm = rgStrm;
47 }
48
52 public void CleanUp()
53 {
54 m_nColCount = 0;
55 }
56
60 public void Reset()
61 {
62 m_nValIdx = 0;
63 }
64
68 public ValueItem Item
69 {
70 get { return m_item; }
71 }
72
77 {
78 get { return m_rgStrm; }
79 }
80
87 public Tuple<DateTime, DateTime> Load(out bool bEOD)
88 {
89 int nSrcID = m_item.SourceID.Value;
90 int nItemID = m_item.ID;
91
92 if (m_data == null)
93 m_data = m_db.GetValues(nSrcID, nItemID);
94
95 bEOD = true;
96 m_nColCount = m_data.ColCount;
97 return new Tuple<DateTime, DateTime>(m_data.StartTime, m_data.EndTime);
98 }
99
104 public void LoadLimit(int nMax)
105 {
106#warning("TBD: LoadLimit")
107 }
108
124 public SimpleTemporalDatumCollection GetData(int nQueryIdx, ref int? nValueIdx, DB_ITEM_SELECTION_METHOD valueSelectionMethod, int nHistSteps, int nFutSteps, int nValueStepOffset = 1, bool bEnableDebug = false, string strDebugPath = null)
125 {
126 int nTotalSteps = nHistSteps + nFutSteps;
127 int nColCount = m_nColCount;
128
129 if (m_item.Steps.HasValue)
130 nColCount = m_item.Steps.Value;
131
132 if (nColCount < nTotalSteps)
133 return null;
134
135 if (valueSelectionMethod == DB_ITEM_SELECTION_METHOD.RANDOM)
136 {
137 m_nValIdx = m_random.Next(nColCount - nTotalSteps);
138 }
139 else if (valueSelectionMethod == DB_ITEM_SELECTION_METHOD.NONE)
140 {
141 if (m_nValIdx >= nColCount - nTotalSteps)
142 {
143 m_nValIdx = 0;
144 nValueIdx = m_nValIdx;
145 return null;
146 }
147 }
148
149 if (m_nValIdx < 0)
150 m_nValIdx = 0;
151
152 if (nValueIdx.HasValue && nValueIdx >= 0)
153 m_nValIdx = nValueIdx.Value;
154
155 nValueIdx = m_nValIdx;
156
157 SimpleDatum sdStatNum = null;
158 SimpleDatum sdStatCat = null;
159 getStaticData(ref sdStatNum, ref sdStatCat);
160
161 SimpleDatum sdHistNum = null;
162 SimpleDatum sdHistCat = null;
163 if (!getHistoricalData(m_nValIdx, nHistSteps, out sdHistNum, out sdHistCat))
164 return null;
165
166 SimpleDatum sdFutNum = null;
167 SimpleDatum sdFutCat = null;
168 if (!getFutureData(m_nValIdx + nHistSteps, nFutSteps, out sdFutNum, out sdFutCat))
169 return null;
170
171 SimpleDatum sdTarget = null;
172 SimpleDatum sdTargetHist = null;
173 if (!getTargetData(m_nValIdx, nHistSteps, nFutSteps, m_nTargetStreamNumIdx, out sdTarget, out sdTargetHist))
174 return null;
175
176 if (bEnableDebug)
177 {
178 debug("trg", nQueryIdx, strDebugPath, m_nValIdx, nHistSteps, nFutSteps, sdTargetHist, sdTarget);
179 debugStatic("stat_cat", nQueryIdx, strDebugPath, m_nValIdx, sdStatCat);
180 debugStatic("stat_num", nQueryIdx, strDebugPath, m_nValIdx, sdStatNum);
181 debug("hist_cat", nQueryIdx, strDebugPath, m_nValIdx, sdHistCat, STREAM_CLASS_TYPE.OBSERVED);
182 debug("hist_num", nQueryIdx, strDebugPath, m_nValIdx, sdHistNum, STREAM_CLASS_TYPE.OBSERVED);
183 debug("fut_cat", nQueryIdx, strDebugPath, m_nValIdx, sdFutCat, STREAM_CLASS_TYPE.KNOWN);
184 debug("fut_num", nQueryIdx, strDebugPath, m_nValIdx, sdFutNum, STREAM_CLASS_TYPE.KNOWN);
185 }
186
188 rgData.Add(m_sdStaticNum);
189 rgData.Add(m_sdStaticCat);
190 rgData.Add(sdHistNum);
191 rgData.Add(sdHistCat);
192 rgData.Add(sdFutNum);
193 rgData.Add(sdFutCat);
194 rgData.Add(sdTarget);
195 rgData.Add(sdTargetHist);
196 m_nValIdx++;
197
198 return rgData;
199 }
200
201 private void debugStatic(string strTag, int nQueryIdx, string strDebugPath, int nIdx, SimpleDatum sd)
202 {
203 if (string.IsNullOrEmpty(strDebugPath))
204 throw new Exception("You must specify a debug path, when 'EnableDebug' = true.");
205
206 if (sd == null)
207 return;
208
209 string strName = strTag + ": QueryIdx = " + nQueryIdx.ToString() + ", Idx = " + nIdx.ToString() + ", Length = " + sd.ItemCount.ToString() + " Time: None - Static";
210 PlotCollection plots = new PlotCollection(strName);
211
212 float[] rgf = sd.GetData<float>();
213 for (int i = 0; i < rgf.Length; i++)
214 {
215 float fVal = rgf[i];
216
217 Plot plot = new Plot(i, fVal);
218 plots.Add(plot);
219 }
220
221 if (!Directory.Exists(strDebugPath))
222 Directory.CreateDirectory(strDebugPath);
223
224 strDebugPath = strDebugPath.TrimEnd('\\') + "\\";
225 string strFile = strDebugPath + nQueryIdx.ToString() + "." + nIdx.ToString() + "." + strTag + ".png";
226 Image img = SimpleGraphingControl.QuickRender(plots, 1000, 600, true, ConfigurationAxis.VALUE_RESOLUTION.MINUTE, null, true, null, true);
227
228 img.Save(strFile);
229 img.Dispose();
230
231 }
232
233 private void debug(string strTag, int nQueryIdx, string strDebugPath, int nIdx, SimpleDatum sd, STREAM_CLASS_TYPE classType)
234 {
235 if (string.IsNullOrEmpty(strDebugPath))
236 throw new Exception("You must specify a debug path, when 'EnableDebug' = true.");
237
238 if (sd == null)
239 return;
240
241 DateTime[] rgSync = getTimeSync(nIdx, sd.Height);
242 if (rgSync.Length != sd.Height)
243 throw new Exception("The sync and data lengths do not match!");
244
245 string strName = strTag + ": QueryIdx = " + nQueryIdx.ToString() + ", Idx = " + nIdx.ToString() + ", Length = " + sd.ItemCount.ToString() + " Time: " + rgSync[0].ToString() + " - " + rgSync[rgSync.Length - 1].ToString();
246 PlotCollectionSet set = new PlotCollectionSet();
247 float[] rgf = sd.GetData<float>();
248
249 for (int i = 0; i < sd.Width; i++)
250 {
251 PlotCollection plots = new PlotCollection(strName + " strm #" + i.ToString());
252
253 for (int j = 0; j < sd.Height; j++)
254 {
255 int nDataIdx = j * sd.Width + i;
256 float fVal = rgf[nDataIdx];
257
258 Plot plot = new Plot(rgSync[j].ToFileTime(), fVal);
259 plot.Tag = rgSync[i];
260 plots.Add(plot);
261 }
262
263 set.Add(plots);
264 }
265
266 if (!Directory.Exists(strDebugPath))
267 Directory.CreateDirectory(strDebugPath);
268
269 DateTime dt = rgSync[0];
270
271 if (classType == STREAM_CLASS_TYPE.OBSERVED)
272 dt = rgSync[rgSync.Length - 1];
273
274 strDebugPath = strDebugPath.TrimEnd('\\') + "\\";
275 string strFile = strDebugPath + nQueryIdx.ToString() + "." + dt.Year.ToString() + "." + dt.Month.ToString() + "." + dt.Day.ToString() + "_" + dt.Hour.ToString() + "." + dt.Minute.ToString() + "." + dt.Second.ToString() + "." + nIdx.ToString() + "." + strTag + ".png";
276 Image img = SimpleGraphingControl.QuickRender(set, 1000, 600, true, ConfigurationAxis.VALUE_RESOLUTION.MINUTE, null, true, null, true);
277
278 img.Save(strFile);
279 img.Dispose();
280 }
281
282 private void debug(string strTag, int nQueryIdx, string strDebugPath, int nIdx, int nHistSteps, int nFutSteps, SimpleDatum sd1, SimpleDatum sd2)
283 {
284 if (string.IsNullOrEmpty(strDebugPath))
285 throw new Exception("You must specify a debug path, when 'EnableDebug' = true.");
286
287 DateTime[] rgSync = getTimeSync(nIdx, nHistSteps + nFutSteps);
288 SimpleDatum sd = getTargetData(nIdx, nHistSteps + nFutSteps, m_nTargetStreamNumIdx);
289
290 if (rgSync.Length != sd1.ItemCount + sd2.ItemCount)
291 throw new Exception("The sync and data lengths do not match!");
292
293 if (sd.ItemCount != sd1.ItemCount + sd2.ItemCount)
294 throw new Exception("The target data length does not match the sum of the historical and future data lengths!");
295
296 string strName = "TargetData: QueryIdx = " + nQueryIdx.ToString() + ", Idx = " + nIdx.ToString() + ", Hist = " + nHistSteps.ToString() + ", Fut = " + nFutSteps.ToString() + "\nTime: " + rgSync[0].ToString() + " - " + rgSync[rgSync.Length-1].ToString();
297 PlotCollection plots = new PlotCollection(strName);
298
299 float[] rgf1 = sd1.GetData<float>();
300 float[] rgf2 = sd2.GetData<float>();
301 float[] rgfE = sd.GetData<float>();
302
303 for (int i=0; i<rgf1.Length; i++)
304 {
305 float fVal = rgf1[i];
306
307 if (fVal != rgfE[i])
308 throw new Exception("The data values do not match!");
309
310 Plot plot = new Plot(rgSync[i].ToFileTime(), fVal);
311 plot.Tag = rgSync[i];
312 plots.Add(plot);
313 }
314
315 for (int i = 0; i < rgf2.Length; i++)
316 {
317 float fVal = rgf2[i];
318 int nDataIdx = i + rgf1.Length;
319
320 if (fVal != rgfE[nDataIdx])
321 throw new Exception("The data values do not match!");
322
323 Plot plot = new Plot(rgSync[nDataIdx].ToFileTime(), fVal);
324 plot.Tag = rgSync[nDataIdx];
325 plots.Add(plot);
326 }
327
328 if (!Directory.Exists(strDebugPath))
329 Directory.CreateDirectory(strDebugPath);
330
331 DateTime dt = rgSync[rgf1.Length];
332
333 strDebugPath = strDebugPath.TrimEnd('\\') + "\\";
334 string strFile = strDebugPath + nQueryIdx.ToString() + "." + dt.Year.ToString() + "." + dt.Month.ToString() + "." + dt.Day.ToString() + "_" + dt.Hour.ToString() + "." + dt.Minute.ToString() + "." + dt.Second.ToString() + "." + nIdx.ToString() + "." + strTag + ".png";
335 int nImgWid = 1000;
336 int nActualWid = plots.Count * 5 + 55;
337
338 if (nImgWid > nActualWid)
339 nImgWid = nActualWid;
340
341 Image img = SimpleGraphingControl.QuickRender(plots, nImgWid, 600, true, ConfigurationAxis.VALUE_RESOLUTION.MINUTE, null, true, null, true);
342
343 using (Graphics g = Graphics.FromImage(img))
344 {
345 Brush br = new SolidBrush(Color.FromArgb(64, Color.Blue));
346 int nWid = 5 * nFutSteps;
347 int nLeft = img.Width - (55 + nWid);
348 Rectangle rc = new Rectangle(nLeft, 0, nWid, img.Height);
349 g.FillRectangle(br, rc);
350 g.DrawLine(Pens.Lime, nLeft, 0, nLeft, img.Height);
351 br.Dispose();
352 }
353
354 img.Save(strFile);
355 img.Dispose();
356 }
357
358 private void getStaticData(ref SimpleDatum sdNum, ref SimpleDatum sdCat)
359 {
360 if (m_sdStaticNum != null && m_sdStaticCat != null)
361 {
362 sdNum = m_sdStaticNum;
363 sdCat = m_sdStaticCat;
364 return;
365 }
366
367 Tuple<float[], float[]> data = m_data.GetStaticValues();
368
369 List<ValueStreamDescriptor> rgDesc = m_rgStrm.GetStreamDescriptors(STREAM_CLASS_TYPE.STATIC, STREAM_VALUE_TYPE.NUMERIC);
370 int nC = 1;
371
372 if (rgDesc != null && rgDesc.Count > 0)
373 {
374 int nH = rgDesc.Count;
375 int nW = rgDesc.Max(p => p.Steps);
376 sdNum = new SimpleDatum(nC, nW, nH, data.Item1, 0, data.Item1.Length);
377 sdNum.TagName = "StaticNumeric";
378 }
379 else
380 {
381 sdNum = null;
382 }
383
384 rgDesc = m_rgStrm.GetStreamDescriptors(STREAM_CLASS_TYPE.STATIC, STREAM_VALUE_TYPE.CATEGORICAL);
385 nC = 1;
386
387 if (rgDesc != null && rgDesc.Count > 0)
388 {
389 int nH = rgDesc.Count;
390 int nW = rgDesc.Max(p => p.Steps);
391 sdCat = new SimpleDatum(nC, nW, nH, data.Item2, 0, data.Item2.Length);
392 sdCat.TagName = "StaticCategorical";
393 }
394 else
395 {
396 sdCat = null;
397 }
398
399 m_sdStaticNum = sdNum;
400 m_sdStaticCat = sdCat;
401 }
402
403 private bool getHistoricalData(int nIdx, int nCount, out SimpleDatum sdNum, out SimpleDatum sdCat)
404 {
405 sdNum = null;
406 sdCat = null;
407
408 Tuple<float[], float[], DateTime[]> dataObs = m_data.GetObservedValues(nIdx, nCount);
409 if (dataObs == null)
410 return false;
411
412 Tuple<float[], float[], DateTime[]> dataKnown = m_data.GetKnownValues(nIdx, nCount);
413 if (dataKnown == null)
414 return false;
415
416 // Collect the numeric data
417 {
418 List<ValueStreamDescriptor> rgDescO = m_rgStrm.GetStreamDescriptors(STREAM_CLASS_TYPE.OBSERVED, STREAM_VALUE_TYPE.NUMERIC);
419 int nObsCount = rgDescO == null ? 0 : rgDescO.Count;
420 List<ValueStreamDescriptor> rgDescK = m_rgStrm.GetStreamDescriptors(STREAM_CLASS_TYPE.KNOWN, STREAM_VALUE_TYPE.NUMERIC);
421 int nKnownCount = rgDescK == null ? 0 : rgDescK.Count;
422 int nItemCount = nObsCount + nKnownCount;
423
424 float[] rgfNum = null;
425 if (dataObs.Item1.Length > 0 && dataKnown.Item1.Length > 0)
426 {
427 rgfNum = new float[dataObs.Item1.Length + dataKnown.Item1.Length];
428
429 for (int i=0; i<nCount; i++)
430 {
431 for (int j = 0; j < nObsCount; j++)
432 {
433 int nDataIdx = i * nItemCount + j;
434 rgfNum[nDataIdx] = dataObs.Item1[i * nObsCount + j];
435 }
436
437 for (int j = 0; j < nKnownCount; j++)
438 {
439 int nDataIdx = i * nItemCount + nObsCount + j;
440 rgfNum[nDataIdx] = dataKnown.Item1[i * nKnownCount + j];
441 }
442 }
443 }
444 else if (dataObs.Item1.Length > 0)
445 {
446 rgfNum = dataObs.Item1;
447 }
448 else if (dataKnown.Item1.Length > 0)
449 {
450 rgfNum = dataKnown.Item1;
451 }
452
453 if (rgfNum != null)
454 {
455 int nC = 1;
456 int nH = nCount;
457 int nW = nItemCount;
458
459 sdNum = new SimpleDatum(nC, nW, nH, rgfNum, 0, rgfNum.Length);
460 sdNum.TagName = "HistoricalNumeric";
461 sdNum.Tag = dataObs.Item3;
462 }
463 else
464 {
465 sdNum = null;
466 }
467 }
468
469 // Collect the categorical data
470 {
471 List<ValueStreamDescriptor> rgDescO = m_rgStrm.GetStreamDescriptors(STREAM_CLASS_TYPE.OBSERVED, STREAM_VALUE_TYPE.CATEGORICAL);
472 int nObsCount = rgDescO == null ? 0 : rgDescO.Count;
473 List<ValueStreamDescriptor> rgDescK = m_rgStrm.GetStreamDescriptors(STREAM_CLASS_TYPE.KNOWN, STREAM_VALUE_TYPE.CATEGORICAL);
474 int nKnownCount = rgDescK == null ? 0 : rgDescK.Count;
475 int nItemCount = nObsCount + nKnownCount;
476
477 float[] rgfCat = null;
478 if (dataObs.Item2.Length > 0 && dataKnown.Item2.Length > 0)
479 {
480 rgfCat = new float[dataObs.Item2.Length + dataKnown.Item2.Length];
481
482 for (int i = 0; i < nCount; i++)
483 {
484 for (int j = 0; j < nObsCount; j++)
485 {
486 int nDataIdx = i * nItemCount + j;
487 rgfCat[nDataIdx] = dataObs.Item2[i * nObsCount + j];
488 }
489
490 for (int j = 0; j < nKnownCount; j++)
491 {
492 int nDataIdx = i * nItemCount + nObsCount + j;
493 rgfCat[nDataIdx] = dataKnown.Item2[i * nKnownCount + j];
494 }
495 }
496 }
497 else if (dataObs.Item2.Length > 0)
498 {
499 rgfCat = dataObs.Item2;
500 }
501 else if (dataKnown.Item2.Length > 0)
502 {
503 rgfCat = dataKnown.Item2;
504 }
505
506 if (rgfCat != null)
507 {
508 int nC = 1;
509 int nH = nCount;
510 int nW = nItemCount;
511
512 sdCat = new SimpleDatum(nC, nW, nH, rgfCat, 0, rgfCat.Length);
513 sdCat.TagName = "HistoricalCategorical";
514 sdCat.Tag = dataObs.Item3;
515 }
516 else
517 {
518 sdCat = null;
519 }
520 }
521
522 return true;
523 }
524
525 private bool getFutureData(int nIdx, int nCount, out SimpleDatum sdNum, out SimpleDatum sdCat)
526 {
527 sdNum = null;
528 sdCat = null;
529
530 Tuple<float[], float[], DateTime[]> dataKnown = m_data.GetKnownValues(nIdx, nCount);
531 if (dataKnown == null)
532 return false;
533
534 float[] rgfNum = null;
535 if (dataKnown.Item1.Length > 0)
536 rgfNum = dataKnown.Item1;
537
538 float[] rgfCat = null;
539 if (dataKnown.Item2.Length > 0)
540 rgfCat = dataKnown.Item2;
541
542 if (rgfNum != null)
543 {
544 List<ValueStreamDescriptor> rgDescK = m_rgStrm.GetStreamDescriptors(STREAM_CLASS_TYPE.KNOWN, STREAM_VALUE_TYPE.NUMERIC);
545 int nC = 1;
546 int nH = nCount;
547 int nW = rgDescK.Count;
548
549 sdNum = new SimpleDatum(nC, nW, nH, rgfNum, 0, rgfNum.Length);
550 sdNum.TagName = "FutureNumeric";
551 sdNum.Tag = dataKnown.Item3;
552 }
553 else
554 {
555 sdNum = null;
556 }
557
558 if (rgfCat != null)
559 {
560 List<ValueStreamDescriptor> rgDescK = m_rgStrm.GetStreamDescriptors(STREAM_CLASS_TYPE.KNOWN, STREAM_VALUE_TYPE.CATEGORICAL);
561 int nC = 1;
562 int nH = nCount;
563 int nW = rgDescK.Count;
564
565 sdCat = new SimpleDatum(nC, nW, nH, rgfCat, 0, rgfCat.Length);
566 sdCat.TagName = "FutureCategorical";
567 }
568 else
569 {
570 sdCat = null;
571 }
572
573 return true;
574 }
575
576 private bool getTargetData(int nIdx, int nHistSteps, int nFutSteps, int nTargetIdx, out SimpleDatum sdTarget, out SimpleDatum sdTargetHist)
577 {
578 sdTarget = null;
579 sdTargetHist = null;
580
581 Tuple<float[], DateTime[]> rgfTgt = m_data.GetObservedNumValues(nIdx + nHistSteps, nFutSteps, nTargetIdx);
582 if (rgfTgt == null)
583 return false;
584
585 Tuple<float[], DateTime[]> rgfTgtH = m_data.GetObservedNumValues(nIdx, nHistSteps, nTargetIdx);
586 if (rgfTgtH == null)
587 return false;
588
589 int nC = 1;
590 int nH = rgfTgt.Item1.Length;
591 int nW = 1;
592 sdTarget = new SimpleDatum(nC, nW, nH, rgfTgt.Item1, 0, rgfTgt.Item1.Length);
593 sdTarget.TagName = "Target";
594 sdTarget.Tag = rgfTgt.Item2;
595
596 nH = rgfTgtH.Item1.Length;
597 sdTargetHist = new SimpleDatum(nC, nW, nH, rgfTgtH.Item1, 0, rgfTgtH.Item1.Length);
598 sdTargetHist.TagName = "TargetHist";
599 sdTargetHist.Tag = rgfTgtH.Item2;
600
601 return true;
602 }
603
604 private SimpleDatum getTargetData(int nIdx, int nCount, int nTargetIdx)
605 {
606 Tuple<float[], DateTime[]> rgfTgt = m_data.GetObservedNumValues(nIdx, nCount, nTargetIdx);
607
608 int nC = 1;
609 int nH = 1;
610 int nW = rgfTgt.Item1.Length;
611 SimpleDatum sd = new SimpleDatum(nC, nW, nH, rgfTgt.Item1, 0, rgfTgt.Item1.Length);
612 sd.TagName = "Target";
613
614 return sd;
615 }
616
617 private DateTime[] getTimeSync(int nIdx, int nCount)
618 {
619 return m_data.GetTimeSyncValues(nIdx, nCount);
620 }
621
627 public int GetCount(int nSteps)
628 {
629 int nCount = m_nColCount - nSteps;
630 if (nCount < 0)
631 return 0;
632
633 return nCount;
634 }
635 }
636
637 [Serializable]
638 public partial class RawValue
639 {
640 }
641
642 [Serializable]
643 public partial class ValueItem
644 {
645 }
646
647 [Serializable]
648 public partial class ValueStream
649 {
650 }
651}
The CryptoRandom is a random number generator that can use either the standard .Net Random objec or t...
Definition: CryptoRandom.cs:14
int Next(int nMinVal, int nMaxVal, bool bMaxInclusive=true)
Returns a random int within the range
The SimpleDatum class holds a data input within host memory.
Definition: SimpleDatum.cs:161
string TagName
Returns a user-defined name of the tag associated with the data.
Definition: SimpleDatum.cs:910
int ItemCount
Returns the number of data items.
int Width
Return the width of the data.
int Height
Return the height of the data.
The SimpleTemporalDatumCollection manages a collection of SimpleTemporalDatum objects.
Definition: SimpleDatum.cs:91
void Add(SimpleDatum sd)
Add a new datum to the collection (must support the RealDataF data);
Definition: SimpleDatum.cs:106
The ordered value stream descriptor set is used to order the value stream descriptors by class and va...
List< ValueStreamDescriptor > GetStreamDescriptors(STREAM_CLASS_TYPE classType, STREAM_VALUE_TYPE valueType)
Retrieves the set of stream descriptors with the given class and value type.
The value stream descriptor describes a single value stream within a value item.
The DatabaseTemporal is used to manage all temporal specific database objects.
RawValueSet GetValues(int nSrcID, int nItemID)
Load the static value stream categorical values for a given source and item.
The ItemSet manages the data for a single item (e.g., customer, station, stock symbol,...
Definition: ItemSet.cs:21
void CleanUp()
Release all resources used.
Definition: ItemSet.cs:52
void Reset()
Reset the value index.
Definition: ItemSet.cs:60
SimpleTemporalDatumCollection GetData(int nQueryIdx, ref int? nValueIdx, DB_ITEM_SELECTION_METHOD valueSelectionMethod, int nHistSteps, int nFutSteps, int nValueStepOffset=1, bool bEnableDebug=false, string strDebugPath=null)
Retreives the static, historical and future data at a selected step.
Definition: ItemSet.cs:124
OrderedValueStreamDescriptorSet Streams
Returns the value streams.
Definition: ItemSet.cs:77
ValueItem Item
Returns the value item.
Definition: ItemSet.cs:69
ItemSet(CryptoRandom random, DatabaseTemporal db, ValueItem item, OrderedValueStreamDescriptorSet rgStrm)
The constructor.
Definition: ItemSet.cs:41
void LoadLimit(int nMax)
Clips the data to the load limit by removing older data items.
Definition: ItemSet.cs:104
Tuple< DateTime, DateTime > Load(out bool bEOD)
Loads the data for the item starting at the specified date/time and loading the specified number of s...
Definition: ItemSet.cs:87
int GetCount(int nSteps)
Return the total number of queries available in the item set.
Definition: ItemSet.cs:627
The RawValueData class is used to hold the data values for an ItemID.
Tuple< float[], float[]> GetStaticValues()
Return the static values.
Tuple< float[], float[], DateTime[]> GetObservedValues(int nIdx, int nCount)
Returns the observed values.
DateTime StartTime
Returns the start time of the data values.
Tuple< float[], DateTime[]> GetObservedNumValues(int nIdx, int nCount, int nValIdx)
Returns the observed values.
Tuple< float[], float[], DateTime[]> GetKnownValues(int nIdx, int nCount)
Returns the observed values.
int ColCount
Returns the row count of observed and known items.
DateTime[] GetTimeSyncValues(int nIdx, int nCount)
Returns the time sync values.
DateTime EndTime
Returns the end time of the data values.
The descriptors namespace contains all descriptor used to describe various items stored within the da...
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
DB_ITEM_SELECTION_METHOD
Defines the item (e.g., image or temporal item) selection method.
Definition: Interfaces.cs:278
The MyCaffe.db.temporal namespace contains all classes used to create the MyCaffeTemporalDatabase in-...
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12