Example #1
0
        public static List <List <ProcessOutput> > process(SimArguments args)
        {
            ParallelizationManager       trdMgr = new ParallelizationManager(args);
            List <List <ProcessOutput> > res    = new List <List <ProcessOutput> >();

            Parallel.For(0, args.argFiles.Count, trdMgr.parallelArgFiles, fileIdx =>
            {
                ArgFile af = args.argFiles[fileIdx];
                AppSettings.WriteLogLine("Processing Arg File:" + af.FileName);

                // load graph file
                AGameGraph graph = null;

                AppSettings.WriteLogLine("loading graph...");
                string graphVal = af.processParams[0][AppConstants.AppArgumentKeys.GRAPH_FILE.key];
                Utils.Exceptions.ConditionalTryCatch <Exception>(() =>
                {
                    if (graphVal.EndsWith(FileExtensions.GRAPH_FILE))
                    {
                        graph = AGameGraph.loadGraph(File.ReadAllLines(FileUtils.TryFindingFile(graphVal)));
                        //graph = new GridGameGraph(af.processParams[0][AppConstants.AppArgumentKeys.GRAPH_FILE.key]);
                    }
                    else
                    {
                        graph = AGameGraph.loadGraph(graphVal);
                    }
                },
                                                                 (Exception ex) =>
                {
                    AppSettings.WriteLogLine("couldn't load graph file:" + ex.Message);
                });

                AppSettings.WriteLogLine("graph loaded. processing...");
                // populate output table (ValuesCount is the amount of different values from param file, each should have separate theory/sim/optimizer process)
                res.Add(AlgorithmUtils.getRepeatingValueList <ProcessOutput>(af.processParams.ValuesCount));
                populateResults(res.Last(), af.processParams, trdMgr.parallelArgValues, trdMgr.parallelSimRuns, graph);
            });

            return(res);
        }
Example #2
0
 /// <summary>
 /// allows running a single ArgFile
 /// </summary>
 /// <param name="cmdLineArgs">
 /// parameters with keys from AppConstants.CmdLineArguments
 /// NOTE:
 /// CmdLineArguments.MAX_PARALLEL_ARGFILES is ignored (only 1 arg file will run in parallel)
 /// </param>
 /// <param name="processArgs"></param>
 public SimArguments(Dictionary <string, string> cmdLineArgs, ArgFile args)
 {
     maxParallelArgFiles = 1;
     argFiles.Add(args);
 }