com.powsybl.openrao.raoapi.json.JsonLoadFlowAndSensitivityComputationParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of open-rao-rao-api Show documentation
Show all versions of open-rao-rao-api Show documentation
Interface of a RA optimisation task
/*
* Copyright (c) 2023, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.openrao.raoapi.json;
import com.powsybl.openrao.commons.OpenRaoException;
import com.powsybl.openrao.raoapi.parameters.RaoParameters;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.powsybl.sensitivity.json.JsonSensitivityAnalysisParameters;
import java.io.IOException;
import static com.powsybl.openrao.raoapi.RaoParametersCommons.*;
/**
* @author Godelaine de Montmorillon {@literal }
*/
final class JsonLoadFlowAndSensitivityComputationParameters {
private JsonLoadFlowAndSensitivityComputationParameters() {
}
static void serialize(RaoParameters parameters, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeObjectFieldStart(LOAD_FLOW_AND_SENSITIVITY_COMPUTATION);
jsonGenerator.writeStringField(LOAD_FLOW_PROVIDER, parameters.getLoadFlowAndSensitivityParameters().getLoadFlowProvider());
jsonGenerator.writeStringField(SENSITIVITY_PROVIDER, parameters.getLoadFlowAndSensitivityParameters().getSensitivityProvider());
jsonGenerator.writeNumberField(SENSITIVITY_FAILURE_OVERCOST, parameters.getLoadFlowAndSensitivityParameters().getSensitivityFailureOvercost());
jsonGenerator.writeFieldName(SENSITIVITY_PARAMETERS);
serializerProvider.defaultSerializeValue(parameters.getLoadFlowAndSensitivityParameters().getSensitivityWithLoadFlowParameters(), jsonGenerator);
jsonGenerator.writeEndObject();
}
static void deserialize(JsonParser jsonParser, RaoParameters raoParameters) throws IOException {
while (!jsonParser.nextToken().isStructEnd()) {
switch (jsonParser.getCurrentName()) {
case LOAD_FLOW_PROVIDER:
jsonParser.nextToken();
raoParameters.getLoadFlowAndSensitivityParameters().setLoadFlowProvider(jsonParser.getValueAsString());
break;
case SENSITIVITY_PROVIDER:
jsonParser.nextToken();
raoParameters.getLoadFlowAndSensitivityParameters().setSensitivityProvider(jsonParser.getValueAsString());
break;
case SENSITIVITY_FAILURE_OVERCOST:
jsonParser.nextToken();
raoParameters.getLoadFlowAndSensitivityParameters().setSensitivityFailureOvercost(jsonParser.getValueAsDouble());
break;
case SENSITIVITY_PARAMETERS:
jsonParser.nextToken();
raoParameters.getLoadFlowAndSensitivityParameters().setSensitivityWithLoadFlowParameters(JsonSensitivityAnalysisParameters.createObjectMapper().readerForUpdating(raoParameters.getLoadFlowAndSensitivityParameters().getSensitivityWithLoadFlowParameters()).readValue(jsonParser));
break;
default:
throw new OpenRaoException(String.format("Cannot deserialize load flow and sensitivity parameters: unexpected field in %s (%s)", LOAD_FLOW_AND_SENSITIVITY_COMPUTATION, jsonParser.getCurrentName()));
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy