示例#1
0
        public HeatMap LoadHeatMapDiagramToTestWorkspace(string testWorkspaceName)
        {
            string workspaceResultsPath    = GetWorkspaceRandomExplorationResultsPath(testWorkspaceName);
            string heatMapDiagramsFilePath = workspaceResultsPath + RandomExplorationRun.heatMapDiagramsFileName;

            if (!File.Exists(heatMapDiagramsFilePath))
            {
                return(null);
            }
            string[]        heatMapDiagramsFileLines = System.IO.File.ReadAllLines(heatMapDiagramsFilePath);
            MatchCollection wordMatches = Regex.Matches(heatMapDiagramsFileLines[0], @"[^,]+");

            if (wordMatches.Count != (4 + 5))
            {
                return(null);
            }
            string[] objectiveFunctionsName = new string[5];
            for (int i = 0; i < 5; ++i)
            {
                objectiveFunctionsName[i] = wordMatches[i + 4].Value;
            }
            HeatMap heatMap = new HeatMap();

            for (int l = 1; l < heatMapDiagramsFileLines.Count(); ++l)
            {
                MatchCollection valueMatches = Regex.Matches(heatMapDiagramsFileLines[l], @"[^,]+");
                if (valueMatches.Count != (4 + 5))
                {
                    return(null);
                }
                HeatMapPoint heatMapPoint = new HeatMapPoint();
                heatMapPoint.indexX = Int16.Parse(valueMatches[0].Value);
                heatMapPoint.indexY = Int16.Parse(valueMatches[1].Value);
                heatMapPoint.x      = float.Parse(valueMatches[2].Value);
                heatMapPoint.y      = float.Parse(valueMatches[3].Value);
                for (int i = 4; i < valueMatches.Count; ++i)
                {
                    heatMapPoint.objectiveFunctionValues.Add(objectiveFunctionsName[i - 4],
                                                             float.Parse(valueMatches[i].Value));
                }
                heatMap.AddPoint(heatMapPoint);
            }
            heatMap.FinalizeAddingPoints();
            return(heatMap);
        }