예제 #1
0
파일: Program.cs 프로젝트: jeanbern/portent
        private static void ArrangeGraphsCacheAware()
        {
            Console.WriteLine("Starting Topological");
            var graph = BuildGraph(DictionaryPath);

            Console.WriteLine($"Default Topological ordering cost: {graph.CacheArrangementCost():E}");
            graph.Save(NormalPath);

            /*
             * Console.WriteLine("Starting CacheAwareTopological Annealing");
             * var (_, topologicalCacheArrangement) = Annealer.Anneal<CacheAwareInstance, int[]>(
             *  new CacheAwareInstance(graph),
             *  7654323,
             *  0.0001d,
             *  .9999999d,
             *  .000000001d);
             * Console.WriteLine("Arranging");
             * var topologicalCacheGraph = graph.Arrange(topologicalCacheArrangement);
             * Console.WriteLine($"CacheAwareTopological ordering cost: {topologicalCacheGraph.CacheArrangementCost():E}");
             * topologicalCacheGraph.Save(CacheAwareTopologicalPath);
             * //*/var topologicalCacheGraph = graph;

            Console.WriteLine("Starting CacheAware Annealing");
            var(_, cacheArrangement) = Annealer.Anneal <CacheAwareInstance, int[]>(
                new CacheAwareInstance(topologicalCacheGraph),
                7654324,
                0.005d,
                .999999995d,
                .000000001d);
            Console.WriteLine("Arranging");
            var cacheGraph = topologicalCacheGraph.Arrange(cacheArrangement);

            Console.WriteLine($"CacheAware ordering cost: {cacheGraph.CacheArrangementCost():E}");
            cacheGraph.Save(CacheAwarePath);
        }
예제 #2
0
파일: Program.cs 프로젝트: jeanbern/portent
        private static void ArrangeGraphs()
        {
            Console.WriteLine("Starting Topological");
            var graph = BuildGraph(DictionaryPath);

            Console.WriteLine($"Default Topological ordering cost: {graph.ArrangementCost():E}");
            graph.Save(NormalPath);

            Console.WriteLine("Starting Annealed Topological");
            var(_, topologicalArrangement) = Annealer.Anneal <TopologicalOrderingInstance, int[]>(
                new TopologicalOrderingInstance(graph),
                7654321,
                50.0d,
                .9999995d,
                .0000001d);
            Console.WriteLine("Arranging");
            var newTopologicalGraph = graph.Arrange(topologicalArrangement);

            Console.WriteLine($"Annealed Topological ordering cost: {newTopologicalGraph.ArrangementCost():E}");
            newTopologicalGraph.Save(TopologicallyAnnealedPath);

            Console.WriteLine("Starting Spectral");
            var spectralArrangement = ChacoSequencer.SpectralSequence(newTopologicalGraph);

            Console.WriteLine("Arranging");
            var spectralGraph = newTopologicalGraph.Arrange(spectralArrangement);

            Console.WriteLine($"Spectral ordering cost: {spectralGraph.ArrangementCost():E}");
            spectralGraph.Save(SpectralPath);

            Console.WriteLine("Starting Annealing");
            var(_, annealingArrangement) = Annealer.Anneal <OrderingInstance, int[]>(
                new OrderingInstance(spectralGraph),
                7654322,
                500000.0d,
                .999999d,
                .00001d);
            Console.WriteLine("Arranging");
            var annealedGraph = spectralGraph.Arrange(annealingArrangement);

            Console.WriteLine($"Annealed ordering cost: {annealedGraph.ArrangementCost():E}");
            annealedGraph.Save(AnnealedPath);
            Console.WriteLine("Starting Annealing");
        }