コード例 #1
0
        internal static void SaveFast99OutputMeasures(
            SensitivityDesign instance,
            string outputName,
            DataTable firstOrder,
            DataTable totalOrder,
            DataTable variance,
            string pathToSensitivityDesignsDirectory
            )
        {
            RequireTrue(instance.SensitivityMethod == SensitivityMethod.Fast99);
            RequireDirectory(pathToSensitivityDesignsDirectory);

            var sensitivityDesignDirectory       = instance.CreatedOn.ToDirectoryName();
            var pathToSensitivityDesignDirectory = Combine(
                pathToSensitivityDesignsDirectory,
                sensitivityDesignDirectory
                );

            SaveFast99OutputMeasures(
                outputName,
                firstOrder,
                totalOrder,
                variance,
                pathToSensitivityDesignDirectory
                );
        }
コード例 #2
0
        internal static NumDataTable?LoadSensitivityDesignTrace(
            SensitivityDesign instance,
            string pathToSensitivityDesignsDirectory
            )
        {
            RequireDirectory(pathToSensitivityDesignsDirectory);

            var sensitivityDesignDirectory       = instance.CreatedOn.ToDirectoryName();
            var pathToSensitivityDesignDirectory = Combine(
                pathToSensitivityDesignsDirectory,
                sensitivityDesignDirectory
                );

            var pathToSerializedTrace = Combine(
                pathToSensitivityDesignDirectory,
                SERIALIZED_TRACE_FILE_NAME
                );

            if (File.Exists(pathToSerializedTrace))
            {
                var serializedTrace = File.ReadAllBytes(pathToSerializedTrace);
                using var memoryStream = new MemoryStream(serializedTrace);
                return(Serializer.Deserialize <NumDataTable>(memoryStream));
            }

            return(default);
コード例 #3
0
        internal static void SaveMorrisOutputMeasures(
            SensitivityDesign instance,
            string outputName,
            DataTable mu,
            DataTable muStar,
            DataTable sigma,
            string pathToSensitivityDesignsDirectory
            )
        {
            RequireTrue(instance.SensitivityMethod == SensitivityMethod.Morris);
            RequireDirectory(pathToSensitivityDesignsDirectory);

            var sensitivityDesignDirectory       = instance.CreatedOn.ToDirectoryName();
            var pathToSensitivityDesignDirectory = Combine(
                pathToSensitivityDesignsDirectory,
                sensitivityDesignDirectory
                );

            SaveMorrisOutputMeasures(
                outputName,
                mu,
                muStar,
                sigma,
                pathToSensitivityDesignDirectory
                );
        }
コード例 #4
0
        internal static void SaveSensitivityDesignTrace(
            SensitivityDesign instance,
            NumDataTable trace,
            string pathToSensitivityDesignsDirectory
            )
        {
            RequireDirectory(pathToSensitivityDesignsDirectory);

            var sensitivityDesignDirectory       = instance.CreatedOn.ToDirectoryName();
            var pathToSensitivityDesignDirectory = Combine(
                pathToSensitivityDesignsDirectory,
                sensitivityDesignDirectory
                );

            RequireDirectory(pathToSensitivityDesignDirectory);

            var pathToSerializedTrace = Combine(
                pathToSensitivityDesignDirectory,
                SERIALIZED_TRACE_FILE_NAME
                );

            using var memoryStream = new MemoryStream();
            Serializer.Serialize(memoryStream, trace);
            memoryStream.Position = 0;
            File.WriteAllBytes(pathToSerializedTrace, memoryStream.ToArray());
        }
コード例 #5
0
        internal static void SaveSensitivityDesign(
            SensitivityDesign instance,
            string pathToSensitivityDesignsDirectory
            )
        {
            RequireDirectory(pathToSensitivityDesignsDirectory);

            var sensitivityDesignDirectory       = instance.CreatedOn.ToDirectoryName();
            var pathToSensitivityDesignDirectory = Combine(
                pathToSensitivityDesignsDirectory,
                sensitivityDesignDirectory
                );

            RequireFalse(Directory.Exists(pathToSensitivityDesignDirectory));
            Directory.CreateDirectory(pathToSensitivityDesignDirectory);

            SaveDesign(
                instance.CreatedOn,
                instance.DesignParameters,
                instance.SensitivityMethod,
                instance.MethodParameters,
                pathToSensitivityDesignDirectory
                );

            SaveSamples(
                instance.Samples,
                pathToSensitivityDesignDirectory
                );

            SaveSerializedDesigns(
                instance.SerializedDesigns,
                pathToSensitivityDesignDirectory
                );
        }
コード例 #6
0
        internal void Export(Arr <string> outputNames, string targetDirectory)
        {
            RequireNotNull(_moduleState.SensitivityDesign);

            string measureNames;
            string mainEffect;

            if (_moduleState.SensitivityDesign.SensitivityMethod == SensitivityMethod.Morris)
            {
                SensitivityDesign.ExportMorris(
                    _moduleState.SensitivityDesign,
                    _moduleState.MeasuresState.MorrisOutputMeasures,
                    outputNames,
                    targetDirectory
                    );

                measureNames = "\"mu\", \"mustar\", \"sigma\"";
                mainEffect   = "\"mustar\"";
            }
            else if (_moduleState.SensitivityDesign.SensitivityMethod == SensitivityMethod.Fast99)
            {
                SensitivityDesign.ExportFast99(
                    _moduleState.SensitivityDesign,
                    _moduleState.MeasuresState.Fast99OutputMeasures,
                    outputNames,
                    targetDirectory
                    );

                measureNames = "\"firstorder\", \"totalorder\", \"variance\"";
                mainEffect   = "\"firstorder\"";
            }
            else
            {
                throw new InvalidOperationException(nameof(SensitivityMethod));
            }

            var r = Format(
                InvariantCulture,
                FMT_LOAD_DATA,
                targetDirectory.Replace("\\", "/"),
                measureNames,
                mainEffect
                );

            File.WriteAllText(Combine(targetDirectory, "load_data.R"), r);

            var maybeOutputs = _sampleInputs.Map(i => _simData.GetOutput(i, _simulation));
            var allLoaded    = maybeOutputs.ForAll(o => o.IsSome);

            if (allLoaded)
            {
                ExportOutputs(
                    outputNames,
                    targetDirectory,
                    _simulation,
                    maybeOutputs.Somes().ToArr()
                    );
            }
        }
コード例 #7
0
 internal static bool LoadMorrisOutputMeasures(
     SensitivityDesign instance,
     string outputName,
     string pathToSensitivityDesignsDirectory,
     out (DataTable Mu, DataTable MuStar, DataTable Sigma) measures
コード例 #8
0
 internal static void ExportMorris(
     SensitivityDesign sensitivityDesign,
     Map <string, (DataTable Mu, DataTable MuStar, DataTable Sigma)> outputMeasures,