Package com.powsybl.iidm.network
Interface VariantManager
- All Known Implementing Classes:
VariantManagerImpl
public interface VariantManager
This class provides methods to manage variants of the network (create and
remove a variant, set the working variant, etc).
WARNING: Variant management is not thread safe and should never be done will an other thread read from or write to
an already existing variant. The classical pattern for multi-variant processing is to pre-allocate variants and
call allowVariantMultiThreadAccess(boolean)
to allow multi-thread access on main thread, work on variants from other
threads (be carefull to only write concurrently attributes flagged as dependent to variant in the Javadoc) and then
remove variants from main thread once work is over.
- Author:
- Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
-
Method Summary
Modifier and TypeMethodDescriptionvoid
allowVariantMultiThreadAccess
(boolean allow) Allows variants to be accessed simultaneously by different threads.void
cloneVariant
(String sourceVariantId, String targetVariantId) Create a new variant by cloning an existing one.void
cloneVariant
(String sourceVariantId, String targetVariantId, boolean mayOverwrite) Create or overwrite a variant by cloning an existing one.void
cloneVariant
(String sourceVariantId, List<String> targetVariantIds) Create a new variant by cloning an existing one.void
cloneVariant
(String sourceVariantId, List<String> targetVariantIds, boolean mayOverwrite) Create or overwrite a variant by cloning an existing one.Get the variant id list.Get the working variant.boolean
Get the allowed multithread access state .void
removeVariant
(String variantId) Remove a variant.void
setWorkingVariant
(String variantId) Set the working variant.
-
Method Details
-
getVariantIds
Collection<String> getVariantIds()Get the variant id list.- Returns:
- the variant id list
-
getWorkingVariantId
String getWorkingVariantId()Get the working variant.- Returns:
- the id of the working variant
-
setWorkingVariant
Set the working variant.- Parameters:
variantId
- the id of the working variant- Throws:
PowsyblException
- if the variant is not found
-
cloneVariant
Create a new variant by cloning an existing one.- Parameters:
sourceVariantId
- the source variant idtargetVariantIds
- the target variant id list (the ones that will be created)- Throws:
PowsyblException
- if the source variant is not found or if a variant with an id of targetStateIds already exists
-
cloneVariant
Create or overwrite a variant by cloning an existing one.- Parameters:
sourceVariantId
- the source variant idtargetVariantIds
- the target variant id list (the ones that will be created/overwritten)mayOverwrite
- indicates if the target can be overwritten when it already exists- Throws:
PowsyblException
- if a variant with an id of targetVariantIds already exists and the mayOverwrite parameter is set tofalse
-
cloneVariant
Create a new variant by cloning an existing one.- Parameters:
sourceVariantId
- the source variant idtargetVariantId
- the target variant id (the one that will be created)- Throws:
PowsyblException
- if the source variant is not found or if a variant with the id targetVariantId already exists
-
cloneVariant
Create or overwrite a variant by cloning an existing one.- Parameters:
sourceVariantId
- the source variant idtargetVariantId
- the target variant id list (the one that will be created/overwritten)mayOverwrite
- indicates if the target can be overwritten when it already exists- Throws:
PowsyblException
- * if a variant with the id of targetVariantId already exists and * the mayOverwrite parameter is set tofalse
-
removeVariant
Remove a variant.- Parameters:
variantId
- the id of the variant to remove
-
allowVariantMultiThreadAccess
void allowVariantMultiThreadAccess(boolean allow) Allows variants to be accessed simultaneously by different threads. When this option is activated, the working variant can have a different value for each thread.- Parameters:
allow
-
-
isVariantMultiThreadAccessAllowed
boolean isVariantMultiThreadAccessAllowed()Get the allowed multithread access state .- Returns:
- a boolean to check if the variantManager is allowed to be accessed simulaneously by different threads.
-