public void TestSolveOnce() { const string configString = @"{""solver"":""DWSSA"",""prng_seed"":123, ""prng_index"":1,""RNG"":{""type"":""PSEUDODES""},""dwSSA"":{""reExpressionName"":""reExpression"", ""reValName"":""reVal"", ""gamma"":[1, 1]}}"; Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(configString); RunResetRNGFactory(); var modelInfo = EmodlLoader.LoadEMODLFile("resources\\rever_isom.emodl"); const double duration = 10.0; const int repeats = 1000000; const int samples = 1; var solver = new dwSSA(modelInfo, duration, repeats, samples); solver.Initialize(); var method = solver.GetType().GetMethod("SolveOnce", BindingFlags.NonPublic | BindingFlags.Instance, Type.DefaultBinder, new Type[] { }, null); method.Invoke(solver, null); var trajectoryCounter = GetHiddenField <int>("_trajectoryCounter", solver); var runningMean = GetHiddenField <double>("_runningMean", solver); var currentTime = GetHiddenField <double>("_currentTime", solver); Assert.AreEqual(1, trajectoryCounter); Assert.AreEqual(0.0, runningMean); Assert.GreaterOrEqual(currentTime, duration); }
public void TestSelectAndFireReaction() { const string configString = @"{""solver"":""DWSSA"", ""prng_seed"":123, ""prng_index"":1, ""RNG"":{""type"":""PSEUDODES""}, ""dwSSA"":{""crossEntropyThreshold"":0.005, ""crossEntropyRuns"":100000, ""reExpressionName"":""reExpression"", ""reValName"":""reVal"", ""gamma"":[2.0, 0.5]}}"; Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(configString); RunResetRNGFactory(); var modelInfo = EmodlLoader.LoadEMODLFile("resources\\rever_isom.emodl"); const double duration = 10.0; const int repeats = 1; const int samples = 1; var solver = new dwSSA(modelInfo, duration, repeats, samples); solver.Initialize(); var startRealization = GetHiddenMethod("StartRealization", solver); startRealization.Invoke(solver, null); var method = solver.GetType().GetMethod("SelectAndFireReaction", BindingFlags.NonPublic | BindingFlags.Instance, Type.DefaultBinder, new[] { typeof(double) }, null); var inputArray1 = new object[] { 1.5 }; method.Invoke(solver, inputArray1); var reactions = GetHiddenField <ReactionSet>("_reactions", solver); Assert.AreEqual(reactions.Reactions[0].Reactants[0].Value, 99); }
public void TestSetRareEventType() { const string configString = @"{""solver"":""DWSSA"",""dwSSA"":{""gamma"": [1, 1]}}"; Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(configString); var modelInfo = EmodlLoader.LoadEMODLFile("resources\\rever_isom.emodl"); const double duration = 10.0; const int repeats = 100000; const int samples = 1; var solver = new dwSSA(modelInfo, duration, repeats, samples); solver.Initialize(); var method = FindMethod("SetRareEventType", typeof(dwSSA)); method.Invoke(solver, null); var reExpression = GetHiddenField <Expression>("_reExpression", solver); var reEventValue = GetHiddenField <double>("_rareEventValue", solver); Assert.AreEqual(0, reExpression.Value); Assert.AreEqual(30.0, reEventValue); Assert.AreEqual(1, GetHiddenField <int>("_rareEventType", solver)); }
private static dwSSA SetupCrossEntropy() { const string configString = @"{""solver"":""DWSSA"", ""prng_seed"":123, ""prng_index"":1, ""RNG"":{""type"":""PSEUDODES""}, ""dwSSA"":{""gamma"":[1, 1]}}"; Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(configString); RunResetRNGFactory(); var modelInfo = EmodlLoader.LoadEMODLFile("resources\\rever_isom.emodl"); const double duration = 10.0; const int repeats = 1; const int samples = 1; var solver = new dwSSA(modelInfo, duration, repeats, samples); solver.Initialize(); var startRealization = GetHiddenMethod("StartRealization", solver); startRealization.Invoke(solver, null); return(solver); }
public void TestInitialize() { const string configString = @"{""solver"":""DWSSA"", ""dwSSA"":{""gamma"":[1.0, 1.0]}}"; Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(configString); ModelInfo modelInfo = EmodlLoader.LoadEMODLFile("resources\\rever_isom.emodl"); const double duration = 10.0; const int repeats = 1000000; const int samples = 1; var solver = new dwSSA(modelInfo, duration, repeats, samples); solver.Initialize(); var rareEventValue = GetHiddenField <double>("_rareEventValue", solver); var reExpression = GetHiddenField <Expression>("_reExpression", solver); Assert.AreEqual(30.0, rareEventValue); Assert.AreEqual(0.0, reExpression.Value); }
private static dwSSA StartStepOnce() { const string configString = @"{""solver"":""DWSSA"",""prng_seed"":123, ""prng_index"":1,""RNG"":{""type"":""PSEUDODES""},""dwSSA"":{""crossEntropyThreshold"":0.005, ""crossEntropyRuns"":100000, ""reExpressionName"":""reExpression"", ""reValName"":""reVal"", ""gamma"":[2.0, 0.5]}}"; Configuration.CurrentConfiguration = Configuration.ConfigurationFromString(configString); RunResetRNGFactory(); var modelInfo = EmodlLoader.LoadEMODLFile("resources\\rever_isom.emodl"); const float duration = 10.0f; const int repeats = 1; const int samples = 1; var solver = new dwSSA(modelInfo, duration, repeats, samples); solver.Initialize(); var startRealization = GetHiddenMethod("StartRealization", solver); startRealization.Invoke(solver, null); return(solver); }