Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }