Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue-155] User setting of NULLCOST parameter #159

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ParametersData {
Float lossOfLoadCost
Float curativeLossOfLoadCost
Float curativeLossOfGenerationCost
Float generatorMinCost
Float contingenciesProbability
Integer nominalU
Integer nbMaxIteration
Expand Down Expand Up @@ -143,6 +144,10 @@ class ParametersData {
this.curativeLossOfGenerationCost = lossOfGenerationCost
}

void generatorMinCost(Float generatorMinCost) {
this.generatorMinCost = generatorMinCost
}

void contingenciesProbability(Float contingenciesProbability) {
this.contingenciesProbability = contingenciesProbability
}
Expand Down Expand Up @@ -269,6 +274,9 @@ class ParametersData {
if (spec.curativeLossOfGenerationCost != null) {
parameters.setCurativeLossOfGenerationCost(spec.curativeLossOfGenerationCost)
}
if (spec.generatorMinCost != null) {
parameters.setGeneratorMinCost(spec.generatorMinCost)
}
if (spec.contingenciesProbability != null) {
parameters.setContingenciesProbability(spec.contingenciesProbability)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public static MetrixParameters load() {
private Float curativeLossOfLoadCost = null;
private Float curativeLossOfGenerationCost = null;
private Float contingenciesProbability = null;
private Float generatorMinCost = null;

public MetrixParameters() {
this(DEFAULT_COMPUTATION_TYPE, DEFAULT_LOSS_FACTOR, DEFAULT_NOMINAL_U);
Expand Down Expand Up @@ -239,6 +240,11 @@ private Float getContingenciesProbability() {
return contingenciesProbability;
}

@JsonGetter
private Float getGeneratorMinCost() {
return generatorMinCost;
}

public MetrixComputationType getComputationType() {
return computationType;
}
Expand Down Expand Up @@ -529,6 +535,17 @@ public MetrixParameters setCurativeLossOfGenerationCost(Float curativeLossOfGene
return this;
}

// Generator min cost
@JsonIgnore
public Optional<Float> getOptionalGeneratorMinCost() {
return Optional.ofNullable(generatorMinCost);
}

public MetrixParameters setGeneratorMinCost(Float generatorMinCost) {
this.generatorMinCost = generatorMinCost;
return this;
}

// Outage probability
@JsonIgnore
public Optional<Float> getOptionalContingenciesProbability() {
Expand Down Expand Up @@ -617,6 +634,7 @@ public int hashCode() {
lossOfLoadCost,
curativeLossOfLoadCost,
curativeLossOfGenerationCost,
generatorMinCost,
contingenciesProbability,
maxSolverTime,
nbMaxIteration,
Expand Down Expand Up @@ -654,6 +672,7 @@ public boolean equals(Object obj) {
Objects.equals(lossOfLoadCost, other.lossOfLoadCost) &&
Objects.equals(curativeLossOfLoadCost, other.curativeLossOfLoadCost) &&
Objects.equals(curativeLossOfGenerationCost, other.curativeLossOfGenerationCost) &&
Objects.equals(generatorMinCost, other.generatorMinCost) &&
Objects.equals(contingenciesProbability, other.contingenciesProbability) &&
Objects.equals(maxSolverTime, other.maxSolverTime) &&
Objects.equals(nbMaxIteration, other.nbMaxIteration) &&
Expand Down Expand Up @@ -696,6 +715,7 @@ public String toString() {
getOptionalLossOfLoadCost().ifPresent(value -> builder.put("lossOfLoadCost", value));
getOptionalCurativeLossOfLoadCost().ifPresent(value -> builder.put("curativeLossOfLoadCost", value));
getOptionalCurativeLossOfGenerationCost().ifPresent(value -> builder.put("curativeLossOfGenerationCost", value));
getOptionalGeneratorMinCost().ifPresent(value -> builder.put("generatorMinCost", value));
getOptionalContingenciesProbability().ifPresent(value -> builder.put("contingenciesProbability", value));
getOptionalMaxSolverTime().ifPresent(value -> builder.put("maxSolverTime", value));
getOptionalNbMaxIteration().ifPresent(value -> builder.put("nbMaxIteration", value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ private void writeOptions(MetrixDie die) {
parameters.getOptionalLossOfLoadCost().ifPresent(value -> die.setFloat("COUTDEFA", value));
parameters.getOptionalCurativeLossOfLoadCost().ifPresent(value -> die.setFloat("COUENDCU", value));
parameters.getOptionalCurativeLossOfGenerationCost().ifPresent(value -> die.setFloat("COUENECU", value));
parameters.getOptionalGeneratorMinCost().ifPresent(value -> die.setFloat("NULLCOST", value));
parameters.getOptionalContingenciesProbability().ifPresent(value -> die.setFloat("PROBAINC", value));
parameters.getOptionalMaxSolverTime().ifPresent(value -> die.setInt("MAXSOLVE", value));
parameters.getOptionalNbMaxIteration().ifPresent(value -> die.setInt("NBMAXMIT", value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ void testParameters() throws IOException {
" lossOfLoadCost 12000",
" curativeLossOfLoadCost 26000",
" curativeLossOfGenerationCost 100",
" generatorMinCost 0.5",
" contingenciesProbability 0.01",
" maxSolverTime (-1)",
" nominalU 103",
Expand Down Expand Up @@ -574,6 +575,7 @@ void testParameters() throws IOException {
assertEquals(12000f, parameters.getOptionalLossOfLoadCost().get(), 0f);
assertEquals(26000f, parameters.getOptionalCurativeLossOfLoadCost().get(), 0f);
assertEquals(100f, parameters.getOptionalCurativeLossOfGenerationCost().get(), 0f);
assertEquals(0.5f, parameters.getOptionalGeneratorMinCost().get(), 0f);
assertEquals(0.01f, parameters.getOptionalContingenciesProbability().get(), 0f);
assertEquals(4, parameters.getOptionalNbMaxIteration().getAsInt());
assertEquals(2, parameters.getOptionalNbMaxCurativeAction().getAsInt());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ void metrixInputTest() throws IOException {
.setLossOfLoadCost(13000f)
.setCurativeLossOfLoadCost(26000f)
.setCurativeLossOfGenerationCost(100f)
.setGeneratorMinCost(-100.5f)
.setContingenciesProbability(0.001f)
.setNbMaxIteration(3)
.setNbMaxCurativeAction(4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void getSetTest() {
assertFalse(p.getOptionalLossOfLoadCost().isPresent());
assertFalse(p.getOptionalCurativeLossOfLoadCost().isPresent());
assertFalse(p.getOptionalCurativeLossOfGenerationCost().isPresent());
assertFalse(p.getOptionalGeneratorMinCost().isPresent());
assertFalse(p.getOptionalContingenciesProbability().isPresent());
assertFalse(p.getOptionalMaxSolverTime().isPresent());
assertFalse(p.getOptionalLossNbRelaunch().isPresent());
Expand Down Expand Up @@ -75,6 +76,7 @@ void getSetTest() {
.setLossOfLoadCost(9000f)
.setCurativeLossOfLoadCost(1000f)
.setCurativeLossOfGenerationCost(11000f)
.setGeneratorMinCost(1.5f)
.setContingenciesProbability(0.001f)
.setMaxSolverTime(-1)
.setLossNbRelaunch(2)
Expand Down Expand Up @@ -106,6 +108,7 @@ void getSetTest() {
assertEquals(0.0001f, p.getOptionalPstCostPenality().get(), 0f);
assertEquals(0.01f, p.getOptionalHvdcCostPenality().get(), 0f);
assertEquals(9000f, p.getOptionalLossOfLoadCost().get(), 0f);
assertEquals(1.5f, p.getOptionalGeneratorMinCost().get(), 0f);
assertEquals(0.001f, p.getOptionalContingenciesProbability().get(), 0f);
assertEquals(-1, p.getOptionalMaxSolverTime().getAsInt());
assertEquals(3, p.getOptionalNbMaxIteration().getAsInt());
Expand Down Expand Up @@ -174,6 +177,9 @@ void getSetTest() {
assertEquals(p, p.setLossOfLoadCost(8000f));
assertEquals(8000f, p.getOptionalLossOfLoadCost().get(), 0f);

assertEquals(p, p.setGeneratorMinCost(-2.5f));
assertEquals(-2.5f, p.getOptionalGeneratorMinCost().get(), 0f);

assertEquals(p, p.setContingenciesProbability(0.003f));
assertEquals(0.003f, p.getOptionalContingenciesProbability().get(), 0f);

Expand Down
9 changes: 9 additions & 0 deletions metrix-integration/src/test/resources/simpleNetwork.json
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,15 @@
"firstValueIndex" : 1,
"lastValueIndex" : 1,
"values" : [ 100.0 ]
}, {
"name" : "NULLCOST",
"type" : "FLOAT",
"valueCount" : 1,
"firstIndexMaxValue" : 1,
"secondIndexMaxValue" : 1,
"firstValueIndex" : 1,
"lastValueIndex" : 1,
"values" : [ -100.5 ]
}, {
"name" : "PROBAINC",
"type" : "FLOAT",
Expand Down
Loading