Example #1
0
        public bool doesSlimRnnSolveTask(SlimRnn slimRnn, bool mustHalt, double tLim)
        {
            // NOTE< we ignore must halt because we hardcoded to check for termination >

            instrumentationNewSolveTrial();

            // simulate slimRnn in environment and correctness demonstration

            //    we don't have to show that the old solver doesn't solve the task because we did the step already in searchForCandidateProgram()
            //    we just have to show that the new solver can solve the new task and all old tasks

            IList <SlimRnnNeuronWithWeight> traceResult;
            double requiredTime;
            bool   wasTerminated;

            { // test new task
                slimRnn.world = new TaskSlimRnnWorld(currentTask);

                currentTask.resetState();

                slimRnn.t_lim = tLim;
                slimRnn.spread(out traceResult, out requiredTime, out wasTerminated);

                bool thisTaskSolvedAndTerminated = wasTerminated && currentTask.wasTaskSolved;
                if (!thisTaskSolvedAndTerminated)
                {
                    return(false);
                }
            }

            // test all old tasks
            foreach (ITask iOldTask in allExistingTasks)
            {
                slimRnn.world = new TaskSlimRnnWorld(iOldTask);

                iOldTask.resetState();

                slimRnn.t_lim = tLim;
                slimRnn.spread(out traceResult, out requiredTime, out wasTerminated);

                bool thisTaskSolvedAndTerminated = wasTerminated && iOldTask.wasTaskSolved;
                if (!thisTaskSolvedAndTerminated)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
            public bool doesSlimRnnSolveTask(SlimRnn slimRnn, bool mustHalt, double tLim)
            {
                IList <SlimRnnNeuronWithWeight> trace;

                slimRnn.t_lim = tLim;
                double time;
                bool   wasTerminated;

                slimRnn.spread(out trace, out time, out wasTerminated);

                return(true);
            }
Example #3
0
        // tests if the network successfully calculates a complex formula
        public static void testCalculation()
        {
            SlimRnn rnn = new SlimRnn();

            rnn.neurons.Add(SlimRnnNeuron.makeInputNeuron());                          // [0] input
            rnn.neurons.Add(SlimRnnNeuron.makeInputNeuron());                          // [1] input
            rnn.neurons.Add(SlimRnnNeuron.makeInputNeuron());                          // [2] input
            rnn.neurons.Add(new SlimRnnNeuron(SlimRnnNeuron.EnumType.ADDITIVE));       // [3]
            rnn.neurons.Add(new SlimRnnNeuron(SlimRnnNeuron.EnumType.MULTIPLICATIVE)); // [4] output
            rnn.neurons.Add(new SlimRnnNeuron(SlimRnnNeuron.EnumType.ADDITIVE));       // [5] termination

            rnn.outputNeuronsStartIndex = 4;
            rnn.numberOfOutputNeurons   = 1;

            rnn.terminatingNeuronIndex     = 5;
            rnn.terminatingNeuronThreshold = 0.5f;

            rnn.numberOfInputNeurons = 3;

            rnn.t_lim = 5; // are actually less steps but fine for testing

            rnn.world = new TestWorld();

            rnn.neurons[0].outNeuronsWithWeights.Add(new SlimRnnNeuronWithWeight(rnn.neurons[0], rnn.neurons[3], 0.5f, 0));
            rnn.neurons[1].outNeuronsWithWeights.Add(new SlimRnnNeuronWithWeight(rnn.neurons[1], rnn.neurons[3], 0.81f, 0));
            rnn.neurons[2].outNeuronsWithWeights.Add(new SlimRnnNeuronWithWeight(rnn.neurons[2], rnn.neurons[4], 1.5f, 0));
            rnn.neurons[3].outNeuronsWithWeights.Add(new SlimRnnNeuronWithWeight(rnn.neurons[3], rnn.neurons[4], 0.5f, 0));
            rnn.neurons[4].outNeuronsWithWeights.Add(new SlimRnnNeuronWithWeight(rnn.neurons[4], rnn.neurons[5], 5000.0f, 0)); // terminate if output is set

            rnn.initializeNeurons();

            IList <SlimRnnNeuronWithWeight> trace;
            double time;
            bool   wasTerminated;

            rnn.spread(out trace, out time, out wasTerminated);
            Debug.Assert(wasTerminated); // must terminate
        }