public List <HeatMapRegion> LoadHeatMapRegionsToTestWorkspace(string testWorkspaceName) { List <HeatMapRegion> heatMapRegions = new List <HeatMapRegion>(); string workspaceResultsPath = GetWorkspaceRandomExplorationResultsPath(testWorkspaceName); string heatMapRegionsFilePath = workspaceResultsPath + RandomExplorationRun.heatMapRegionsFileName; if (!File.Exists(heatMapRegionsFilePath)) { return(null); } string[] heatMapRegionsFileLines = System.IO.File.ReadAllLines(heatMapRegionsFilePath); MatchCollection wordMatches = Regex.Matches(heatMapRegionsFileLines[0], @"[^,]+"); if (wordMatches.Count != (6 + 3 * 5)) { return(null); } string[] objectiveFunctionsName = new string[5]; for (int i = 0; i < 5; ++i) { objectiveFunctionsName[i] = wordMatches[6 + i * 3].Value; } HeatMap heatMap = new HeatMap(); for (int l = 1; l < heatMapRegionsFileLines.Count(); ++l) { MatchCollection valueMatches = Regex.Matches(heatMapRegionsFileLines[l], @"[^,]+"); if (valueMatches.Count != (6 + 3 * 5)) { return(null); } for (int i = 0; i < 5; ++i) { HeatMapRegion heatMapRegion = new HeatMapRegion(); heatMapRegion.indexX = Int16.Parse(valueMatches[0].Value); heatMapRegion.indexY = Int16.Parse(valueMatches[1].Value); heatMapRegion.xStart = float.Parse(valueMatches[2].Value); heatMapRegion.xEnd = float.Parse(valueMatches[3].Value); heatMapRegion.yStart = float.Parse(valueMatches[4].Value); heatMapRegion.yEnd = float.Parse(valueMatches[5].Value); heatMapRegion.requirementName = objectiveFunctionsName[i]; HeatMapPoint heatMapPoint = new HeatMapPoint(); heatMapPoint.objectiveFunctionValues[heatMapRegion.requirementName] = float.Parse(valueMatches[6 + i * 3].Value); heatMapPoint.x = float.Parse(valueMatches[7 + i * 3].Value); heatMapPoint.y = float.Parse(valueMatches[8 + i * 3].Value); heatMapRegion.worstCasePointFromRandomExploration = heatMapPoint; heatMapRegion.objectiveFunctionAverageValue = heatMapPoint.objectiveFunctionValues[heatMapRegion.requirementName]; heatMapRegions.Add(heatMapRegion); } } return(heatMapRegions); }
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); }