WCAUtils { public static WCAClustersResult readClustersResult(String clustersPrefix, Path workingDir, String flowsFile, String uncertaintiesFile) throws IOException { Objects.requireNonNull(clustersPrefix); Objects.requireNonNull(workingDir); Objects.requireNonNull(uncertaintiesFile); WCAClusterNum clusterNum = WCAClusterNum.UNDEFINED; int curativeActionIndex = 0; Matcher matcher = parseOutFile(clustersPrefix, CLUSTER_INDEX_PATTERN, workingDir); if (matcher != null) { clusterNum = WCAClusterNum.fromInt(Integer.parseInt(matcher.group(2))); curativeActionIndex = Integer.parseInt(matcher.group(3)); } return new WCAClustersResult(clusterNum, flowsWithViolations(flowsFile, workingDir), curativeActionIndex, parseUncertaintiesFile(uncertaintiesFile, workingDir)); } private  WCAUtils(); static void exportState(Network network, Path folder, int faultNum, int actionNum); static WCADomainsResult readDomainsResult(String domainsPrefix, Path workingDir, String uncertaintiesFile); static WCAClustersResult readClustersResult(String clustersPrefix, Path workingDir, String flowsFile, String uncertaintiesFile); static void writeContingencies(Collection<Contingency> contingencies, DataSource dataSource, StringToIntMapper<AmplSubset> mapper); static void writeActions(Collection<String> actionIds, DataSource dataSource, StringToIntMapper<AmplSubset> mapper,
                                     String title, AmplSubset amplSubset); static void applyInjections(Network network, String stateId, Map<String, Float> injections); static boolean containsViolation(List<LimitViolation> violations, LimitViolation violation);  }
@Test public void testReadClustersResults() throws URISyntaxException, IOException { Path workingDir = Paths.get(getClass().getResource("/clusters").toURI()); WCAClustersResult clustersResult = WCAUtils.readClustersResult("wca_clusters_1", workingDir, "wca_flow_1.txt", "wca_uncertainties.txt"); assertEquals(WCAClusterNum.TWO, clustersResult.getClusterNum()); assertFalse(clustersResult.foundViolations()); assertEquals(1, clustersResult.getCurativeActionIndex()); testInjection(clustersResult.getInjections(), "LOAD_1", -1.1f); testInjection(clustersResult.getInjections(), "LOAD_2", 1.5f); testInjection(clustersResult.getInjections(), "GEN_1", 1.2f); clustersResult = WCAUtils.readClustersResult("wca_clusters_2", workingDir, "wca_flow_2.txt", "wca_uncertainties.txt"); assertEquals(WCAClusterNum.ONE, clustersResult.getClusterNum()); assertTrue(clustersResult.foundViolations()); assertEquals(0, clustersResult.getCurativeActionIndex()); testInjection(clustersResult.getInjections(), "LOAD_1", -1.1f); testInjection(clustersResult.getInjections(), "LOAD_2", 1.5f); testInjection(clustersResult.getInjections(), "GEN_1", 1.2f); }