public static string[] SerializeDistributions(Arr <IDistribution> distributions) { RequireTrue(_distributionTypes.ForAll( dt => distributions.Exists(ds => ds.DistributionType == dt) )); return(distributions.Map(ds => ds.ToString()).ToArray()); }
internal static string[] SerializeErrorModels(Arr <IErrorModel> errorModels) { RequireTrue(_errorModelTypes.ForAll( dt => errorModels.Exists(ds => ds.ErrorModelType == dt) )); return(errorModels.Map(ds => ds.ToString() !).ToArray()); }
private static OutputGroup Create( string name, SortedDictionary <string, List <double> > parameterValues, Arr <string> serieInputHashes, SimInput defaultInput ) { var includeDefaultValues = serieInputHashes.Exists(h => h == defaultInput.Hash); var ranges = parameterValues.Keys .OrderBy(k => k) .Select(k => { var defaultParameter = defaultInput.SimParameters.GetParameter(k); var list = parameterValues[k]; if (includeDefaultValues && !IsNaN(defaultParameter.Scalar)) { list.Add(defaultParameter.Scalar); } list.Sort(); var values = list.Distinct().ToArray(); var rangeDescription = k + "="; var unit = defaultParameter.Unit ?? string.Empty; if (values.Length == 1) { rangeDescription += $"{values[0]:G4}{unit}"; } else if (values.Length < 6) { rangeDescription += Join(",", values.Select(v => $"{v:G4}{unit}")); } else { var min = values.Min(); var max = values.Max(); rangeDescription += $"{min:G4}{unit}->{max:G4}{unit}"; } var rAssignmentRhs = values.Length > 1 ? $"c({Join(", ", values.Select(v => v.ToString(InvariantCulture)))})" : values[0].ToString(InvariantCulture); var rangeParameter = defaultParameter.With(rAssignmentRhs); return(Description: rangeDescription, Parameter: rangeParameter); }) .ToArray(); var description = Join(", ", ranges.Select(r => r.Description)); var createdOn = DateTime.Now; var inputAssignments = ranges.Select(r => r.Parameter).ToArr(); return(new OutputGroup(name, description, createdOn, inputAssignments, serieInputHashes)); }
internal OutputState( string name, ErrorModelType errorModelType, Arr <IErrorModel> errorModels, bool isSelected ) { RequireNotNullEmptyWhiteSpace(name); RequireFalse(errorModelType == ErrorModelType.None); RequireTrue(errorModels.Exists(d => d.ErrorModelType == errorModelType)); Name = name; ErrorModelType = errorModelType; ErrorModels = errorModels; IsSelected = isSelected; }
public ParameterState( string name, DistributionType distributionType, Arr <IDistribution> distributions, bool isSelected ) { RequireNotNullEmptyWhiteSpace(name); RequireFalse(distributionType == DistributionType.None); RequireTrue(distributions.Exists(d => d.DistributionType == distributionType)); Name = name; DistributionType = distributionType; Distributions = distributions; IsSelected = isSelected; }
public static bool ContainsState(this Arr <SimObservationsSharedState> observationsSharedStates, string reference) => observationsSharedStates.Exists(oss => oss.Reference == reference);
public static bool ContainsState(this Arr <SimElementSharedState> elementSharedStates, string name) => elementSharedStates.Exists(ess => ess.Name == name);
public static bool ContainsState(this Arr <SimParameterSharedState> parameterSharedStates, string name) => parameterSharedStates.Exists(pss => pss.Name == name);
public static bool ContainsParameter(this Arr <SimParameter> parameters, string name) => parameters.Exists(p => p.Name == name);
public static bool ContainsElement(this Arr <SimValue> values, string name) => values.Exists(v => v.SimElements.Exists(e => e.Name == name));
public static bool ContainsEvidenceSource(this Arr <SimEvidenceSource> evidenceSources, string refHash) => evidenceSources.Exists(es => es.RefHash == refHash);
public static bool ContainsObservationsSet(this Arr <SimObservationsSet> observationsSets, string subject) => observationsSets.Exists(os => os.Subject == subject);
public static bool ContainsObservations(this Arr <SimObservations> arr, SimObservations observations) => arr.Exists(o => o.EvidenceSourceID == observations.EvidenceSourceID && o.ID == observations.ID);