コード例 #1
0
ファイル: Distribution.cs プロジェクト: thehoglet/RVis
        public static string[] SerializeDistributions(Arr <IDistribution> distributions)
        {
            RequireTrue(_distributionTypes.ForAll(
                            dt => distributions.Exists(ds => ds.DistributionType == dt)
                            ));

            return(distributions.Map(ds => ds.ToString()).ToArray());
        }
コード例 #2
0
        internal static string[] SerializeErrorModels(Arr <IErrorModel> errorModels)
        {
            RequireTrue(_errorModelTypes.ForAll(
                            dt => errorModels.Exists(ds => ds.ErrorModelType == dt)
                            ));

            return(errorModels.Map(ds => ds.ToString() !).ToArray());
        }
コード例 #3
0
ファイル: OutputGroup.cs プロジェクト: thehoglet/RVis
        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));
        }
コード例 #4
0
        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;
        }
コード例 #5
0
ファイル: ParameterState.cs プロジェクト: thehoglet/RVis
        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;
        }
コード例 #6
0
 public static bool ContainsState(this Arr <SimObservationsSharedState> observationsSharedStates, string reference) =>
 observationsSharedStates.Exists(oss => oss.Reference == reference);
コード例 #7
0
 public static bool ContainsState(this Arr <SimElementSharedState> elementSharedStates, string name) =>
 elementSharedStates.Exists(ess => ess.Name == name);
コード例 #8
0
 public static bool ContainsState(this Arr <SimParameterSharedState> parameterSharedStates, string name) =>
 parameterSharedStates.Exists(pss => pss.Name == name);
コード例 #9
0
 public static bool ContainsParameter(this Arr <SimParameter> parameters, string name) =>
 parameters.Exists(p => p.Name == name);
コード例 #10
0
 public static bool ContainsElement(this Arr <SimValue> values, string name) =>
 values.Exists(v => v.SimElements.Exists(e => e.Name == name));
コード例 #11
0
ファイル: SimEvidenceExt.cs プロジェクト: thehoglet/RVis
 public static bool ContainsEvidenceSource(this Arr <SimEvidenceSource> evidenceSources, string refHash) =>
 evidenceSources.Exists(es => es.RefHash == refHash);
コード例 #12
0
ファイル: SimEvidenceExt.cs プロジェクト: thehoglet/RVis
 public static bool ContainsObservationsSet(this Arr <SimObservationsSet> observationsSets, string subject) =>
 observationsSets.Exists(os => os.Subject == subject);
コード例 #13
0
ファイル: SimEvidenceExt.cs プロジェクト: thehoglet/RVis
 public static bool ContainsObservations(this Arr <SimObservations> arr, SimObservations observations) =>
 arr.Exists(o => o.EvidenceSourceID == observations.EvidenceSourceID && o.ID == observations.ID);