Example #1
0
        private void FillDistributionValueCollection()
        {
            Debug.Assert(this.m_DistributionValues.Count == 0);
            DataSheet ds = this.Scenario.GetDataSheet(Strings.DISTRIBUTION_VALUE_DATASHEET_NAME);

            foreach (DataRow dr in ds.GetData().Rows)
            {
                try
                {
                    DistributionFrequency?ValueDistributionFrequency = null;

                    if (dr[Strings.DISTRIBUTION_VALUE_VALUE_DIST_FREQUENCY_COLUMN_NAME] != DBNull.Value)
                    {
                        ValueDistributionFrequency = (DistributionFrequency)(long)dr[Strings.DISTRIBUTION_VALUE_VALUE_DIST_FREQUENCY_COLUMN_NAME];
                    }

                    STSimDistributionValue Item = new STSimDistributionValue(
                        DataTableUtilities.GetNullableInt(dr, Strings.DATASHEET_ITERATION_COLUMN_NAME),
                        DataTableUtilities.GetNullableInt(dr, Strings.DATASHEET_TIMESTEP_COLUMN_NAME),
                        DataTableUtilities.GetNullableInt(dr, Strings.DATASHEET_STRATUM_ID_COLUMN_NAME),
                        DataTableUtilities.GetNullableInt(dr, Strings.DATASHEET_SECONDARY_STRATUM_ID_COLUMN_NAME),
                        DataTableUtilities.GetNullableInt(dr, Strings.DATASHEET_TERTIARY_STRATUM_ID_COLUMN_NAME),
                        Convert.ToInt32(dr[Strings.DISTRIBUTION_VALUE_DIST_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture),
                        DataTableUtilities.GetNullableInt(dr,
                                                          Strings.DISTRIBUTION_VALUE_EXTVAR_TYPE_ID_COLUMN_NAME),
                        DataTableUtilities.GetNullableDouble(dr, Strings.DISTRIBUTION_VALUE_EXTVAR_MIN_COLUMN_NAME),
                        DataTableUtilities.GetNullableDouble(dr, Strings.DISTRIBUTION_VALUE_EXTVAR_MAX_COLUMN_NAME),
                        DataTableUtilities.GetNullableDouble(dr, Strings.DISTRIBUTION_VALUE_DIST_VALUE_COLUMN_NAME),
                        DataTableUtilities.GetNullableInt(dr, Strings.DISTRIBUTION_VALUE_VALUE_DIST_TYPE_ID_COLUMN_NAME),
                        ValueDistributionFrequency,
                        DataTableUtilities.GetNullableDouble(dr, Strings.DISTRIBUTION_VALUE_VALUE_DIST_SD_COLUMN_NAME),
                        DataTableUtilities.GetNullableDouble(dr, Strings.DISTRIBUTION_VALUE_VALUE_DIST_MIN_COLUMN_NAME),
                        DataTableUtilities.GetNullableDouble(dr, Strings.DISTRIBUTION_VALUE_VALUE_DIST_MAX_COLUMN_NAME),
                        DataTableUtilities.GetNullableDouble(dr, Strings.DISTRIBUTION_VALUE_VALUE_DIST_RELATIVE_FREQUENCY_COLUMN_NAME));

                    this.Validate(Item.ValueDistributionTypeId, Item.Value, Item.ValueDistributionSD, Item.ValueDistributionMin, Item.ValueDistributionMax);

                    this.m_DistributionValues.Add(Item);
                }
                catch (Exception ex)
                {
                    throw new ArgumentException(ds.DisplayName + " -> " + ex.Message);
                }
            }
        }
Example #2
0
        public void AddValue(STSimDistributionValue value)
        {
            SortedKeyMap2 <DistributionValueCollection> m = this.m_Map.GetItemExact(value.StratumId, value.SecondaryStratumId, value.DistributionTypeId);

            if (m == null)
            {
                m = new SortedKeyMap2 <DistributionValueCollection>(SearchMode.ExactPrevNext);
                this.m_Map.AddItem(value.StratumId, value.SecondaryStratumId, value.DistributionTypeId, m);
            }

            DistributionValueCollection c = m.GetItemExact(value.Iteration, value.Timestep);

            if (c == null)
            {
                c = new DistributionValueCollection();
                m.AddItem(value.Iteration, value.Timestep, c);
            }

            c.Add(value);
        }