Class AmplModelExecutionHandler
- All Implemented Interfaces:
ExecutionHandler<AmplResults>
It copies every file given by AmplModel.getAmplRunFiles()
in
the working directory. It exports the Network with
AmplExporter.export(com.powsybl.iidm.network.Network, java.util.Properties, com.powsybl.commons.datasource.DataSource)
.
Then it runs the ampl model, and AmplReadableElement.readElement(com.powsybl.ampl.converter.AmplNetworkReader)
is used to
apply modifications on the network.
The majority of the configuration is made by the AmplModel
interface.
- Author:
- Nicolas Pierre <[email protected]>
-
Constructor Summary
ConstructorDescriptionAmplModelExecutionHandler
(AmplModel model, Network network, String networkVariant, AmplConfig config, AmplParameters parameters) -
Method Summary
Modifier and TypeMethodDescriptionafter
(Path workingDir, ExecutionReport report) Method called by theComputationManager
with the working directory and an execution report as parameters, after the commands defined by theExecutionHandler.before(java.nio.file.Path)
method have been executed: it is in charge of any postprocessing and of providing the actual computation result.Method called by theComputationManager
with the working directory as parameter, before the commands are actually executed: it is in charge of any preprocessing of providing the list of commands to be executed.protected static CommandExecution
createAmplRunCommand
(AmplConfig config, AmplModel model) protected static String
getAmplBinPath
(AmplConfig cfg) Methods inherited from class com.powsybl.computation.AbstractExecutionHandler
onExecutionCompletion, onExecutionStart
-
Constructor Details
-
AmplModelExecutionHandler
public AmplModelExecutionHandler(AmplModel model, Network network, String networkVariant, AmplConfig config, AmplParameters parameters)
-
-
Method Details
-
createAmplRunCommand
-
getAmplBinPath
-
before
Description copied from interface:ExecutionHandler
Method called by theComputationManager
with the working directory as parameter, before the commands are actually executed: it is in charge of any preprocessing of providing the list of commands to be executed. Typically, it will copy input data to the specified working directory, and create the command to be executed with those inputs.If the call throws an exception, no command will be executed.
- Parameters:
workingDir
- the working directory used for this computation. Input data may be written to it.- Returns:
- the list of
CommandExecution
s to be executed. - Throws:
IOException
- when an error occurs while wirting to working directory.
-
after
Description copied from class:AbstractExecutionHandler
Method called by theComputationManager
with the working directory and an execution report as parameters, after the commands defined by theExecutionHandler.before(java.nio.file.Path)
method have been executed: it is in charge of any postprocessing and of providing the actual computation result. Typically, it will check that the execution was correctly performed, then read command results from the specified working directory and translate it to a business object.That method will not be called in case the call to
ExecutionHandler.before(java.nio.file.Path)
throws an exception, or if the execution is cancelled. That implementation checks theExecutionReport
for errors, and throws aPowsyblException
in that case. May be called by actual implementations.- Specified by:
after
in interfaceExecutionHandler<AmplResults>
- Overrides:
after
in classAbstractExecutionHandler<AmplResults>
- Parameters:
workingDir
- the working directory used for this computation. Results may be read from it.report
- the execution report, in particular reporting command execution errors.- Returns:
- the actual result of the processing.
- Throws:
IOException
- if and error occurs while reading results from the working directory.
-