public static (double Value, double Minimum, double Maximum) GetParameterValueStateOrDefaults( this Arr <SimParameterSharedState> parameterSharedStates, string name, Arr <SimParameter> parameters ) { var parameterSharedState = parameterSharedStates.Find(pss => pss.Name == name); return(parameterSharedState.Match( pss => (pss.Value, pss.Minimum, pss.Maximum), () => { var parameter = parameters.GetParameter(name); var scalar = parameter.Scalar; return (scalar, scalar.GetPreviousOrderOfMagnitude(), scalar.GetNextOrderOfMagnitude()); })); }
private NumDataTable?_Execute(Arr <SimParameter> parameters) { File.Delete(_pathToOutFile); var source = _defaultSource.Map( p => parameters.Find(pp => pp.Name == p.Name).IfNone(p) ); var scriptObject = new ScriptObject(); source.Iter(p => scriptObject.Add(p.Name, p.Value)); var context = new TemplateContext(); context.PushGlobal(scriptObject); var @in = _templateIn.Render(context); WriteAllText(_pathToInFile, @in); using var run = Process.Start(_processStartInfo); RequireNotNull(run, "Failed to start MCSim process"); run.WaitForExit(); if (run.ExitCode != 0) { var stdOut = run.StandardOutput.ReadToEnd(); var stdErr = run.StandardError.ReadToEnd(); return(HandleFailure(run.ExitCode, stdOut, stdErr)); } if (!File.Exists(_pathToOutFile)) { var stdOut = run.StandardOutput.ReadToEnd(); return(HandleIntegrationFailure(stdOut)); } return(ProcessOutFile()); }
public static Option <SimObservationsSharedState> FindState(this Arr <SimObservationsSharedState> observationsSharedStates, string reference) => observationsSharedStates.Find(oss => oss.Reference == reference);
public static Option <SimElementSharedState> FindState(this Arr <SimElementSharedState> elementSharedStates, string name) => elementSharedStates.Find(ess => ess.Name == name);
public static Option <SimParameterSharedState> FindState(this Arr <SimParameterSharedState> parameterSharedStates, string name) => parameterSharedStates.Find(pss => pss.Name == name);
public static SimParameter GetParameter(this Arr <SimParameter> parameters, string name) => parameters.Find(p => p.Name == name).AssertSome($"Unknown parameter: {name}");
public static Option <SimParameter> FindParameter(this Arr <SimParameter> parameters, string name) => parameters.Find(p => p.Name == name);
public static Option <SimEvidenceSource> FindEvidenceSource(this Arr <SimEvidenceSource> evidenceSources, string refHash) => evidenceSources.Find(es => es.RefHash == refHash);
public static Option <SimObservationsSet> FindObservationsSet(this Arr <SimObservationsSet> observationsSets, string subject) => observationsSets.Find(os => os.Subject == subject);