-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into temporary_limit_value
- Loading branch information
Showing
9 changed files
with
774 additions
and
558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,20 +7,19 @@ | |
*/ | ||
package eu.itesla_project.modules.online; | ||
|
||
import java.io.Serializable; | ||
import java.util.*; | ||
|
||
import eu.itesla_project.cases.CaseType; | ||
import eu.itesla_project.commons.config.ModuleConfig; | ||
import eu.itesla_project.commons.config.PlatformConfig; | ||
import eu.itesla_project.iidm.network.Country; | ||
import eu.itesla_project.cases.CaseType; | ||
import eu.itesla_project.simulation.securityindexes.SecurityIndexType; | ||
|
||
import org.joda.time.DateTime; | ||
import org.joda.time.Interval; | ||
|
||
import java.io.Serializable; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
/** | ||
* | ||
* @author Quinary <[email protected]> | ||
*/ | ||
public class OnlineWorkflowParameters implements Serializable { | ||
|
@@ -48,10 +47,11 @@ public class OnlineWorkflowParameters implements Serializable { | |
private float limitReduction; | ||
private boolean handleViolationsInN; | ||
private float constraintMargin; | ||
private String caseFile; | ||
|
||
public static OnlineWorkflowParameters loadDefault() { | ||
ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("online-default-parameters"); | ||
DateTime baseCaseDate = DateTime.parse(config.getStringProperty("baseCaseDate")); | ||
|
||
int states = config.getIntProperty("states"); | ||
String offlineWorkflowId = config.getStringProperty("offlineWorkflowId", null); | ||
TimeHorizon timeHorizon = TimeHorizon.fromName(config.getStringProperty("timeHorizon").trim()); | ||
|
@@ -62,43 +62,61 @@ public static OnlineWorkflowParameters loadDefault() { | |
boolean analyseBasecase = config.getBooleanProperty("analyseBasecase", true); | ||
boolean validation = config.getBooleanProperty("validation", false); | ||
Set<SecurityIndexType> securityIndexes = config.getEnumSetProperty("securityIndexes", SecurityIndexType.class, null); | ||
CaseType caseType = config.getEnumProperty("caseType", CaseType.class); | ||
Set<Country> countries = config.getEnumSetProperty("countries", Country.class); | ||
boolean mergeOptimized = config.getBooleanProperty("mergeOptimized", DEFAULT_MERGE_OPTIMIZED); | ||
float limitReduction = config.getFloatProperty("limitReduction", DEFAULT_LIMIT_REDUCTION); | ||
boolean handleViolationsInN = config.getBooleanProperty("handleViolationsInN", DEFAULT_HANDLE_VIOLATIONS_IN_N); | ||
float constraintMargin = config.getFloatProperty("constraintMargin", DEFAULT_CONSTRAINT_MARGIN); | ||
|
||
return new OnlineWorkflowParameters(baseCaseDate, | ||
states, | ||
histoInterval, | ||
offlineWorkflowId, | ||
timeHorizon, | ||
feAnalysisId, | ||
rulesPurityThreshold, | ||
storeStates, | ||
analyseBasecase, | ||
String caseFile = config.getStringProperty("caseFile", null); | ||
if (caseFile != null) { | ||
if ((config.getStringProperty("baseCaseDate", null) != null) | ||
|| (config.getStringProperty("caseType", null) != null) | ||
|| (config.getStringProperty("countries", null) != null)) | ||
throw new RuntimeException("caseFile and ( baseCaseDate, caseType, countries ) are mutually exclusive options"); | ||
return new OnlineWorkflowParameters(states, | ||
histoInterval, | ||
offlineWorkflowId, | ||
timeHorizon, | ||
feAnalysisId, | ||
rulesPurityThreshold, | ||
storeStates, | ||
analyseBasecase, | ||
validation, | ||
securityIndexes, | ||
mergeOptimized, | ||
limitReduction, | ||
handleViolationsInN, | ||
constraintMargin, | ||
caseFile); | ||
} | ||
DateTime baseCaseDate = DateTime.parse(config.getStringProperty("baseCaseDate")); | ||
CaseType caseType = config.getEnumProperty("caseType", CaseType.class); | ||
Set<Country> countries = config.getEnumSetProperty("countries", Country.class); | ||
return new OnlineWorkflowParameters(baseCaseDate, | ||
states, | ||
histoInterval, | ||
offlineWorkflowId, | ||
timeHorizon, | ||
feAnalysisId, | ||
rulesPurityThreshold, | ||
storeStates, | ||
analyseBasecase, | ||
validation, | ||
securityIndexes, | ||
caseType, | ||
countries, | ||
mergeOptimized, | ||
limitReduction, | ||
handleViolationsInN, | ||
constraintMargin | ||
); | ||
} | ||
|
||
public OnlineWorkflowParameters(DateTime baseCaseDate, int states, Interval histoInterval, String offlineWorkflowId, TimeHorizon timeHorizon, | ||
String feAnalysisId, double rulesPurityThreshold, boolean storeStates, boolean analyseBasecase, boolean validation, | ||
Set<SecurityIndexType> securityIndexes, CaseType caseType, Set<Country> countries, boolean mergeOptimized, | ||
float limitReduction, boolean handleViolationsInN, float constraintMargin) { | ||
Objects.requireNonNull(baseCaseDate); | ||
Objects.requireNonNull(histoInterval); | ||
Objects.requireNonNull(countries); | ||
Objects.requireNonNull(caseType); | ||
constraintMargin); | ||
} | ||
|
||
private OnlineWorkflowParameters(DateTime baseCaseDate, int states, Interval histoInterval, String offlineWorkflowId, TimeHorizon timeHorizon, | ||
String feAnalysisId, double rulesPurityThreshold, boolean storeStates, boolean analyseBasecase, boolean validation, | ||
Set<SecurityIndexType> securityIndexes, CaseType caseType, Set<Country> countries, boolean mergeOptimized, | ||
float limitReduction, boolean handleViolationsInN, float constraintMargin, String caseFile) { | ||
this.baseCaseDate = baseCaseDate; | ||
this.states=states; | ||
this.states = states; | ||
this.histoInterval = histoInterval; | ||
this.offlineWorkflowId = offlineWorkflowId; | ||
this.timeHorizon = timeHorizon; | ||
|
@@ -114,6 +132,62 @@ public OnlineWorkflowParameters(DateTime baseCaseDate, int states, Interval hist | |
this.limitReduction = limitReduction; | ||
this.handleViolationsInN = handleViolationsInN; | ||
this.constraintMargin = constraintMargin; | ||
this.caseFile = caseFile; | ||
} | ||
|
||
|
||
public OnlineWorkflowParameters(DateTime baseCaseDate, int states, Interval histoInterval, String offlineWorkflowId, TimeHorizon timeHorizon, | ||
String feAnalysisId, double rulesPurityThreshold, boolean storeStates, boolean analyseBasecase, boolean validation, | ||
Set<SecurityIndexType> securityIndexes, CaseType caseType, Set<Country> countries, boolean mergeOptimized, | ||
float limitReduction, boolean handleViolationsInN, float constraintMargin) { | ||
this(baseCaseDate, | ||
states, | ||
histoInterval, | ||
offlineWorkflowId, | ||
timeHorizon, | ||
feAnalysisId, | ||
rulesPurityThreshold, | ||
storeStates, | ||
analyseBasecase, | ||
validation, | ||
securityIndexes, | ||
caseType, | ||
countries, | ||
mergeOptimized, | ||
limitReduction, | ||
handleViolationsInN, | ||
constraintMargin, | ||
null); | ||
Objects.requireNonNull(this.baseCaseDate); | ||
Objects.requireNonNull(this.countries); | ||
Objects.requireNonNull(this.caseType); | ||
Objects.requireNonNull(this.histoInterval); | ||
} | ||
|
||
public OnlineWorkflowParameters(int states, Interval histoInterval, String offlineWorkflowId, TimeHorizon timeHorizon, | ||
String feAnalysisId, double rulesPurityThreshold, boolean storeStates, boolean analyseBasecase, boolean validation, | ||
Set<SecurityIndexType> securityIndexes, boolean mergeOptimized, | ||
float limitReduction, boolean handleViolationsInN, float constraintMargin, String caseFile) { | ||
this(null, | ||
states, | ||
histoInterval, | ||
offlineWorkflowId, | ||
timeHorizon, | ||
feAnalysisId, | ||
rulesPurityThreshold, | ||
storeStates, | ||
analyseBasecase, | ||
validation, | ||
securityIndexes, | ||
null, | ||
null, | ||
mergeOptimized, | ||
limitReduction, | ||
handleViolationsInN, | ||
constraintMargin, | ||
caseFile); | ||
Objects.requireNonNull(this.caseFile); | ||
Objects.requireNonNull(this.histoInterval); | ||
} | ||
|
||
public DateTime getBaseCaseDate() { | ||
|
@@ -124,20 +198,20 @@ public Interval getHistoInterval() { | |
return histoInterval; | ||
} | ||
|
||
public int getStates() { | ||
return states; | ||
public int getStates() { | ||
return states; | ||
} | ||
|
||
public String getOfflineWorkflowId() { | ||
return offlineWorkflowId; | ||
public String getOfflineWorkflowId() { | ||
return offlineWorkflowId; | ||
} | ||
|
||
public TimeHorizon getTimeHorizon() { | ||
return timeHorizon; | ||
public TimeHorizon getTimeHorizon() { | ||
return timeHorizon; | ||
} | ||
|
||
public String getFeAnalysisId() { | ||
return feAnalysisId; | ||
public String getFeAnalysisId() { | ||
return feAnalysisId; | ||
} | ||
|
||
public double getRulesPurityThreshold() { | ||
|
@@ -184,6 +258,10 @@ public float getConstraintMargin() { | |
return constraintMargin; | ||
} | ||
|
||
public String getCaseFile() { | ||
return caseFile; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "{baseCaseDate=" + baseCaseDate | ||
|
@@ -196,13 +274,14 @@ public String toString() { | |
+ ", storeStates=" + storeStates | ||
+ ", analyseBasecase=" + analyseBasecase | ||
+ ", validation=" + validation | ||
+ ", securityIndexes=" + securityIndexes | ||
+ ", securityIndexes=" + securityIndexes | ||
+ ", caseType=" + caseType | ||
+ ", countries=" + countries | ||
+ ", mergeOptimized=" + mergeOptimized | ||
+ ", limitReduction=" + limitReduction | ||
+ ", handleViolationsInN=" + handleViolationsInN | ||
+ ", constraintMargin=" + constraintMargin | ||
+ ", caseFile=" + caseFile | ||
+ "}"; | ||
} | ||
|
||
|
@@ -274,4 +353,8 @@ public void setConstraintMargin(float constraintMargin) { | |
this.constraintMargin = constraintMargin; | ||
} | ||
|
||
public void setCaseFile(String caseFile) { | ||
this.caseFile = caseFile; | ||
} | ||
|
||
} |
Oops, something went wrong.