Skip to content

Commit

Permalink
Clean-up getLine
Browse files Browse the repository at this point in the history
  • Loading branch information
yichen88 committed Aug 1, 2017
1 parent fa374c3 commit 3707be4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
Expand Up @@ -112,10 +112,7 @@ public void looseConstraints(String stateId, List<LimitViolation> violations, fl
}

private void setNewCurrentLimit(String stateId, LimitViolation violation, float margin, boolean applyToBaseCase) {
TwoTerminalsConnectable branch = network.getLine(violation.getSubjectId());
if ( branch == null ) {
branch = network.getTwoWindingsTransformer(violation.getSubjectId());
}
TwoTerminalsConnectable branch = network.getBranch(violation.getSubjectId());
if ( branch != null ) {
float newLimit = getNewUpperLimit(violation, margin);
if ( branch.getTerminal1().getI() == violation.getValue() ) {
Expand All @@ -127,11 +124,8 @@ private void setNewCurrentLimit(String stateId, LimitViolation violation, float
branch.newCurrentLimits1().setPermanentLimit(newLimit).add();
if ( applyToBaseCase && !StateManager.INITIAL_STATE_ID.equals(stateId) ) { // change the limit also to basecase
network.getStateManager().setWorkingState(StateManager.INITIAL_STATE_ID);
branch = network.getLine(violation.getSubjectId());
if ( branch == null ) {
branch = network.getTwoWindingsTransformer(violation.getSubjectId());
}
LOGGER.debug("State {}: changing current limit 1 of branch {}: {} -> {}",
branch = network.getBranch(violation.getSubjectId());
LOGGER.debug("State {}: changing current limit 1 of branch {}: {} -> {}",
StateManager.INITIAL_STATE_ID,
branch.getId(),
violation.getLimit(),
Expand All @@ -148,11 +142,8 @@ private void setNewCurrentLimit(String stateId, LimitViolation violation, float
branch.newCurrentLimits2().setPermanentLimit(newLimit).add();
if ( applyToBaseCase && !StateManager.INITIAL_STATE_ID.equals(stateId) ) { // change the limit also to basecase
network.getStateManager().setWorkingState(StateManager.INITIAL_STATE_ID);
branch = network.getLine(violation.getSubjectId());
if ( branch == null ) {
branch = network.getTwoWindingsTransformer(violation.getSubjectId());
}
LOGGER.debug("State {}: changing current limit 2 of branch {}: {} -> {}",
branch = network.getBranch(violation.getSubjectId());
LOGGER.debug("State {}: changing current limit 2 of branch {}: {} -> {}",
StateManager.INITIAL_STATE_ID,
branch.getId(),
violation.getLimit(),
Expand Down
Expand Up @@ -325,10 +325,7 @@ private boolean fixBranchesAlwaysDisconnectAtOneSide(int iteration, Network netw
String branchId = entry.getKey();
if (entry.getValue().size() == 1) {
String substationId = entry.getValue().iterator().next();
TwoTerminalsConnectable branch = network.getLine(branchId);
if (branch == null) {
branch = network.getTwoWindingsTransformer(branchId);
}
TwoTerminalsConnectable branch = network.getBranch(branchId);
if (branch == null) {
throw new RuntimeException();
}
Expand Down
Expand Up @@ -80,10 +80,7 @@ private static WCAEntity toEntity(HistoDbNetworkAttributeId attrId, Network netw
int entityNum;
int sideNum = 0;
float nomV;
TwoTerminalsConnectable branch = network.getLine(attrId.getEquipmentId());
if (branch == null) {
branch = network.getTwoWindingsTransformer(attrId.getEquipmentId());
}
TwoTerminalsConnectable branch = network.getBranch(attrId.getEquipmentId());
if (branch != null) {
entityType = 1;
entityNum = mapper.getInt(AmplSubset.BRANCH, attrId.getEquipmentId());
Expand Down

0 comments on commit 3707be4

Please sign in to comment.