static void Main(string[] args) { var inputPath = "input"; var modelsPath = @"..\..\..\data\models"; // "LA145" -> xx var modelToSize = GetModelToSize(modelsPath); // "LA145" -> .. var summary = new Dictionary <string, List <(string strategyName, long energy, string tracePath)> >(); foreach (var directory in Directory.EnumerateDirectories(inputPath)) { Console.WriteLine($"## Start processing {directory}"); var startegyName = Path.GetDirectoryName(directory); foreach (var tracePath in Directory.EnumerateFiles(directory)) { var ai = new FileAI(tracePath); var mongoOplogWriter = new FakeOpLog(); mongoOplogWriter.WriteLogName(startegyName); var simulator = new Simulator(); var modelName = Path.GetFileName(tracePath).Substring(0, 5); Console.Write($"# evaluating {modelName}... "); var size = modelToSize[modelName]; var state = State.CreateInitial(size, mongoOplogWriter); mongoOplogWriter.WriteInitialState(state); while (true) { var commands = ai.NextStep(state).ToList(); simulator.NextStep(state, new Trace(commands)); if (commands[0] is HaltCommand) { break; } } UpdateSummary(summary, state, startegyName, tracePath, modelName); mongoOplogWriter.Save(); } } var defaultTracksPath = @"..\..\..\data\track"; PrepareBestSubmission(summary, defaultTracksPath, modelsPath, "output"); }
private long GetActualEnergy(string tracePath, string anyModelPath) { var fileAi = new FileAI(tracePath); var matrix = MatrixDeserializer.Deserialize(File.ReadAllBytes(anyModelPath)); var state = State.CreateInitial(matrix.R); while (true) { var commands = fileAi.NextStep(state).ToList(); simulator.NextStep(state, new Trace(commands)); if (commands.Count == 1 && commands[0] is HaltCommand) { break; } } return(state.Energy); }