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 all commits
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 @@ -239,6 +239,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 @@ -314,6 +314,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 @@ -48,6 +48,7 @@ private void checkOptionalParametersAreNotPresent(MetrixParameters p) {
assertFalse(p.getOptionalLossOfLoadCost().isPresent());
assertFalse(p.getOptionalCurativeLossOfLoadCost().isPresent());
assertFalse(p.getOptionalCurativeLossOfGenerationCost().isPresent());
assertFalse(p.getOptionalGeneratorMinCost().isPresent());
assertFalse(p.getOptionalContingenciesProbability().isPresent());
assertFalse(p.isWithLostLoadDetailedResultsOnContingency().isPresent());
}
Expand Down Expand Up @@ -145,6 +146,7 @@ void optionalParametersTest() {
.setLossOfLoadCost(9000f)
.setCurativeLossOfLoadCost(1000f)
.setCurativeLossOfGenerationCost(11000f)
.setGeneratorMinCost(1.5f)
.setContingenciesProbability(0.001f);

assertFalse(p.isWithGridCost().get());
Expand All @@ -164,6 +166,7 @@ void optionalParametersTest() {
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(1000f, p.getOptionalCurativeLossOfLoadCost().get(), 0f);
assertEquals(11000f, p.getOptionalCurativeLossOfGenerationCost().get(), 0f);
assertEquals(0.001f, 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
36 changes: 18 additions & 18 deletions metrix-simulator/src/calculecrirecontraintesdodu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,20 @@ int Calculer::ecrireContraintesDeBordGroupesDodu()
// A la hausse
pbXmin_[numVar] = 0.0;
pbXmax_[numVar] = grp->puisMax_ - grp->prodPobj_;
pbCoutLineaire_[numVar] = std::max(grp->coutHausseHR_, config::configuration().noiseCost())
+ config::configuration().adequacyCostOffset();
pbCoutLineaire_[numVar] = std::max(grp->coutHausseHR_
+ config::configuration().adequacyCostOffset(), config::configuration().noiseCost());
// A la baisse
pbXmin_[numVar + 1] = 0.0;
pbXmax_[numVar + 1] = grp->prodPobj_ - grp->puisMin_;
pbCoutLineaire_[numVar + 1] = std::max(grp->coutBaisseHR_, config::configuration().noiseCost())
+ config::configuration().adequacyCostOffset();
pbCoutLineaire_[numVar + 1] = std::max(grp->coutBaisseHR_
+ config::configuration().adequacyCostOffset(), config::configuration().noiseCost());

} else { // P_min>P_0
// A la hausse
pbXmin_[numVar] = grp->puisMin_ - grp->prodPobj_;
pbXmax_[numVar] = grp->puisMax_ - grp->prodPobj_;
pbCoutLineaire_[numVar] = std::max(grp->coutHausseHR_, config::configuration().noiseCost())
+ config::configuration().adequacyCostOffset();
pbCoutLineaire_[numVar] = std::max(grp->coutHausseHR_
+ config::configuration().adequacyCostOffset(), config::configuration().noiseCost());
// A la baisse
pbXmin_[numVar + 1] = 0.0;
pbXmax_[numVar + 1] = 0.0;
Expand All @@ -255,13 +255,13 @@ int Calculer::ecrireContraintesDeBordGroupesDodu()
// A la hausse
pbXmin_[numVar] = 0.;
pbXmax_[numVar] = grp->puisMax_ - grp->prodPobj_;
pbCoutLineaire_[numVar] = std::max(grp->coutHausseHR_, config::configuration().noiseCost())
+ config::configuration().adequacyCostOffset();
pbCoutLineaire_[numVar] = std::max(grp->coutHausseHR_
+ config::configuration().adequacyCostOffset(), config::configuration().noiseCost());
// A la baisse
pbXmin_[numVar + 1] = 0.;
pbXmax_[numVar + 1] = grp->prodPobj_ - grp->puisMin_;
pbCoutLineaire_[numVar + 1] = std::max(grp->coutBaisseHR_, config::configuration().noiseCost())
+ config::configuration().adequacyCostOffset();
pbCoutLineaire_[numVar + 1] = std::max(grp->coutBaisseHR_
+ config::configuration().adequacyCostOffset(), config::configuration().noiseCost());
}
} else { // Groupe deconnecte ou fixe HR
// A la hausse
Expand Down Expand Up @@ -294,13 +294,13 @@ void Calculer::ajoutRedispatchCostOffsetConsos()
const auto& conso = cIt->second;
if (conso->numVarConso_ >= 0) {
if (conso->valeur_ >= 0) {
pbCoutLineaire_[conso->numVarConso_] = std::max(conso->cout_, config.noiseCost())
+ config.redispatchCostOffset();
pbCoutLineaire_[conso->numVarConso_] = std::max(conso->cout_ + config.redispatchCostOffset(),
config.noiseCost());
pbCoutLineaireSansOffset_[conso->numVarConso_] = conso->cout_;
} else {
// consumption cost is negative so we use min instead of max to compare to cost noise
pbCoutLineaire_[conso->numVarConso_] = -(std::min(conso->cout_, -config.noiseCost())
+ config.redispatchCostOffset());
pbCoutLineaire_[conso->numVarConso_] = -(std::min(conso->cout_ + config.redispatchCostOffset(),
-config.noiseCost()));
pbCoutLineaireSansOffset_[conso->numVarConso_] = conso->cout_;
}
}
Expand All @@ -323,13 +323,13 @@ int Calculer::ecrireContraintesDeBordConsosDodu()
if (consoNodale >= 0) {
pbXmin_[numVar] = 0.0;
pbXmax_[numVar] = conso->seuil_ * consoNodale;
pbCoutLineaire_[numVar] = std::max(conso->cout_, config::configuration().noiseCost())
+ config::configuration().adequacyCostOffset();
pbCoutLineaire_[numVar] = std::max(conso->cout_ + config::configuration().adequacyCostOffset(),
config::configuration().noiseCost());
} else {
pbXmin_[numVar] = conso->seuil_ * consoNodale;
pbXmax_[numVar] = 0.0;
pbCoutLineaire_[numVar] = -(std::max(conso->cout_, config::configuration().noiseCost())
+ config::configuration().adequacyCostOffset());
pbCoutLineaire_[numVar] = -(std::max(conso->cout_ + config::configuration().adequacyCostOffset(),
config::configuration().noiseCost()));
}

if (pbXmax_[numVar] - pbXmin_[numVar] < config::constants::epsilon) {
Expand Down
12 changes: 9 additions & 3 deletions metrix-simulator/tests/divers/redispatching_offset/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
Redispatching offset test case :
=================================

In the general case, the adequacy and the rediqpatch cost offset are defined to ensure the user that no opportunity cost will lead metrix to choose generation means instead of network means. Indeed, when downward cost are negative on the balancing mechanism, it can happen that it is more interesting to decrease this geenration unit and increase another upward offer, for economical reason only. For example, if a generation unit produces at minimal power for 15 euros/MW, and another generation unit produces at maximal power at -25 euros/MW, Metrix will increase the first one and decrease the second as it allows a gain of 10 euros/MW.
Hence, the two options adequacyCostOffset and redispatchingCostOffset allows to define a translation cost for all generation units, in order to prevent opportunity while keeping the Metrix final cost indicators identical.
In the general case, the adequacy and the redispatch cost offset are defined to ensure the user that no opportunity cost
will lead Metrix to choose generation means instead of network means. Indeed, when downward cost are negative on the
balancing mechanism, it can happen that it is more interesting to decrease this generation unit and increase another
upward offer, for economical reason only. For example, if a generation unit produces at minimal power for 15 euros/MW,
and another generation unit produces at maximal power at -25 euros/MW, Metrix will increase the first one and decrease
the second as it allows a gain of 10 euros/MW.
Hence, the two options adequacyCostOffset and redispatchingCostOffset allows to define a translation cost for all
generation units, in order to prevent opportunity while keeping the Metrix final cost indicators identical.

In this particular case, we aims to validate this "no opportunity" behavior in the special case of negative load (demand side response).
In this particular case, we aim to validate this "no opportunity" behavior in the special case of negative load (demand side response).
- when load is positive (load shedding) the cost offset is positive and added to the load cost.
- when load is negative, the cost offset is negative and withdrawn to the load cost (which is also negative).
By doing this in the adequacy phase and redispatch phase, we ensure that Metrix will not use the load as first means for constraint.
Expand Down
20 changes: 10 additions & 10 deletions metrix-simulator/tests_reference/groupes/cost_offsets/metrixOut.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ Résultats en volume (MW)
Volume de production = 960.0000 MW
Volume de délestage = 0.0000 MW
Résultats sur les couts
Cout associé aux groupes : 630.0000
Cout associé aux groupes : 600.0000
Cout associé au délestage : 0.0000
Cout de pénalisation TD & HVDC : 0.0000
Cout des écarts de transit : 0.0000
Valeur de la fonction objectif : 630.0000
Valeur de la fonction objectif : 600.0000

Prise en compte des couts avec reseau
Micro itération 1 (nombre de contraintes 1)
Expand Down Expand Up @@ -88,11 +88,11 @@ Résultats en volume (MW)
Volume de production = 960.0000 MW
Volume de délestage = 0.0000 MW
Résultats sur les couts
Cout associé aux groupes : 630.0000
Cout associé aux groupes : 600.0000
Cout associé au délestage : 0.0000
Cout de pénalisation TD & HVDC : 0.0000
Cout des écarts de transit : 0.0000
Valeur de la fonction objectif : 630.0000
Valeur de la fonction objectif : 600.0000

Prise en compte des couts avec reseau
Micro itération 1 (nombre de contraintes 1)
Expand Down Expand Up @@ -124,11 +124,11 @@ Résultats en volume (MW)
Volume de production = 960.0000 MW
Volume de délestage = 0.0000 MW
Résultats sur les couts
Cout associé aux groupes : 630.0000
Cout associé aux groupes : 600.0000
Cout associé au délestage : 0.0000
Cout de pénalisation TD & HVDC : 0.0000
Cout des écarts de transit : 0.0000
Valeur de la fonction objectif : 630.0000
Valeur de la fonction objectif : 600.0000

Prise en compte des couts avec reseau
Micro itération 1 (nombre de contraintes 1)
Expand Down Expand Up @@ -178,11 +178,11 @@ Résultats en volume (MW)
Volume de production = 960.0000 MW
Volume de délestage = 0.0000 MW
Résultats sur les couts
Cout associé aux groupes : 630.0000
Cout associé aux groupes : 600.0000
Cout associé au délestage : 0.0000
Cout de pénalisation TD & HVDC : 0.0000
Cout des écarts de transit : 0.0000
Valeur de la fonction objectif : 630.0000
Valeur de la fonction objectif : 600.0000

Prise en compte des couts avec reseau
Micro itération 1 (nombre de contraintes 1)
Expand Down Expand Up @@ -232,11 +232,11 @@ Résultats en volume (MW)
Volume de production = 960.0000 MW
Volume de délestage = 0.0000 MW
Résultats sur les couts
Cout associé aux groupes : 630.0000
Cout associé aux groupes : 600.0000
Cout associé au délestage : 0.0000
Cout de pénalisation TD & HVDC : 0.0000
Cout des écarts de transit : 0.0000
Valeur de la fonction objectif : 630.0000
Valeur de la fonction objectif : 600.0000

Prise en compte des couts avec reseau
Micro itération 1 (nombre de contraintes 1)
Expand Down