private static void validateResults(SimulationResultsImport simulationResultsImport, IndividualResults individualResults) { var simulationResults = simulationResultsImport.SimulationResults; //No entry yet? Set this indiviudal results as base for the import if (!simulationResults.Any()) { simulationResults.Time = individualResults.Time; individualResults.UpdateQuantityTimeReference(); return; } validateTimeResults(simulationResultsImport, individualResults); var availableQuantityPaths = simulationResults.AllQuantityPaths(); var currentQuantityPaths = individualResults.Select(x => x.QuantityPath).ToList(); if (availableQuantityPaths.Count != currentQuantityPaths.Count) { simulationResultsImport.AddError(PKSimConstants.Error.IndividualResultsDoesNotHaveTheExpectedQuantity(individualResults.IndividualId, availableQuantityPaths, currentQuantityPaths)); return; } for (int i = 0; i < availableQuantityPaths.Count; i++) { if (!string.Equals(availableQuantityPaths[i], currentQuantityPaths[i])) { simulationResultsImport.AddError(PKSimConstants.Error.IndividualResultsDoesNotHaveTheExpectedQuantity(individualResults.IndividualId, availableQuantityPaths, currentQuantityPaths)); return; } } }
private SimulationResults createResultsFrom(DataRepository dataRepository, ISimModelBatch simModel, string[] parameters) { if (dataRepository.IsNull() || dataRepository.BaseGrid == null) { return(new NullSimulationResults()); } var results = new SimulationResults { Time = valuesFrom(dataRepository.BaseGrid, null, new string[] { }) }; foreach (var columnsForIndividual in dataRepository.AllButBaseGrid().GroupBy(selectIndividualIndex)) { var individualResults = new IndividualResults { IndividualId = columnsForIndividual.Key, Time = results.Time }; foreach (var dataColumn in columnsForIndividual) { individualResults.Add(valuesFrom(dataColumn, pathWithoutIndividualIndex(dataColumn, columnsForIndividual.Key), simModel, parameters)); } individualResults.UpdateQuantityTimeReference(); results.Add(individualResults); } return(results); }
public SimulationResults CreateResultsFrom(DataRepository dataRepository) { if (dataRepository.IsNull()) { return(new NullSimulationResults()); } var results = new SimulationResults(); var baseGrid = dataRepository.BaseGrid; results.Time = valuesFrom(baseGrid); foreach (var columnsForIndividual in dataRepository.AllButBaseGrid().GroupBy(selectIndividualIndex)) { var individualResults = new IndividualResults { IndividualId = columnsForIndividual.Key, Time = results.Time }; foreach (var dataColumn in columnsForIndividual) { individualResults.Add(valuesFrom(dataColumn, pathWithoutIndividualIndex(dataColumn, columnsForIndividual.Key))); } individualResults.UpdateQuantityTimeReference(); results.Add(individualResults); } return(results); }
private static void validateTimeResults(SimulationResultsImport simulationResultsImport, IndividualResults individualResults) { var time = simulationResultsImport.SimulationResults.Time; int expectedLength = time.Values.Length; int currentLength = individualResults.Time.Values.Length; if (time.Values.Length != individualResults.Time.Values.Length) { simulationResultsImport.AddError(PKSimConstants.Error.TimeArrayLengthDoesNotMatchFirstIndividual(individualResults.IndividualId, expectedLength, currentLength)); return; } for (int i = 0; i < currentLength; i++) { if (!ValueComparer.AreValuesEqual(time[i], individualResults.Time[i])) { simulationResultsImport.AddError(PKSimConstants.Error.TimeArrayValuesDoesNotMatchFirstIndividual(individualResults.IndividualId, i, time[i], individualResults.Time[i])); } } //update reference time to ensure that all results are using the same time individualResults.Time = time; individualResults.UpdateQuantityTimeReference(); }
protected override void Context() { base.Context(); _pkParameter1 = new QuantityPKParameter { QuantityPath = "Output1", Name = "AUC" }; _pkParameter1.SetValue(0, 10); _pkParameter1.SetValue(1, 11); _pkParameter1.SetValue(2, 12); _pkParameter1.SetValue(4, _defaultPK1Value); _pkParameter2 = new QuantityPKParameter { QuantityPath = "Output2", Name = "Cmax" }; _pkParameter2.SetValue(0, 20); _pkParameter2.SetValue(1, 21); _pkParameter2.SetValue(2, 22); _pkParameter2.SetValue(3, 23); _pkParameter2.SetValue(4, _defaultPK2Value); _pkAnalyses.AddPKAnalysis(_pkParameter1); _pkAnalyses.AddPKAnalysis(_pkParameter2); _sensitivityParameter1 = A.Fake <SensitivityParameter>().WithName("SP1"); A.CallTo(() => _sensitivityParameter1.DefaultValue).Returns(10); A.CallTo(() => _sensitivityParameter1.ParameterSelection.Path).Returns("SP1-PATH"); _sensitivityParameter2 = A.Fake <SensitivityParameter>().WithName("SP2"); A.CallTo(() => _sensitivityParameter2.DefaultValue).Returns(20); A.CallTo(() => _sensitivityParameter2.ParameterSelection.Path).Returns("SP2-PATH"); _sensitivityAnalysis.AddSensitivityParameter(_sensitivityParameter1); _sensitivityAnalysis.AddSensitivityParameter(_sensitivityParameter2); var pv11 = new ParameterVariation(parameterName: _sensitivityParameter1.Name, parameterIndex: 0, variationId: 0, variation: new[] { 15d, 200d, 300d }); var pv12 = new ParameterVariation(parameterName: _sensitivityParameter1.Name, parameterIndex: 0, variationId: 1, variation: new[] { 20d, 200d, 300d }); var pv21 = new ParameterVariation(parameterName: _sensitivityParameter2.Name, parameterIndex: 1, variationId: 2, variation: new[] { 100d, 21d, 300d }); var pv22 = new ParameterVariation(parameterName: _sensitivityParameter2.Name, parameterIndex: 1, variationId: 3, variation: new[] { 100d, 31d, 300d }); _variationData.DefaultValues = new[] { 100d, 200d, 300d }; _variationData.AddVariation(pv11); _variationData.AddVariation(pv12); _variationData.AddVariation(pv21); _variationData.AddVariation(pv22); _timeValues = new QuantityValues { QuantityPath = "Time", Values = new[] { 1, 2, 3, 4, 5f } }; _resV11 = new IndividualResults { IndividualId = 0, Time = _timeValues }; _resV11.Add(new QuantityValues { QuantityPath = "Output1", Values = new[] { 111.1f, 211.1f, 311.1f, 411.1f, 511.1f } }); _resV11.Add(new QuantityValues { QuantityPath = "Output2", Values = new[] { 111.2f, 211.2f, 311.2f, 411.2f, 511.2f } }); _resV11.UpdateQuantityTimeReference(); _resV12 = new IndividualResults { IndividualId = 1, Time = _timeValues }; _resV12.Add(new QuantityValues { QuantityPath = "Output1", Values = new[] { 112.1f, 212.1f, 312.1f, 412.1f, 512.1f } }); _resV12.Add(new QuantityValues { QuantityPath = "Output2", Values = new[] { 112.2f, 212.2f, 312.2f, 412.2f, 512.2f } }); _resV12.UpdateQuantityTimeReference(); _resV21 = new IndividualResults { IndividualId = 2, Time = _timeValues }; _resV21.Add(new QuantityValues { QuantityPath = "Output1", Values = new[] { 121.1f, 221.1f, 321.1f, 421.1f, 521.1f } }); _resV21.Add(new QuantityValues { QuantityPath = "Output2", Values = new[] { 121.2f, 221.2f, 321.2f, 421.2f, 521.2f } }); _resV21.UpdateQuantityTimeReference(); _resV22 = new IndividualResults { IndividualId = 3, Time = _timeValues }; _resV22.Add(new QuantityValues { QuantityPath = "Output1", Values = new[] { 122.1f, 222.1f, 322.1f, 422.1f, 522.1f } }); _resV22.Add(new QuantityValues { QuantityPath = "Output2", Values = new[] { 122.2f, 222.2f, 322.2f, 422.2f, 522.2f } }); _resV22.UpdateQuantityTimeReference(); _simulationResults.Add(_resV11); _simulationResults.Add(_resV12); _simulationResults.Add(_resV21); _simulationResults.Add(_resV22); }