Skip to content

Commit

Permalink
Add NetPosition constraint & variable
Browse files Browse the repository at this point in the history
  • Loading branch information
flomnes committed Dec 30, 2024
1 parent 24697e7 commit 5e40e10
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/solver/optimisation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ set(RTESOLVER_OPT
include/antares/solver/optimisation/constraints/constraint_builder_utils.h
include/antares/solver/optimisation/constraints/AreaBalance.h
constraints/AreaBalance.cpp
include/antares/solver/optimisation/constraints/NetPosition.h
constraints/NetPosition.cpp
include/antares/solver/optimisation/constraints/FictitiousLoad.h
constraints/FictitiousLoad.cpp
include/antares/solver/optimisation/constraints/ShortTermStorageLevel.h
Expand Down
17 changes: 2 additions & 15 deletions src/solver/optimisation/constraints/AreaBalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,9 @@ void AreaBalance::add(int pdt, int pays)

builder.updateHourWithinWeek(pdt);

int interco = data.IndexDebutIntercoOrigine[pays];
while (interco >= 0)
{
builder.NTCDirect(interco, 1.0);
interco = data.IndexSuivantIntercoOrigine[interco];
}

interco = data.IndexDebutIntercoExtremite[pays];
while (interco >= 0)
{
builder.NTCDirect(interco, -1.0);
interco = data.IndexSuivantIntercoExtremite[interco];
}

ExportPaliers(data.PaliersThermiquesDuPays[pays], builder);
builder.HydProd(pays, -1.0)
builder.NetPosition(pays, 1)
.HydProd(pays, -1.0)
.Pumping(pays, 1.0)
.PositiveUnsuppliedEnergy(pays, -1.0)
.NegativeUnsuppliedEnergy(pays, 1.0);
Expand Down
13 changes: 13 additions & 0 deletions src/solver/optimisation/constraints/Group1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ AreaBalanceData Group1::GetAreaBalanceData()
.ShortTermStorage = problemeHebdo_->ShortTermStorage};
}

NetPositionData Group1::GetNetPositionData()
{
return {.CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim,
.IndexDebutIntercoOrigine = problemeHebdo_->IndexDebutIntercoOrigine,
.IndexSuivantIntercoOrigine = problemeHebdo_->IndexSuivantIntercoOrigine,
.IndexDebutIntercoExtremite = problemeHebdo_->IndexDebutIntercoExtremite,
.IndexSuivantIntercoExtremite = problemeHebdo_->IndexSuivantIntercoExtremite};
}

FictitiousLoadData Group1::GetFictitiousLoadData()
{
return {.CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim,
Expand Down Expand Up @@ -79,6 +88,9 @@ void Group1::BuildConstraints()
auto areaBalanceData = GetAreaBalanceData();
AreaBalance areaBalance(builder_, areaBalanceData);

auto netPositionData = GetNetPositionData();
NetPosition netPosition(builder_, netPositionData);

auto fictitiousLoadData = GetFictitiousLoadData();
FictitiousLoad fictitiousLoad(builder_, fictitiousLoadData);

Expand Down Expand Up @@ -116,6 +128,7 @@ void Group1::BuildConstraints()
for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
{
areaBalance.add(pdt, pays);
netPosition.add(pdt, pays);
fictitiousLoad.add(pdt, pays);
shortTermStorageLevel.add(pdt, pays);
shortTermStorageCostVariationInjectionBackward.add(pdt, pays);
Expand Down
47 changes: 47 additions & 0 deletions src/solver/optimisation/constraints/NetPosition.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
** Copyright 2007-2024, RTE (https://www.rte-france.com)
** See AUTHORS.txt
** SPDX-License-Identifier: MPL-2.0
** This file is part of Antares-Simulator,
** Adequacy and Performance assessment for interconnected energy networks.
**
** Antares_Simulator is free software: you can redistribute it and/or modify
** it under the terms of the Mozilla Public Licence 2.0 as published by
** the Mozilla Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** Antares_Simulator is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** Mozilla Public Licence 2.0 for more details.
**
** You should have received a copy of the Mozilla Public Licence 2.0
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include "antares/solver/optimisation/constraints/NetPosition.h"

void NetPosition::add(int pdt, int pays)
{
int interco = data.IndexDebutIntercoOrigine[pays];
while (interco >= 0)
{
builder.NTCDirect(interco, 1.0);
interco = data.IndexSuivantIntercoOrigine[interco];
}

interco = data.IndexDebutIntercoExtremite[pays];
while (interco >= 0)
{
builder.NTCDirect(interco, -1.0);
interco = data.IndexSuivantIntercoExtremite[interco];
}

ConstraintNamer namer(builder.data.NomDesContraintes);
namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
namer.UpdateArea(builder.data.NomsDesPays[pays]);
namer.NetPosition(builder.data.nombreDeContraintes);

builder.NetPosition(pays, 1.0);
builder.equalTo().build();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "ConstraintGroup.h"
#include "FictitiousLoad.h"
#include "FlowDissociation.h"
#include "NetPosition.h"
#include "ShortTermStorageLevel.h"

class Group1: public ConstraintGroup
Expand All @@ -36,6 +37,7 @@ class Group1: public ConstraintGroup

private:
AreaBalanceData GetAreaBalanceData();
NetPositionData GetNetPositionData();
FictitiousLoadData GetFictitiousLoadData();
ShortTermStorageData GetShortTermStorageData();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
** Copyright 2007-2024, RTE (https://www.rte-france.com)
** See AUTHORS.txt
** SPDX-License-Identifier: MPL-2.0
** This file is part of Antares-Simulator,
** Adequacy and Performance assessment for interconnected energy networks.
**
** Antares_Simulator is free software: you can redistribute it and/or modify
** it under the terms of the Mozilla Public Licence 2.0 as published by
** the Mozilla Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** Antares_Simulator is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** Mozilla Public Licence 2.0 for more details.
**
** You should have received a copy of the Mozilla Public Licence 2.0
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
#pragma once
#include "ConstraintBuilder.h"

struct NetPositionData
{
std::vector<CORRESPONDANCES_DES_CONTRAINTES>& CorrespondanceCntNativesCntOptim;
const std::vector<int>& IndexDebutIntercoOrigine;
const std::vector<int>& IndexSuivantIntercoOrigine;
const std::vector<int>& IndexDebutIntercoExtremite;
const std::vector<int>& IndexSuivantIntercoExtremite;
};

/*!
* represent 'Net Position' constraint type
*/

class NetPosition: public ConstraintFactory
{
public:
NetPosition(ConstraintBuilder& builder, NetPositionData& data):
ConstraintFactory(builder),
data(data)
{
}

/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pdt : timestep
* @param pays : area
*/

void add(int pdt, int pays);

private:
NetPositionData& data;
};
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class VariableNamer: public Namer
void PositiveUnsuppliedEnergy(unsigned int variable);
void NegativeUnsuppliedEnergy(unsigned int variable);
void AreaBalance(unsigned int variable);
void NetPosition(unsigned int variable);

private:
void SetAreaVariableName(unsigned int variable,
Expand All @@ -133,6 +134,7 @@ class ConstraintNamer: public Namer
const std::string& origin,
const std::string& destination);

void NetPosition(unsigned int variable);
void AreaBalance(unsigned int constraint);
void FictiveLoads(unsigned int constraint);
void HydroPower(unsigned int constraint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaire(PROBLEME_HEBD
// NetPosition
ProblemeAResoudre->TypeDeVariable[NombreDeVariables] = VARIABLE_NON_BORNEE;
variableManager.NetPosition(pays, pdt) = NombreDeVariables;
variableNamer.NetPosition(NombreDeVariables);
NombreDeVariables++;

for (const auto& storage: problemeHebdo->ShortTermStorage[pays])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,13 @@ int OPT_DecompteDesVariablesEtDesContraintesDuProblemeAOptimiser(PROBLEME_HEBDO*
}
}

// NetPosition
for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
{
ProblemeAResoudre->NombreDeVariables += nombreDePasDeTempsPourUneOptimisation;
ProblemeAResoudre->NombreDeContraintes += nombreDePasDeTempsPourUneOptimisation;
}

if (problemeHebdo->OptimisationAvecCoutsDeDemarrage)
{
OPT_DecompteDesVariablesEtDesContraintesCoutsDeDemarrage(problemeHebdo);
Expand Down
10 changes: 10 additions & 0 deletions src/solver/optimisation/opt_rename_problem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ void VariableNamer::ShortTermStorageCostVariationWithdrawal(unsigned int variabl
SetShortTermStorageVariableName(variable, "CostVariationWithdrawal", shortTermStorageName);
}

void VariableNamer::NetPosition(unsigned int constraint)
{
SetAreaElementNameHour(constraint, "NetPositionVariable");
}

void VariableNamer::HydProd(unsigned int variable)
{
SetAreaElementNameHour(variable, "HydProd");
Expand Down Expand Up @@ -275,6 +280,11 @@ void ConstraintNamer::AreaBalance(unsigned int constraint)
SetAreaElementNameHour(constraint, "AreaBalance");
}

void ConstraintNamer::NetPosition(unsigned int constraint)
{
SetAreaElementNameHour(constraint, "NetPositionConstraint");
}

void ConstraintNamer::FictiveLoads(unsigned int constraint)
{
SetAreaElementNameHour(constraint, "FictiveLoads");
Expand Down

0 comments on commit 5e40e10

Please sign in to comment.