@Override public synchronized List<Contingency> getContingencies() { LOGGER.info("Network {}: getting contingencies", network.getId()); return contingenciesActionsDbClient.getContingencies(network); }
public MontecarloSamplerImpl(Network network, ComputationManager computationManager, ForecastErrorsDataStorage forecastErrorsDataStorage, MontecarloSamplerConfig config) { Objects.requireNonNull(network, "network is null"); Objects.requireNonNull(computationManager, "computationManager is null"); Objects.requireNonNull(forecastErrorsDataStorage, "forecast errors data storage is null"); Objects.requireNonNull(config, "config is null"); LOGGER.info("Network {}: {}", network.getId(), config.toString()); this.network = network; this.computationManager = computationManager; this.forecastErrorsDataStorage = forecastErrorsDataStorage; this.config = config; currentSampleIndex = -1; }
@Override public List<CommandExecution> before(Path workingDir) throws IOException { // put mat files in working dir Path localForecastErrorsDataFile = Paths.get(workingDir.toString(), MCSINPUTFILEPREFIX + "forecast_errors_" + timeHorizon.getLabel() + ".mat"); forecastErrorsDataStorage.getForecastErrorsFile(feAnalysisId, timeHorizon, localForecastErrorsDataFile); Path localNetworkDataMatFile = Paths.get(workingDir.toString(), MCSINPUTFILEPREFIX + network.getId() + ".mat"); Files.copy(networkDataMatFile, localNetworkDataMatFile); LOGGER.info("Preparing FPF input data for {} network", network.getId()); Command cmd = createFPFCommand(localForecastErrorsDataFile, localNetworkDataMatFile); return Collections.singletonList(new CommandExecution(cmd, 1)); }
public SamplingNetworkData createSamplingNetworkData() { HashMap<String, Integer> busMapping = new HashMap<String, Integer>(); LOGGER.debug("Getting buses data from {} network", network.getId()); ArrayList<BusData> busesData = getBusData(busMapping); LOGGER.debug("Getting generators data from {} network", network.getId()); ArrayList<GeneratorData> generatorsData = getGeneratorData(busMapping); LOGGER.debug("Getting loads data from {} network", network.getId()); ArrayList<LoadData> loadsData = getLoadData(busMapping); samplingData = new SamplingNetworkData(busesData, generatorsData, loadsData); return samplingData; }
public static void exportState(Network network, Path folder, int faultNum, int actionNum) { Objects.requireNonNull(network); Objects.requireNonNull(folder); Properties parameters = new Properties(); parameters.setProperty("iidm.export.xml.indent", "true"); parameters.setProperty("iidm.export.xml.with-branch-state-variables", "true"); DataSource dataSource = new GzFileDataSource(folder, network.getId() + "_" + faultNum + "_" + actionNum); Exporters.export("XIIDM", network, parameters, dataSource); }
@Override public CompletableFuture<WCAAsyncResult> runAsync(String baseStateId, WCAParameters parameters) throws Exception { LOGGER.info(parameters.toString()); LOGGER.info("Network {}: starting WCA...", network.getId()); return createWcaTask(baseStateId, parameters) .thenApply(clusters -> () -> clusters); }
public ForecastErrorsHistoricalData createForecastErrorsHistoricalData(Path historicalDataCsvFile) throws IOException { LOGGER.debug("Getting stochastic variables from {} network", network.getId()); ArrayList<StochasticVariable> stochasticVariables = FEANetworkUtils.getStochasticVariables(network, generatorsIds, loadsIds); LOGGER.debug("Reading historical data from cvs file {}", historicalDataCsvFile.toString()); forecastErrorsHistoricalData = loadHistoricalDataFromCsvFile(historicalDataCsvFile, generatorsIds, loadsIds, stochasticVariables); //LOGGER.debug("Forecast errors historical data:\n" + forecastErrorsHistoricalData.toString()); return forecastErrorsHistoricalData; }
@Override public void process(Network network, ComputationManager cm) throws Exception { Objects.requireNonNull(network); LOGGER.info("Execute {} post processor on network {}", getName(), network.getId()); removeBreakers(network); }
private void createMat(Network network, Path outputFolder) throws IOException { System.out.println("creating mat file for network " + network.getId()); ArrayList<String> generatorsIds = NetworkUtils.getGeneratorsIds(network); ArrayList<String> loadsIds = NetworkUtils.getLoadsIds(network); SamplingNetworkData samplingNetworkData = new SamplingDataCreator(network, generatorsIds, loadsIds).createSamplingNetworkData(); Path networkDataMatFile = Files.createTempFile(outputFolder, "mcsamplerinput_" + network.getId() + "_", ".mat"); System.out.println("saving data of network " + network.getId() + " in file " + networkDataMatFile.toString()); new MCSMatFileWriter(networkDataMatFile).writeSamplingNetworkData(samplingNetworkData); }
@Override public SampledData after(Path workingDir, ExecutionReport report) throws IOException { report.log(); LOGGER.debug("Network {}: retrieving sampling results from file {}", network.getId(), MCSOUTPUTFILENAME); try { return new MCSMatFileReader(workingDir.resolve(MCSOUTPUTFILENAME)).getSampledData(); } catch (Exception e) { throw new RuntimeException(e); } } }).join();
@Override public void process(Network network, ComputationManager computationManager) throws Exception { Objects.requireNonNull(network); LOGGER.info("Execute {} post processor on network {}", getName(), network.getId()); new LoadFlowResultsCompletion(parameters, lfParameters).run(network, computationManager); }
@Override public WCADomainsResult after(Path workingDir, ExecutionReport report) throws IOException { report.log(); WCADomainsResult domainsResult = WCAUtils.readDomainsResult(DOMAINS_CMD_ID, workingDir, WCA_UNCERTAINTIES_FILE); LOGGER.info("Network {}, {}: 'domains' result = {}", network.getId(), contingency == null ? "pre-contingency" : "contingency " + contingency.getId(), domainsResult.toString()); return domainsResult; } });
public ImportedCaseBuilder withNetwork(Network network) { Objects.requireNonNull(network); if (name == null) { name = network.getId(); } DataSource memDataSource = new MemDataSource(); Exporters.export("XIIDM", network, null, memDataSource); return withDatasource(memDataSource); }
public NetworkMetadata(Network network) { Objects.requireNonNull(network); this.id = network.getId(); this.sourceFormat = network.getSourceFormat(); this.caseDate = network.getCaseDate(); this.forecastDistance = network.getForecastDistance(); }
public static NetworkData extract(Network network) { Objects.requireNonNull(network, "network is null"); LOGGER.info("Extracting data of network {}", network.getId()); NetworkData networkData = new NetworkData(network.getId()); extractBusesData(network, networkData); extractLinesData(network, networkData); extractTfo2WData(network, networkData); extractTfo3WData(network, networkData); extractGeneratorsData(network, networkData); extractLoadsData(network, networkData); return networkData; }
@Override public WCAClustersResult after(Path workingDir, ExecutionReport report) throws IOException { report.log(); WCAClustersResult clustersResult = WCAUtils.readClustersResult(CLUSTERS_CMD_ID, workingDir, WCA_FLOWS_FILE, WCA_UNCERTAINTIES_FILE); LOGGER.info("Network {}, contingency {}: 'clusters' result = {}", network.getId(), contingency.getId(), clustersResult.toString()); return clustersResult; } });
private RulesFacadeResults evaluate(Network network, List<SecurityRule> rules, List<SecurityIndexType> bacecaseInvalidRulesIndexes) { Objects.requireNonNull(network, "network is null"); HashMap<HistoDbAttributeId, Object> networkValues = IIDM2DB.extractCimValues(network, new IIDM2DB.Config(null, true)).getSingleValueMap(); return evaluate(network.getId(), network.getStateManager().getWorkingStateId(), networkValues, rules, bacecaseInvalidRulesIndexes); }
public void write(Writer writer, EsgGeneralParameters parameters, EsgSpecialParameters specialParameters) throws IOException { EsgNetwork esgNetwork = createNetwork(parameters); new EsgWriter(esgNetwork, parameters, specialParameters).write(writer, network.getId() + "/" + network.getStateManager().getWorkingStateId()); }
public void looseConstraints(String stateId, float margin, boolean applyToBaseCase) { if (network.getStateManager().getStateIds().contains(stateId)) { String workingStateId = network.getStateManager().getWorkingStateId(); network.getStateManager().setWorkingState(stateId); List<LimitViolation> violations = Security.checkLimits(network); looseConstraints(stateId, violations, margin, applyToBaseCase); network.getStateManager().setWorkingState(workingStateId); } else { throw new RuntimeException("No " + stateId + " in network " + network.getId() + ": cannot loose constraints"); } }
private static void assertRunningContext(RunningContext context) { assertNotNull(context); assertNotNull(context.getNetwork()); assertEquals("sim1", context.getNetwork().getId()); assertEquals("test", context.getNetwork().getSourceFormat()); }