public static ThrowArgumentException ( string message ) : void | ||
message | string | |
return | void |
private void AddAttributeValue(TransitionAttributeValue item) { AttributeValueAgeBinCollection AgeBins = this.GetItemExact( item.TransitionAttributeTypeId, item.TransitionGroupId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId, item.StateClassId, item.Iteration, item.Timestep); if (AgeBins == null) { AgeBins = new AttributeValueAgeBinCollection(this.m_Project); this.AddItem( item.TransitionAttributeTypeId, item.TransitionGroupId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId, item.StateClassId, item.Iteration, item.Timestep, AgeBins); } try { AttributeValueAgeBin Bin = AgeBins.GetOrCreateAgeBin(item.MinimumAge, item.MaximumAge); Bin.AddReference(new AttributeValueReference(item.TSTGroupId, item.TSTMin, item.TSTMax, item)); } catch (STSimMapDuplicateItemException) { string template = "A duplicate Transition Attribute value has been created. More information:" + Environment.NewLine + "Transition Attribute={0}, Transition Group={1}, {2}={3}, {4}={5}, {6}={7}, MinAge={8}, MaxAge={9}, TSTMin={10}, TSTMax={11}, TSTGroup={12}, Iteration={13}, Timestep={14}." + Environment.NewLine + "NOTE: A user defined distribution can result in additional Transition Attributes when the model is run."; ExceptionUtils.ThrowArgumentException(template, this.GetTransitionAttributeTypeName(item.TransitionAttributeTypeId), this.GetTransitionGroupName(item.TransitionGroupId), this.PrimaryStratumLabel, this.GetStratumName(item.StratumId), this.SecondaryStratumLabel, this.GetSecondaryStratumName(item.SecondaryStratumId), this.TertiaryStratumLabel, this.GetTertiaryStratumName(item.TertiaryStratumId), item.MinimumAge, item.MaximumAge == int.MaxValue ? "NULL" : item.MaximumAge.ToString(), STSimMapBase.FormatValue(item.TSTMin), (!item.TSTMax.HasValue || item.TSTMax.Value == int.MaxValue) ? "NULL" : item.TSTMax.ToString(), this.GetTSTGroupString(item.TSTGroupId), STSimMapBase.FormatValue(item.Iteration), STSimMapBase.FormatValue(item.Timestep)); } if (!this.m_TypeGroupMap.ContainsKey(item.TransitionGroupId)) { this.m_TypeGroupMap.Add(item.TransitionGroupId, new Dictionary <int, bool>()); } Dictionary <int, bool> d = TypeGroupMap[item.TransitionGroupId]; if (!d.ContainsKey(item.TransitionAttributeTypeId)) { d.Add(item.TransitionAttributeTypeId, true); } Debug.Assert(this.HasItems); }
private static void ValidateReportScenarios(IEnumerable <int> sids, Library l) { Dictionary <int, bool> pids = new Dictionary <int, bool>(); foreach (int id in sids) { if (!l.Scenarios.Contains(id)) { ExceptionUtils.ThrowArgumentException("The scenario does not exist: {0}", id); } Scenario s = l.Scenarios[id]; if (!s.IsResult) { ExceptionUtils.ThrowArgumentException("The scenario is not a result scenario: {0}", id); } if (!pids.ContainsKey(s.Project.Id)) { pids.Add(s.Project.Id, true); } if (pids.Count > 1) { ExceptionUtils.ThrowArgumentException("The scenarios must belong to the same project: {0}", id); } } }
private void TryAddItem(TransitionTargetPrioritization item) { try { this.AddItem(item.TransitionGroupId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId, item.StateClassId, item.Iteration, item.Timestep, item); } catch (STSimMapDuplicateItemException) { string template = "A duplicate transition target prioritization was detected: More information:" + Environment.NewLine + "Transition Group={0}, {1}={2}, {3}={4}, {5}={6}, State Class={7}, Iteration={8}, Timestep={9}."; ExceptionUtils.ThrowArgumentException( template, this.GetTransitionGroupName(item.TransitionGroupId), this.PrimaryStratumLabel, this.GetStratumName(item.StratumId), this.SecondaryStratumLabel, this.GetSecondaryStratumName(item.SecondaryStratumId), this.TertiaryStratumLabel, this.GetTertiaryStratumName(item.TertiaryStratumId), this.GetStateClassName(item.StateClassId), STSimMapBase.FormatValue(item.Iteration), STSimMapBase.FormatValue(item.Timestep)); } Debug.Assert(this.HasItems); }
public ClassBinHelper(bool isEnabled, int frequency, int maximum) { if (isEnabled) { if (frequency <= 0) { ExceptionUtils.ThrowArgumentException( "The frequency must be greater than zero."); } if (maximum < frequency) { ExceptionUtils.ThrowArgumentException( "The maximum cannot be less than the frequency."); } } this.m_IsEnabled = isEnabled; this.m_Frequency = frequency; this.m_Maximum = maximum; if ((this.m_Maximum / (double)this.m_Frequency) > MAX_CLASSES) { this.m_Maximum = (this.m_Frequency * MAX_CLASSES); } }
/// <summary> /// Configures the timesteps and iterations for this model run /// </summary> /// <remarks></remarks> private void ConfigureTimestepsAndIterations() { DataRow dr = this.ResultScenario.GetDataSheet(Strings.DATASHEET_RUN_CONTROL_NAME).GetDataRow(); this.MinimumIteration = Convert.ToInt32(dr["MinimumIteration"], CultureInfo.InvariantCulture); this.MaximumIteration = Convert.ToInt32(dr["MaximumIteration"], CultureInfo.InvariantCulture); this.MinimumTimestep = Convert.ToInt32(dr["MinimumTimestep"], CultureInfo.InvariantCulture); this.MaximumTimestep = Convert.ToInt32(dr["MaximumTimestep"], CultureInfo.InvariantCulture); //We want run control to have the minimum timestep that it is configured with, but we don't want //to run this timestep. Instead, we want to set TimestepZero to the minimum timestep and run the //model starting at MinimumTimestep + 1. We need to configure these values before initializing the //rest of the model because some of the initialization routines depend on these values being set. if (this.MinimumTimestep == this.MaximumTimestep) { ExceptionUtils.ThrowArgumentException( "ST-Sim: The start {0} and end {1} cannot be the same.", this.m_TimestepUnitsLower, this.m_TimestepUnitsLower); } this.m_TimestepZero = this.MinimumTimestep; this.MinimumTimestep = this.MinimumTimestep + 1; this.m_TotalIterations = ( this.MaximumIteration - this.MinimumIteration + 1); }
private int?ParseJobsArgument() { int v = 0; string a = this.GetArgument("jobs"); if (string.IsNullOrEmpty(a)) { return(null); } if (this.GetArgument("child-process") == "True") { ExceptionUtils.ThrowArgumentException("The --jobs argument cannot be used with the --child-process argument."); } if (!int.TryParse(a, NumberStyles.Any, CultureInfo.InvariantCulture, out v)) { ExceptionUtils.ThrowArgumentException("The format for the --jobs argument is not correct."); } if (v <= 0) { ExceptionUtils.ThrowArgumentException("The value for the --jobs argument must be greater than zero."); } return(v); }
private void TryAddItem(TransitionAttributeTarget item) { try { base.AddItem(item.TransitionAttributeTypeId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId, item.Iteration, item.Timestep, item); } catch (STSimMapDuplicateItemException) { string template = "A duplicate transition attribute target was detected: More information:" + Environment.NewLine + "Transition Attribute Type={0}, {1}={2}, {3}={4}, {5}={6}, Iteration={7}, Timestep={8}." + Environment.NewLine + "NOTE: A user defined distribution can result in additional transition attribute targets when the model is run."; ExceptionUtils.ThrowArgumentException(template, this.GetTransitionAttributeTypeName(item.TransitionAttributeTypeId), this.PrimaryStratumLabel, this.GetStratumName(item.StratumId), this.SecondaryStratumLabel, this.GetSecondaryStratumName(item.SecondaryStratumId), this.TertiaryStratumLabel, this.GetTertiaryStratumName(item.TertiaryStratumId), STSimMapBase.FormatValue(item.Iteration), STSimMapBase.FormatValue(item.Timestep)); } }
private void TryAddItem(TransitionSizePrioritization item) { try { this.AddItem(item.TransitionGroupId, item.StratumId, item.Iteration, item.Timestep, item); } catch (STSimMapDuplicateItemException) { string template = "A duplicate transition size prioritization was detected: More information:" + Environment.NewLine + "Transition Group={0}, {1}={2}, Iteration={3}, Timestep={4}"; ExceptionUtils.ThrowArgumentException(template, this.GetTransitionGroupName(item.TransitionGroupId), this.PrimaryStratumLabel, this.GetStratumName(item.StratumId), STSimMapBase.FormatValue(item.Iteration), STSimMapBase.FormatValue(item.Timestep)); } }
private void TryAddItem(TransitionPathwayAutoCorrelation item) { try { this.AddItem(item.TransitionGroupId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId, item.Iteration, item.Timestep, item); } catch (STSimMapDuplicateItemException) { string template = "A duplicate transition pathway auto-correlation was detected: More information:" + Environment.NewLine + "Transition Group={0}, {1}={2}, {3}={4}, {5}={6}, Iteration={7}, Timestep={8}."; ExceptionUtils.ThrowArgumentException(template, this.GetTransitionGroupName(item.TransitionGroupId), this.PrimaryStratumLabel, this.GetStratumName(item.StratumId), this.SecondaryStratumLabel, this.GetSecondaryStratumName(item.SecondaryStratumId), this.TertiaryStratumLabel, this.GetTertiaryStratumName(item.TertiaryStratumId), STSimMapBase.FormatValue(item.Iteration), STSimMapBase.FormatValue(item.Timestep)); } }
public void AddGroup(int transitionTypeId, int?stratumId, int?secondaryStratumId, int?tertiaryStratumId, TstTransitionGroup item) { TstTransitionGroup v = this.m_Map.GetItemExact(transitionTypeId, stratumId, secondaryStratumId, tertiaryStratumId); if (v != null) { string template = "A duplicate Time-Since-Transition Group was detected: More information:" + Environment.NewLine + "Transition Type={0}, {1}={2}, {3}={4}, {5}={6}."; ExceptionUtils.ThrowArgumentException(template, this.GetTransitionTypeName(transitionTypeId), this.PrimaryStratumLabel, this.GetStratumName(stratumId), this.SecondaryStratumLabel, this.GetSecondaryStratumName(secondaryStratumId), this.TertiaryStratumLabel, this.GetTertiaryStratumName(tertiaryStratumId)); } this.m_Map.AddItem(transitionTypeId, stratumId, secondaryStratumId, tertiaryStratumId, item); this.SetHasItems(); }
private void AddTransition(DeterministicTransition t) { try { this.AddItem(t.StratumIdSource, t.StateClassIdSource, t.Iteration, t.Timestep, t); } catch (STSimMapDuplicateItemException) { string template = "A duplicate deterministic transition was detected: More information:" + Environment.NewLine + "Source {0}={1}, Source State Class={2}, Iteration={3}, Timestep={4}."; ExceptionUtils.ThrowArgumentException(template, this.PrimaryStratumLabel, this.GetStratumName(t.StratumIdSource), this.GetStateClassName(t.StateClassIdSource), STSimMapBase.FormatValue(t.Iteration), STSimMapBase.FormatValue(t.Timestep)); } Debug.Assert(this.HasItems); }
private void TryAddItem(TransitionDirectionMultiplier item) { try { this.AddItem( item.TransitionGroupId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId, (int?)item.CardinalDirection, item.Iteration, item.Timestep, item); } catch (STSimMapDuplicateItemException) { string template = "A duplicate transition direction multiplier was detected: More information:" + Environment.NewLine + "Transition Group={0}, {1}={2}, {3}={4}, {5}={6}, Iteration={7}, Timestep={8}, Cardinal Direction={9}." + Environment.NewLine + "NOTE: A user defined distribution can result in additional transition direction multipliers when the model is run."; ExceptionUtils.ThrowArgumentException(template, this.GetTransitionGroupName(item.TransitionGroupId), this.PrimaryStratumLabel, this.GetStratumName(item.StratumId), this.SecondaryStratumLabel, this.GetSecondaryStratumName(item.SecondaryStratumId), this.TertiaryStratumLabel, this.GetTertiaryStratumName(item.TertiaryStratumId), STSimMapBase.FormatValue(item.Iteration), STSimMapBase.FormatValue(item.Timestep), GetCardinalDirection(item.CardinalDirection)); } }
private string GetReportName() { string n = this.GetRequiredArgument("name"); if (n != Strings.STATECLASS_SUMMARY_REPORT_NAME && n != Strings.TRANSITION_SUMMARY_REPORT_NAME && n != Strings.TRANSITION_STATECLASS_SUMMARY_REPORT_NAME && n != Strings.STATE_ATTRIBUTE_REPORT_NAME && n != Strings.TRANSITION_ATTRIBUTE_REPORT_NAME) { ExceptionUtils.ThrowArgumentException("The report name is not valid."); } return(n); }
private static int FindSecondaryStratumId(int ssid, DataTable data, string pkidColumnName) { foreach (DataRow dr in data.Rows) { if (dr[Strings.DATASHEET_MAPID_COLUMN_NAME] != DBNull.Value) { int id = Convert.ToInt32(dr[Strings.DATASHEET_MAPID_COLUMN_NAME], CultureInfo.InvariantCulture); if (id == ssid) { return(Convert.ToInt32(dr[pkidColumnName], CultureInfo.InvariantCulture)); } } } ExceptionUtils.ThrowArgumentException("A Secondary Stratum with the ID '{0}' was not found.", ssid); return(0); }
private void TryAddItem(TransitionSpatialInitiationMultiplier item) { try { this.AddItem(item.TransitionGroupId, item.Iteration, item.Timestep, item); } catch (STSimMapDuplicateItemException) { string template = "A duplicate transition spatial initiation multiplier was detected: More information:" + Environment.NewLine + "Transition Group={0}, Iteration={1}, Timestep={2}"; ExceptionUtils.ThrowArgumentException(template, this.GetTransitionGroupName(item.TransitionGroupId), STSimMapBase.FormatValue(item.Iteration), STSimMapBase.FormatValue(item.Timestep)); } Debug.Assert(this.HasItems); }
/// <summary> /// Calculates the sum of the Non Spatial Initial Conditions relative amount /// </summary> /// <remarks></remarks> private double CalcSumOfRelativeAmount(int?iteration) { double sumOfRelativeAmount = 0.0; InitialConditionsDistributionCollection icds = this.m_InitialConditionsDistributionMap.GetICDs(iteration); foreach (InitialConditionsDistribution sis in icds) { sumOfRelativeAmount += sis.RelativeAmount; } if (sumOfRelativeAmount <= 0.0) { ExceptionUtils.ThrowArgumentException("The sum of the relative amount cannot be zero."); } return(sumOfRelativeAmount); }
private void ValidateSlxSly(DataTable dt) { foreach (DataRow dr in dt.Rows) { if (dr[Strings.DATASHEET_STATECLASS_STATE_LABEL_X_ID_COLUMN_NAME] == DBNull.Value) { ExceptionUtils.ThrowArgumentException( "The data contains a NULL for '{0}'.", this.Columns[Strings.DATASHEET_STATECLASS_STATE_LABEL_X_ID_COLUMN_NAME].DisplayName); } if (dr[Strings.DATASHEET_STATECLASS_STATE_LABEL_Y_ID_COLUMN_NAME] == DBNull.Value) { ExceptionUtils.ThrowArgumentException( "The data contains a NULL for '{0}'.", this.Columns[Strings.DATASHEET_STATECLASS_STATE_LABEL_Y_ID_COLUMN_NAME].DisplayName); } } }
/// <summary> /// Initializes the model /// </summary> /// <remarks> /// This function must be called once the model has been configured /// </remarks> private void InitializeModel() { if (this.m_Cells.Count == 0) { ExceptionUtils.ThrowArgumentException("You must have at least one cell to run the simulation."); } if (!this.IsSpatial) { if (this.m_InitialConditionsDistributionMap.GetICDs(this.MinimumIteration).Count == 0) { ExceptionUtils.ThrowArgumentException("The initial conditions distribution collection cannot be empty."); } } Debug.Assert(this.MinimumTimestep > 0); Debug.Assert(this.MinimumIteration > 0); this.InitializeCellArea(); this.InitializeCollectionMaps(); this.InitializeIntervalMeanTimestepMap(); this.InitializeStateAttributes(); this.InitializeTransitionAttributes(); this.InitializeShufflableTransitionGroups(); this.InitializeTransitionTargetPrioritizations(); this.InitializeTransitionAttributeTargetPrioritizations(); if (this.IsSpatial) { this.InitializeAvgRasterStateClassMap(); this.InitializeAvgRasterAgeMap(); this.InitializeAvgRasterStratumMap(); this.InitializeAvgRasterTransitionProbMaps(); this.InitializeAvgRasterTSTMaps(); this.InitializeAvgRasterStateAttributeMaps(); this.InitializeAvgRasterTransitionAttributeMaps(); this.InitializeTransitionSpreadGroups(); } Debug.Assert(this.m_SummaryStratumStateResults.Count == 0); Debug.Assert(this.m_SummaryStratumTransitionStateResults.Count == 0); }
private List <int> GetSecondaryStratumIds(Scenario s) { List <int> l = null; string a = this.GetArgument("ssids"); if (string.IsNullOrEmpty(a)) { l = GetAllSecondaryStratumIds(s); } else { l = this.GetExplicitSecondaryStratumIds(s); } if (l.Count < 2) { ExceptionUtils.ThrowArgumentException("Cannot split with fewer than 2 Secondary Strata."); } return(l); }
private void AddAttributeValue(StateAttributeValue item) { AttributeValueAgeBinCollection AgeBins = this.GetItemExact( item.StateAttributeTypeId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId, item.StateClassId, item.Iteration, item.Timestep); if (AgeBins == null) { AgeBins = new AttributeValueAgeBinCollection(this.m_Project); this.AddItem( item.StateAttributeTypeId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId, item.StateClassId, item.Iteration, item.Timestep, AgeBins); } try { AttributeValueAgeBin Bin = AgeBins.GetOrCreateAgeBin(item.MinimumAge, item.MaximumAge); Bin.AddReference(new AttributeValueReference(item.TSTGroupId, item.TSTMin, item.TSTMax, item)); } catch (STSimMapDuplicateItemException ex) { string template = ex.Message + ". More information:" + Environment.NewLine + "State Attribute={0}, {1}={2}, {3}={4}, {5}={6}, Iteration={7}, Timestep={8}." + Environment.NewLine + "NOTE: A user defined distribution can result in additional State Attributes when the model is run."; ExceptionUtils.ThrowArgumentException(template, this.GetStateAttributeTypeName(item.StateAttributeTypeId), this.PrimaryStratumLabel, this.GetStratumName(item.StratumId), this.SecondaryStratumLabel, this.GetSecondaryStratumName(item.SecondaryStratumId), this.TertiaryStratumLabel, this.GetTertiaryStratumName(item.TertiaryStratumId), STSimMapBase.FormatValue(item.Iteration), STSimMapBase.FormatValue(item.Timestep)); } Debug.Assert(this.HasItems); }
private static int GetVersionTableValue(DataStore store, string tableName) { DataTable dt = store.CreateDataTable(tableName); if (dt.Rows.Count != 1) { ExceptionUtils.ThrowArgumentException("The version table '{0}' is corrupt. Cannot continue.", tableName); } //As of version 3.0.11, Ecological departure does not have a database updater so //its version table never gets the 2.x schema. However, we still need the current //version so we are going to look for it using the old column name as a special case. //This only affects Ecological Departure. if (dt.Columns.Contains("Version")) { Debug.Assert(tableName == "ED_Version"); return(Convert.ToInt32(dt.Rows[0]["Version"], CultureInfo.InvariantCulture)); } return(Convert.ToInt32(dt.Rows[0]["SchemaVersion"], CultureInfo.InvariantCulture)); }
private string CreateOutputDirectory(Scenario s) { string a = this.GetArgument("out"); if (string.IsNullOrEmpty(a)) { a = s.Library.GetFolderName(LibraryFolderType.Temporary, s, false); a = Path.Combine(a, "SSimJobs"); } else { a = Path.GetFullPath(a); } if (Directory.Exists(a)) { ExceptionUtils.ThrowArgumentException("The directory exists: {0}", a); } Directory.CreateDirectory(a); return(a); }
public void AddTstRandomize (int?transitionGroupId, int?stratumId, int?secondaryStratumId, int?tertiaryStratumId, int?stateClassId, int?iteration, TstRandomize tstRandomize) { SortedKeyMap1 <TstRandomize> m = this.m_map.GetItemExact( transitionGroupId, stratumId, secondaryStratumId, tertiaryStratumId, stateClassId); if (m == null) { m = new SortedKeyMap1 <TstRandomize>(SearchMode.ExactPrev); this.m_map.AddItem(transitionGroupId, stratumId, secondaryStratumId, tertiaryStratumId, stateClassId, m); } TstRandomize v = m.GetItemExact(iteration); if (v != null) { string template = "A duplicate Time-Since-Transition Randomize value was detected: More information:" + Environment.NewLine + "Transition Group={0}, {1}={2}, {3}={4}, {5}={6}, State Class={7}, Iteration={8}."; ExceptionUtils.ThrowArgumentException(template, this.GetTransitionGroupName(transitionGroupId), this.PrimaryStratumLabel, this.GetStratumName(stratumId), this.SecondaryStratumLabel, this.GetSecondaryStratumName(secondaryStratumId), this.TertiaryStratumLabel, this.GetTertiaryStratumName(tertiaryStratumId), this.GetStateClassName(stateClassId), STSimMapBase.FormatValue(iteration)); } m.AddItem(iteration, tstRandomize); this.SetHasItems(); }