///<summary> /// Constructs a Solver. ///</summary> ///<param name="timeStepSettings">Time step settings used by the solver.</param> ///<param name="deactivationManager">Deactivation manager used by the solver.</param> public Solver(TimeStepSettings timeStepSettings, DeactivationManager deactivationManager) { TimeStepSettings = timeStepSettings; DeactivationManager = deactivationManager; multithreadedPrestepDelegate = MultithreadedPrestep; multithreadedIterationDelegate = MultithreadedIteration; Enabled = true; PermutationMapper = new PermutationMapper(); }
/// <summary> /// Constructs a new demo. /// </summary> /// <param name="game">Game owning this demo.</param> public PermutationTestDemo(DemosGame game) : base(game) { var permutations = new HashSet <Permutation>(); var mapper = new PermutationMapper(); var representedIndices = new HashSet <int>(); mapper.PermutationIndex = 0; const int setSize = 250; const int iterationCount = 150000; var conflicts = 0; for (int i = 0; i < iterationCount; ++i) { var permutedIndices = new int[setSize]; for (int setIndex = 0; setIndex < setSize; ++setIndex) { permutedIndices[setIndex] = mapper.GetMappedIndex(setIndex, setSize); } for (int index = 0; index < permutedIndices.Length; ++index) { if (!representedIndices.Add(permutedIndices[index])) { throw new Exception("Not a permutation!"); } } representedIndices.Clear(); var permutation = new Permutation(permutedIndices); if (!permutations.Add(permutation)) { ++conflicts; } ++mapper.PermutationIndex; if (i % (iterationCount / 100) == 0) { Console.WriteLine("{0}% complete", ((double)i * 100) / iterationCount); } } Console.WriteLine("Set size: {0}", setSize); Console.WriteLine("Iteration count: {0}", iterationCount); Console.WriteLine("Permutation count: {0}", permutations.Count); Console.WriteLine("Conflict count: {0}", conflicts); }