Exemple #1
0
 /// <summary>
 /// convert constraint policy to string
 /// </summary>
 private string constraintPolicyToString(ConstraintPolicy policy)
 {
     if (policy == ConstraintPolicy.Single)
     {
         return("Single");
     }
     else if (policy == ConstraintPolicy.Range)
     {
         return("Range");
     }
     else if (policy == ConstraintPolicy.DoubleRange)
     {
         return("Double Range");
     }
     else
     {
         return("NO_POLICY");
     }
 }
Exemple #2
0
        /// <summary>
        /// write execution info to file
        /// </summary>
        public void writeToFile
        (
            string solver,
            string planTime,
            string planCost,
            string instanceId,
            string instanceName,
            string agentsCount,
            string mapFileName,
            uint obstaclesPercents,
            ConstraintPolicy constraintPolicy
        )
        {
            string          pathDesktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string          filePath    = pathDesktop + "\\RobustCSV.csv";
            int             length;
            string          delimter = ",";
            List <string[]> output   = new List <string[]>();

            string[] temps = new string[10];


            if (!File.Exists(filePath))
            {
                File.Create(filePath).Close();

                temps[0] = "IncstanceId";
                temps[1] = "#Agents";
                temps[2] = "Solver";
                temps[3] = "Map";
                temps[4] = "Obstacles";
                temps[5] = "Plan Cost";
                temps[6] = "Success";
                temps[7] = "Plan time";
                temps[8] = "Constraint policy";
                temps[9] = "File";
                output.Add(temps);

                length = output.Count;
                using (System.IO.TextWriter writer = File.AppendText(filePath))
                {
                    for (int index = 0; index < length; index++)
                    {
                        writer.WriteLine(string.Join(delimter, output[index]));
                    }
                }
            }
            string new_file_name = instanceName;

            string[] splitFilePath = new_file_name.Split('\\');
            new_file_name = splitFilePath[splitFilePath.Count() - 1];
            string map      = (new_file_name.Split('.'))[0];
            string instance = (new_file_name.Split('-'))[1];

            //temps[0] = instanceId;
            temps[0] = instance;
            temps[1] = agentsCount;
            temps[2] = solver;
            //temps[3] = Path.GetFileNameWithoutExtension(mapFileName);
            temps[3] = map;
            temps[4] = obstaclesPercents.ToString();;
            temps[5] = planCost;
            if (temps[5].Equals("-1") || temps[5].Equals("-2") || temps[5].Equals("-3"))
            {
                temps[6] = "0";
            }
            else
            {
                temps[6] = "1";
            }
            temps[7] = planTime;
            temps[8] = constraintPolicyToString(constraintPolicy);

            temps[9] = new_file_name;

            output.Add(temps);

            length = output.Count;
            using (System.IO.TextWriter writer = File.AppendText(filePath))
            {
                for (int index = 0; index < length; index++)
                {
                    writer.WriteLine(string.Join(delimter, output[index]));
                }
            }
        }