Exemple #1
0
        // This region contains tests that have not been verified by hand to be correct
        #region Uncertain tests
        private static RecipeExecutorState GetBaseStateForTwoInnermostLayersOfCobweb(int n)
        {
            var instructions = new IPotentialRecipeInstruction[]
            {
                new PeriodicAtomicGlueInstruction(new AtomicGlueInstruction(0, 1, 4), n),
                new PeriodicAtomicGlueInstruction(new AtomicGlueInstruction(2, 2, 3), n),
            };
            var recipe   = new PotentialRecipe(instructions);
            var executor = new RecipeExecutor();
            var qp       = executor.ExecuteRecipe(recipe, initialCycleNumArrows: n);

            var boundary = Enumerable.Range(0, 2 * n).Select(k =>
            {
                int source = 3 * n - 2 * (k / 2) - 2;
                int target = (k == 2 * n - 1) ? 3 * n - 1 : // Handle the last k specially
                             (k % 2 == 0) ? source + 1 : source - 1;
                var arrow = new Arrow <int>(source, target);
                return(arrow, k % 2 == 0 ? BoundaryArrowOrientation.Left : BoundaryArrowOrientation.Right);
            }).ToCircularList();

            return(new RecipeExecutorState()
            {
                Potential = qp.Potential,
                NextVertex = qp.Quiver.Vertices.Count,
                Boundary = boundary,
                PotentiallyProblematicArrows = new HashSet <Arrow <int> >(),
            });
        }
        public void Execute_ResultsInSelfInjectiveQP_WhenShouldBeCobMinus5()
        {
            var gen          = new RecipeExecutor();
            var instructions = new IPotentialRecipeInstruction[]
            {
                new AtomicGlueInstruction(0, 1, 4),
                new AtomicGlueInstruction(3, 1, 4),
                new AtomicGlueInstruction(6, 1, 4),
                new AtomicGlueInstruction(9, 1, 4),
                new AtomicGlueInstruction(12, 1, 4),
                new AtomicGlueInstruction(2, 2, 3),
                new AtomicGlueInstruction(4, 2, 3),
                new AtomicGlueInstruction(6, 2, 3),
                new AtomicGlueInstruction(8, 2, 3),
                new AtomicGlueInstruction(10, 2, 3),
            };

            var recipe   = new PotentialRecipe(instructions);
            var qp       = gen.ExecuteRecipe(recipe, 5);
            var analyzer = new QPAnalyzer();
            var settings = GetSettings(detectNonCancellativity: true);
            var result   = analyzer.Analyze(qp, settings);

            Assert.That(result.MainResults.IndicatesSelfInjectivity());
        }
Exemple #3
0
        public void AddingArrowBetweenNeighboringBoundaryVertices_Throws()
        {
            var instructions = new IPotentialRecipeInstruction[]
            {
                new AtomicGlueInstruction(0, 1, 3), // Boundary is now <- <- -> ... ->
                new AtomicGlueInstruction(0, 2, 3), // Try to consume only the <- arrows
            };
            var recipe   = new PotentialRecipe(instructions);
            var executor = new RecipeExecutor();

            Assert.That(() => executor.ExecuteRecipe(recipe, 10), Throws.InstanceOf <PotentialRecipeExecutionException>());
        }
        public void Execute_Throws_WhenBoundaryArrowsHaveDifferentOrientation()
        {
            var gen          = new RecipeExecutor();
            var instructions = new IPotentialRecipeInstruction[]
            {
                new AtomicGlueInstruction(0, 1, 4),
                new CompositeGlueInstruction(new AtomicGlueInstruction[] { new AtomicGlueInstruction(0, 4, 10) })
            };

            var recipe = new PotentialRecipe(instructions);

            Assert.That(() => gen.ExecuteRecipe(recipe, 5), Throws.InstanceOf <PotentialRecipeExecutionException>());
        }
        public static QuiverWithPotential <int> GetCobMinus7QP()
        {
            var instructions = new IPotentialRecipeInstruction[]
            {
                new PeriodicAtomicGlueInstruction(new AtomicGlueInstruction(0, 1, 4), 7),
                new PeriodicAtomicGlueInstruction(new AtomicGlueInstruction(2, 2, 3), 7),
                new PeriodicAtomicGlueInstruction(new AtomicGlueInstruction(0, 1, 4), 7),
                new PeriodicAtomicGlueInstruction(new AtomicGlueInstruction(2, 3, 4), 7),
            };
            var recipe   = new PotentialRecipe(instructions);
            var executor = new RecipeExecutor();

            return(executor.ExecuteRecipe(recipe, 7));
        }
        public void TryExecute_ReturnsFalse_WhenBoundaryArrowsHaveDifferentOrientation()
        {
            var gen          = new RecipeExecutor();
            var instructions = new IPotentialRecipeInstruction[]
            {
                new AtomicGlueInstruction(0, 1, 4),
                new CompositeGlueInstruction(new AtomicGlueInstruction[] { new AtomicGlueInstruction(0, 4, 10) })
            };

            var  recipe = new PotentialRecipe(instructions);
            bool result = gen.TryExecuteRecipe(recipe, 5, out QuiverWithPotential <int> qp);

            Assert.That(result, Is.EqualTo(false));
            Assert.That(qp, Is.EqualTo(null));
        }
        public void ComputeMaximalNonzeroEquivalenceClassRepresentativesStartingAt_Cobweb5()
        {
            const int NumInitialCycles = 5;
            var       instructions     = new IPotentialRecipeInstruction[]
            {
                new PeriodicAtomicGlueInstruction(new AtomicGlueInstruction(0, 1, 4), 5),
                new PeriodicAtomicGlueInstruction(new AtomicGlueInstruction(2, 2, 3), 5),
            };

            var executor = new RecipeExecutor();
            var qp       = executor.ExecuteRecipe(new PotentialRecipe(instructions), NumInitialCycles);

            DoSetup(qp, out var analyzer, out var ruleTree, out var settings);
            var representativePaths = analyzer.ComputeMaximalNonzeroEquivalenceClassRepresentativesStartingAt(qp, 0, ruleTree, settings).MaximalNonzeroEquivalenceClassRepresentatives.ToList();

            Assert.That(representativePaths, Has.Count.EqualTo(1));
            Assert.That(representativePaths.Single().EndingPoint, Is.EqualTo(2));

            //var analyzer2 = new Analyzer<int>(qp);
            //var maximalClasses2 = analyzer2.ComputeMaximalNonzeroEquivalenceClassRepresentativesStartingAt(0);
        }