예제 #1
0
        internal SimObservationsSet(string subject, Arr <SimObservations> observations)
        {
            RequireTrue(observations.ForAll(o => o.Subject == subject));

            Subject      = subject;
            Observations = observations;
        }
예제 #2
0
        private static Arr <SimInput> CompileSampleInputs(
            Simulation simulation,
            Arr <DataTable> samples,
            Arr <DesignParameter> invariants
            )
        {
            RequireTrue(invariants.ForAll(
                            dp => dp.Distribution.DistributionType == DistributionType.Invariant
                            ));

            var defaultInput = simulation.SimConfig.SimInput;

            var targetParameters = samples.Head().Columns
                                   .Cast <DataColumn>()
                                   .Select(dc => defaultInput.SimParameters.GetParameter(dc.ColumnName))
                                   .ToArr();

            var invariantParameters = invariants.Map(dp =>
            {
                var parameter = defaultInput.SimParameters.GetParameter(dp.Name);
                return(parameter.With(dp.Distribution.Mean));
            });

            return(samples
                   .Map(dt => Range(0, dt.Rows.Count).Map(row =>
            {
                var dataRow = dt.Rows[row];

                var sampleParameters = targetParameters
                                       .Map((i, p) => p.With(dataRow.Field <double>(i)))
                                       .ToArr();

                return defaultInput.With(sampleParameters + invariantParameters);
            }))
                   .Bind(ei => ei)
                   .ToArr());
        }