private RandomVariateGenerator GetRngFromFactory(string prngText) { SetCurrentPrng(prngText); var prng = RNGFactory.GetRNG(); return(prng); }
public void TestNormal() { const double mu = 0.0; const double sigma = 1.0; int numOfFailures = 0; const int numOfTimesToRun = 1000; const int maxExpectedFailures = 15; for (int i = 0; i < numOfTimesToRun; i++) { Console.WriteLine("Test Run Number {0}", (i + 1)); // Reset the seed for the next run Configuration.CurrentConfiguration = Configuration.ConfigurationFromString($"{{\"prng_seed\":{DateTime.Now.Millisecond},\"prng_index\":{i}}}"); RNGFactory.Reset(); if (IsNormalDistribution(mu, sigma) == false) { numOfFailures++; Console.WriteLine("This failed {0} times.", numOfFailures); } } Console.WriteLine("End of Test. This failed {0} times.", numOfFailures); Expect(numOfFailures <= maxExpectedFailures); }
// ReSharper restore InconsistentNaming protected SolverBase(ModelInfo modelInfo, float duration, int repeats, int samples, IModelBuilder modelBuilder = null) { if (modelBuilder == null) { modelBuilder = new ModelBuilder(); } this.modelInfo = modelInfo; this.duration = duration; SamplingParams = new SamplingParameters { RealizationCount = repeats, SampleCount = samples }; rng = RNGFactory.GetRNG(); _currentTime = 0.0f; model = modelBuilder.BuildModel(modelInfo); _time = model.Parameters.First(p => p.Name == "time"); untriggeredEvents = null; triggeredEvents = new Queue <TriggeredEvent>(); scheduledEvents = model.ScheduledEvents.Count > 0 ? new PriorityQueue <ScheduledEvent>(model.ScheduledEvents.Count) : null; trajectories = AllocateRecordingArrays(model.Observables, SamplingParams); InitializePerformanceMeasurements(); stopWatch = new Stopwatch(); }
private Empirical() { Dimensionality = 0; _binCount = 0; _binEdges = null; _probabilities = null; _sum = 0; _rng = RNGFactory.GetRNG(); }
public Uniform(double minimum, double maximum) { if (minimum > maximum) { throw new ArgumentException("Minimum must be <= maxmimum.", "minimum"); } _min = minimum; _max = maximum; _rng = RNGFactory.GetRNG(); }
public Normal(float mean, float variance) { if (variance <= 0.0f) { throw new ArgumentException("Variance must be greater than 0."); } _mean = mean; _variance = variance; _distributionSampler = RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG()); }
public void FixedPopulationTest() { Configuration.CurrentConfiguration = Configuration.ConfigurationFromString("{}"); RNGFactory.Reset(); var modelInfo = compartments.emodl.EmodlLoader.LoadEMODLModel("(import (rnrs) (emodl cmslib)) (start-model \"fixedPopulation\") (species S 42) (species I 1) (observe susceptible S) (reaction infect (S) (I) (* S I)) (end-model)"); var results = compartments.Program.ExecuteModel(modelInfo, "SSA", 10.0, 1000, 4); foreach (var vector in results.Data) { Assert.AreEqual(42.0, vector[0]); } }
public void GillespieTauTest() { ////// /Setup the test ///////// const string configString = @"{""solver"":""Tau"",""prng_seed"":123, ""prng_index"":1,""RNG"":{""type"":""PSEUDODES""}}"; Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(configString); ModelInfo modelInfo = EmodlLoader.LoadEMODLFile("resources//testmodelTau.emodl"); const double duration = 6.28318531; const int repeats = 42; const int samples = 100; var solver = new TauLeaping(modelInfo, duration, repeats, samples); //Find the method MethodInfo gillespieTauMethod = ReflectionUtility.GetHiddenMethod("GillespieTau", solver); //No need to test a0 = 0, since the method is only called when a0 != 0. // a0 != 0 ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("rng", solver, RNGFactory.GetRNG()); var inputArray = new object[1]; inputArray[0] = 1; var tauOut1 = gillespieTauMethod.Invoke(solver, inputArray); Assert.That(tauOut1, Is.EqualTo(0.21309720500123394)); ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("rng", solver, RNGFactory.GetRNG()); inputArray[0] = 100; var tauOut2 = gillespieTauMethod.Invoke(solver, inputArray); Assert.That(tauOut2, Is.EqualTo(0.0021309720500123394)); ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("rng", solver, RNGFactory.GetRNG()); inputArray[0] = 0.001; var tauOut3 = gillespieTauMethod.Invoke(solver, inputArray); Assert.That(tauOut3, Is.EqualTo(213.09720500123393)); }
private static void RunPopulationTest(string distribution, out double mean, out double stdDev) { Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(string.Format("{{\"prng_seed\":{0},\"prng_index\":{1}}}", DateTime.Now.Millisecond, DateTime.Now.DayOfYear)); RNGFactory.Reset(); const string modelTemplate = "(import (rnrs) (emodl cmslib)) (start-model \"fixedPopulation\") (species S ({0})) (species I 1) (observe susceptible S) (reaction infect (S) (I) (* S I)) (end-model)"; var modelInfo = compartments.emodl.EmodlLoader.LoadEMODLModel(string.Format(modelTemplate, distribution)); var results = compartments.Program.ExecuteModel(modelInfo, "SSA", 10.0, 1000, 4); double sum = results.Data.Sum(vector => vector[0]); double sumSqr = results.Data.Sum(vector => (vector[0] * vector[0])); double n = results.Data.Length; mean = sum / n; stdDev = Math.Sqrt((sumSqr - 2 * mean * sum + n * mean * mean) / n); Console.WriteLine("initial population (mean): {0}", mean); Console.WriteLine("initial population (std. dev.): {0}", stdDev); }
public void RngFactoryDefaultTest() { Configuration.CurrentConfiguration = Configuration.ConfigurationFromString("{}"); _resetMethodinfo.Invoke(null, null); RandomVariateGenerator rng = RNGFactory.GetRNG(); Console.WriteLine("Testing RNGFactory default value..."); if (AesCounterVariateGenerator.IsSupported) { Expect(rng is AesCounterVariateGenerator); } else { Expect(rng is PseudoDesVariateGenerator); } Console.WriteLine("{0}() PASSED", MethodBase.GetCurrentMethod().Name); }
public void CalculateProposedTauTest1() { Model model; MethodInfo calculateProposedTauMethod; MethodInfo resetModelStateMethod; var solver = DefaultSetupForCalculateProposedTauTests(out model, out calculateProposedTauMethod, out resetModelStateMethod); ReflectionUtility.SetHiddenField("_regime", solver, 0); double tauIn = 5; object[] inputArray1 = new object[1]; inputArray1[0] = tauIn; var tauOut1 = calculateProposedTauMethod.Invoke(solver, inputArray1); Assert.AreEqual(0.017758100416769496, tauOut1); ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); inputArray1[0] = 0.0001; var tauOut1B = calculateProposedTauMethod.Invoke(solver, inputArray1); Assert.AreEqual(inputArray1[0], tauOut1B); }
public void FireCriticalReactionTest() { ////// /Setup the test ///////// const string configString = @"{""solver"":""TAU""}"; Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(configString); var modelInfo = EmodlLoader.LoadEMODLFile("resources//testmodelTau.emodl"); const double duration = 6.28318531; const int repeats = 42; const int samples = 100; var solver = new TauLeaping(modelInfo, duration, repeats, samples); //Find the model object var model = ReflectionUtility.GetHiddenField <Model>("model", solver); //Find Hidden Method to in order to initialize the population of each of the species var resetModelStateMethod = ReflectionUtility.GetHiddenMethod("ResetModelState", solver); resetModelStateMethod.Invoke(solver, null); var updateAndSumRatesMethod = ReflectionUtility.GetHiddenMethod("UpdateAndSumRates", solver); var currentRates = ReflectionUtility.GetHiddenField <double[]>("_currentRates", solver); //Find the method var fireCriticalReactionMethod = ReflectionUtility.GetHiddenMethod("FireCriticalReaction", solver); //Find a0 update currentRates. var inputArrayForUpdate = new object[2]; inputArrayForUpdate[0] = model.Reactions; inputArrayForUpdate[1] = currentRates; var a0 = updateAndSumRatesMethod.Invoke(solver, inputArrayForUpdate); currentRates = ReflectionUtility.GetHiddenField <double[]>("_currentRates", solver); //Define inputs for method Here there is one reaction ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("rng", solver, RNGFactory.GetRNG()); var inputArray = new object[3]; var criticalReactions = new List <Reaction>(); criticalReactions.Add(model.Reactions[0]); var criticalRates = new double[1]; criticalRates[0] = currentRates[0]; inputArray[0] = criticalReactions; inputArray[1] = criticalRates; inputArray[2] = criticalRates[0]; fireCriticalReactionMethod.Invoke(solver, inputArray); Assert.AreEqual(6, model.Species[0].Count); Assert.AreEqual(1, model.Species[1].Count); //Define inputs for method Here there is for two reactions ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("rng", solver, RNGFactory.GetRNG()); resetModelStateMethod.Invoke(solver, null); inputArray = new object[3]; criticalReactions = new List <Reaction>(); criticalReactions.Add(model.Reactions[0]); criticalReactions.Add(model.Reactions[1]); criticalRates = new double[2]; criticalRates[0] = currentRates[0]; criticalRates[1] = currentRates[1]; inputArray[0] = criticalReactions; inputArray[1] = criticalRates; inputArray[2] = a0; fireCriticalReactionMethod.Invoke(solver, inputArray); Assert.AreEqual(6, model.Species[0].Count); Assert.AreEqual(1, model.Species[1].Count); ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("rng", solver, RNGFactory.GetRNG()); resetModelStateMethod.Invoke(solver, null); inputArray = new object[3]; criticalReactions = new List <Reaction>(); criticalReactions.Add(model.Reactions[0]); criticalReactions.Add(model.Reactions[1]); criticalRates = new double[2]; criticalRates[0] = currentRates[0]; criticalRates[1] = currentRates[1]; inputArray[0] = criticalReactions; inputArray[1] = criticalRates; inputArray[2] = a0; fireCriticalReactionMethod.Invoke(solver, inputArray); Assert.AreEqual(6, model.Species[0].Count); Assert.AreEqual(1, model.Species[1].Count); }
public void GillespieReactionTest() { ////// /Setup the test ///////// const string configString = @"{""solver"":""TAU""}"; Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(configString); var modelInfo = EmodlLoader.LoadEMODLFile("resources//testmodelTau.emodl"); const double duration = 6.28318531; const int repeats = 42; const int samples = 100; var solver = new TauLeaping(modelInfo, duration, repeats, samples); //Find the model object var model = ReflectionUtility.GetHiddenField <Model>("model", solver); //Find Hidden Method to in order to initialize the population of each of the species var resetModelStateMethod = ReflectionUtility.GetHiddenMethod("ResetModelState", solver); resetModelStateMethod.Invoke(solver, null); var updateAndSumRatesMethod = ReflectionUtility.GetHiddenMethod("UpdateAndSumRates", solver); var currentRates = ReflectionUtility.GetHiddenField <double[]>("_currentRates", solver); //Find the method var gillespieReactionMethod = ReflectionUtility.GetHiddenMethod("GillespieReaction", solver); //Test for one value of a0 ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("rng", solver, RNGFactory.GetRNG()); var inputArray = new object[1]; inputArray[0] = 0.01; var reactionOut = gillespieReactionMethod.Invoke(solver, inputArray); Assert.That(reactionOut, Is.EqualTo(model.Reactions[0])); //Test for an actual a0 from the model file. ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("rng", solver, RNGFactory.GetRNG()); var inputArrayForUpdate = new object[2]; inputArrayForUpdate[0] = model.Reactions; inputArrayForUpdate[1] = currentRates; var a0 = updateAndSumRatesMethod.Invoke(solver, inputArrayForUpdate); inputArray[0] = a0; var reactionOut2 = gillespieReactionMethod.Invoke(solver, inputArray); Assert.That(reactionOut2, Is.EqualTo(model.Reactions[0])); //Test for a changed a0 and rate parameter ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("rng", solver, RNGFactory.GetRNG()); model.Parameters[3].Value = 10.0; currentRates = ReflectionUtility.GetHiddenField <double[]>("_currentRates", solver); inputArrayForUpdate[1] = currentRates; a0 = updateAndSumRatesMethod.Invoke(solver, inputArrayForUpdate); inputArray[0] = a0; var reactionOut3 = gillespieReactionMethod.Invoke(solver, inputArray); Assert.That(reactionOut3, Is.EqualTo(model.Reactions[1])); }
public void FireNonCriticalReactionsTest() { const string configString = @"{""solver"":""Tau"",""prng_seed"":123, ""prng_index"":1,""RNG"":{""type"":""PSEUDODES""}}"; Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(configString); ModelInfo modelInfo = EmodlLoader.LoadEMODLFile("resources\\testmodelMidPoint.emodl"); const double duration = 6.28318531; const int repeats = 42; const int samples = 100; var solver = new TauLeaping(modelInfo, duration, repeats, samples); //Inputs for the method // Tau Step double tau1 = 0.0; var tau2 = (1.0 / 200.0); //Need a list of reactions var currentRates = new double[1]; var nonCriticalReaction = new List <Reaction>(); //Find Hidden Method to in order to initialize the population of each of the species MethodInfo resetModelStateMethod = ReflectionUtility.GetHiddenMethod("ResetModelState", solver); resetModelStateMethod.Invoke(solver, null); MethodInfo updateAndSumRatesMethod = ReflectionUtility.GetHiddenMethod("UpdateAndSumRates", solver); //Find the model object var model = ReflectionUtility.GetHiddenField <Model>("model", solver); currentRates[0] = model.Reactions[0].Rate; nonCriticalReaction.Add(model.Reactions[0]); object[] inputArray1 = new object[3]; inputArray1[0] = tau1; inputArray1[1] = nonCriticalReaction; inputArray1[2] = currentRates; object[] inputArray2 = new object[3]; inputArray2[0] = tau2; inputArray2[1] = nonCriticalReaction; inputArray2[2] = currentRates; //Find Hidden Method. MethodInfo fireNonCriticalReactionsMethod = ReflectionUtility.GetHiddenMethod("FireNonCriticalReactions", solver); // First Test if Tau = 0; fireNonCriticalReactionsMethod.Invoke(solver, inputArray1); Assert.AreEqual(400, model.Species[0].Value); Assert.AreEqual(200, model.Species[1].Value); Assert.AreEqual(900, model.Species[2].Value); //Second Test if Tau = = 0.05. Set the RNG to a known seed number, in order to exactly know what is generated ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); fireNonCriticalReactionsMethod.Invoke(solver, inputArray2); Assert.AreEqual(384.0, model.Species[0].Value); Assert.AreEqual(184.0, model.Species[1].Value); Assert.AreEqual(916.0, model.Species[2].Value); resetModelStateMethod.Invoke(solver, null); object[] inputArray3 = new object[2]; inputArray3[0] = model.Reactions; inputArray3[1] = currentRates; updateAndSumRatesMethod.Invoke(solver, inputArray3); ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); fireNonCriticalReactionsMethod.Invoke(solver, inputArray2); Assert.AreEqual(384.0, model.Species[0].Value); Assert.AreEqual(184.0, model.Species[1].Value); Assert.AreEqual(916.0, model.Species[2].Value); }
public void ExecuteReactionsTest() { //0. Setup const string configString = @"{""solver"":""Tau"",""prng_seed"":123, ""prng_index"":1,""RNG"":{""type"":""PSEUDODES""}}"; Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(configString); ModelInfo modelInfo = EmodlLoader.LoadEMODLFile("resources//testmodelTau.emodl"); const double duration = 6.28318531; const int repeats = 42; const int samples = 100; var solver = new TauLeaping(modelInfo, duration, repeats, samples); //Find Hidden Method to in order to initialize the population of each of the species MethodInfo resetModelStateMethod = ReflectionUtility.GetHiddenMethod("ResetModelState", solver); resetModelStateMethod.Invoke(solver, null); //Find the model object var model = ReflectionUtility.GetHiddenField <Model>("model", solver); //Find the method MethodInfo executeReactionsMethod = ReflectionUtility.GetHiddenMethod("ExecuteReactions", solver); //1. ==Regime.SSA ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); ReflectionUtility.SetHiddenField("_regime", solver, 0); ReflectionUtility.GetHiddenField <Reaction>("_ssaReaction", solver); //a. _ssaReaction == null; executeReactionsMethod.Invoke(solver, null); var regime = ReflectionUtility.GetHiddenField <int>("_regime", solver); Assert.AreEqual(0, regime); //b. _ssaReaction != null; ReflectionUtility.SetHiddenField("_remainingSSAsteps", solver, 1); ReflectionUtility.SetHiddenField("_ssaReaction", solver, model.Reactions[0]); ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); executeReactionsMethod.Invoke(solver, null); regime = ReflectionUtility.GetHiddenField <int>("_regime", solver); Assert.AreEqual(3, regime); Assert.AreEqual(6.0, model.Species[0].Count); Assert.AreEqual(1.0, model.Species[1].Count); //2. == Regime.NonCritical ReflectionUtility.SetHiddenField("_regime", solver, 1); ReflectionUtility.RunResetRngFactory(); resetModelStateMethod.Invoke(solver, null); model.Species[0].Count = 100; model.Species[1].Count = 50; var nonCriticalReactionsList = new List <Reaction>(); nonCriticalReactionsList.Add(model.Reactions[0]); nonCriticalReactionsList.Add(model.Reactions[1]); var nonCriticalRates = new double[2]; nonCriticalRates[0] = model.Reactions[0].Rate; nonCriticalRates[1] = model.Reactions[1].Rate; ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); ReflectionUtility.SetHiddenField("_leapTau", solver, 0.01); ReflectionUtility.SetHiddenField("_nonCriticalReactions", solver, nonCriticalReactionsList); ReflectionUtility.SetHiddenField("_noncriticalRates", solver, nonCriticalRates); executeReactionsMethod.Invoke(solver, null); regime = ReflectionUtility.GetHiddenField <int>("_regime", solver); Assert.AreEqual(3, regime); Assert.AreEqual(103, model.Species[0].Count); Assert.AreEqual(47, model.Species[1].Count); //3. == Regime.Critical ) no noncriticalreactions ReflectionUtility.SetHiddenField("_regime", solver, 2); ReflectionUtility.RunResetRngFactory(); resetModelStateMethod.Invoke(solver, null); model.Species[0].Count = 100; model.Species[1].Count = 50; var criticalReactionsList = new List <Reaction>(); criticalReactionsList.Add(model.Reactions[0]); criticalReactionsList.Add(model.Reactions[1]); var criticalRates = new double[2]; criticalRates[0] = model.Reactions[0].Rate; criticalRates[1] = model.Reactions[1].Rate; MethodInfo updateAndSumRatesMethod = ReflectionUtility.GetHiddenMethod("UpdateAndSumRates", solver); object[] inputArray1 = new object[2]; inputArray1[0] = criticalReactionsList; inputArray1[1] = criticalRates; var a0Critical = updateAndSumRatesMethod.Invoke(solver, inputArray1); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); ReflectionUtility.SetHiddenField("_a0Critical", solver, a0Critical); ReflectionUtility.SetHiddenField("_criticalReactions", solver, criticalReactionsList); ReflectionUtility.SetHiddenField("_criticalRates", solver, criticalRates); ReflectionUtility.SetHiddenField("_nonCriticalReactions", solver, null); ReflectionUtility.SetHiddenField("_noncriticalRates", solver, null); executeReactionsMethod.Invoke(solver, null); regime = ReflectionUtility.GetHiddenField <int>("_regime", solver); Assert.AreEqual(3, regime); Assert.AreEqual(101, model.Species[0].Count); Assert.AreEqual(49, model.Species[1].Count); //3. == Regime.Critical b) noncriticalreactions and critical reactions ReflectionUtility.SetHiddenField("_regime", solver, 2); ReflectionUtility.RunResetRngFactory(); resetModelStateMethod.Invoke(solver, null); model.Species[0].Count = 100; model.Species[1].Count = 50; criticalReactionsList = new List <Reaction>(); nonCriticalReactionsList = new List <Reaction>(); criticalReactionsList.Add(model.Reactions[0]); nonCriticalReactionsList.Add(model.Reactions[1]); criticalRates = new double[1]; nonCriticalRates = new double[1]; criticalRates[0] = model.Reactions[0].Rate; nonCriticalRates[0] = model.Reactions[1].Rate; inputArray1[0] = criticalReactionsList; inputArray1[1] = criticalRates; a0Critical = updateAndSumRatesMethod.Invoke(solver, inputArray1); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); ReflectionUtility.SetHiddenField("_a0Critical", solver, a0Critical); ReflectionUtility.SetHiddenField("_leapTau", solver, 0.01); ReflectionUtility.SetHiddenField("_criticalReactions", solver, criticalReactionsList); ReflectionUtility.SetHiddenField("_criticalRates", solver, criticalRates); ReflectionUtility.SetHiddenField("_nonCriticalReactions", solver, nonCriticalReactionsList); ReflectionUtility.SetHiddenField("_noncriticalRates", solver, nonCriticalRates); executeReactionsMethod.Invoke(solver, null); regime = ReflectionUtility.GetHiddenField <int>("_regime", solver); Assert.AreEqual(3, regime); Assert.AreEqual(100, model.Species[0].Count); Assert.AreEqual(50, model.Species[1].Count); //4. == Regime.AnythingElse ReflectionUtility.SetHiddenField("_regime", solver, 4); try { executeReactionsMethod.Invoke(solver, null); Assert.Fail(); } catch (ApplicationException ex) { Assert.That(ex.GetBaseException().ToString(), Is.StringContaining("Bad solver mode.")); } }
public void CalculateProposedTauTest7() { Model model; MethodInfo calculateProposedTauMethod; MethodInfo resetModelStateMethod; var solver = DefaultSetupForCalculateProposedTauTests(out model, out calculateProposedTauMethod, out resetModelStateMethod); object[] inputArray1 = new object[1]; ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); resetModelStateMethod.Invoke(solver, null); ReflectionUtility.SetHiddenField("_regime", solver, 3); model.Species[0].Count = 3; model.Species[1].Count = 3; inputArray1[0] = 10; ReflectionUtility.SetHiddenField("nc", solver, 10); var tauOut7 = calculateProposedTauMethod.Invoke(solver, inputArray1); Assert.AreEqual(0.023677467222359326, tauOut7); ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); ReflectionUtility.SetHiddenField("_regime", solver, 3); inputArray1[0] = 0.001; var tauOut7B = calculateProposedTauMethod.Invoke(solver, inputArray1); Assert.AreEqual(0.001, tauOut7B); }
public void CalculateProposedTauTest6() { Model model; MethodInfo calculateProposedTauMethod; MethodInfo resetModelStateMethod; var solver = DefaultSetupForCalculateProposedTauTests(out model, out calculateProposedTauMethod, out resetModelStateMethod); object[] inputArray1 = new object[1]; ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); resetModelStateMethod.Invoke(solver, null); ReflectionUtility.SetHiddenField("_regime", solver, 3); model.Species[0].Count = 200; model.Species[1].Count = 2; ReflectionUtility.SetHiddenField("epsilon", solver, 0.1); inputArray1[0] = 10; var tauOut6 = calculateProposedTauMethod.Invoke(solver, inputArray1); Assert.AreEqual(0.050502512562814073, tauOut6); ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); resetModelStateMethod.Invoke(solver, null); ReflectionUtility.SetHiddenField("_regime", solver, 3); model.Species[0].Count = 200; model.Species[1].Count = 2; ReflectionUtility.SetHiddenField("epsilon", solver, 0.1); inputArray1[0] = 10; var tauOut6Test = calculateProposedTauMethod.Invoke(solver, inputArray1); Assert.AreEqual(0.050502512562814073, tauOut6Test); ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); ReflectionUtility.SetHiddenField("_regime", solver, 3); inputArray1[0] = 0.01; var tauOut6B = calculateProposedTauMethod.Invoke(solver, inputArray1); Assert.AreEqual(0.01, tauOut6B); }
public void CalculateProposedTauTest4() { Model model; MethodInfo calculateProposedTauMethod; MethodInfo resetModelStateMethod; var solver = DefaultSetupForCalculateProposedTauTests(out model, out calculateProposedTauMethod, out resetModelStateMethod); ReflectionUtility.SetHiddenField("_regime", solver, 0); object[] inputArray1 = new object[1]; ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); //resetModelStateMethod.Invoke(solver, null); ReflectionUtility.SetHiddenField("_regime", solver, 3); model.Species[0].Count = 3; model.Species[1].Count = 2; inputArray1[0] = 10; ReflectionUtility.SetHiddenField("nc", solver, 3); var tauOut4 = calculateProposedTauMethod.Invoke(solver, inputArray1); Assert.AreEqual(0.026637150625154243, tauOut4); ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); ReflectionUtility.SetHiddenField("_regime", solver, 3); inputArray1[0] = 0.001; var tauOut4B = calculateProposedTauMethod.Invoke(solver, inputArray1); Assert.AreEqual(0.001, tauOut4B); ReflectionUtility.RunResetRngFactory(); ReflectionUtility.SetHiddenField("_distributionSampler", solver, RandLibSampler.CreateRandLibSampler(RNGFactory.GetRNG())); ReflectionUtility.SetHiddenField("_regime", solver, 3); inputArray1[0] = 6.29010763; var tauOut4C = calculateProposedTauMethod.Invoke(solver, inputArray1); Assert.AreEqual(0.13335417718069428, tauOut4C); }