Loading [MathJax]/extensions/MathMenu.js
Antares Simulator
Power System Simulator
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages Concepts
hourly_csr_problem.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21
22#pragma once
23
24// TODO[FOM] Remove this, it is only required for PROBLEME_HEBDO
25// but this problem has nothing to do with PROBLEME_HEBDO
26#include <set>
27
28#include <antares/logs/logs.h>
29#include <antares/study/parameters/adq-patch-params.h>
30#include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h"
31
32#include "../variables/VariableManagerUtils.h"
33
35{
37 directVar(-1),
38 indirectVar(-1)
39 {
40 }
41
42 LinkVariable(int direct, int indirect):
43 directVar(direct),
44 indirectVar(indirect)
45 {
46 }
47
48 inline bool check() const
49 {
50 if (directVar < 0)
51 {
52 Antares::logs.warning() << "directVar < 0 detected, this should not happen";
53 }
54 if (indirectVar < 0)
55 {
56 Antares::logs.warning() << "indirectVar < 0 detected, this should not happen";
57 }
58
59 return (directVar >= 0) && (indirectVar >= 0);
60 }
61
62 int directVar;
63 int indirectVar;
64};
65
66struct PROBLEME_HEBDO;
67
69{
71
72public:
73 explicit HourlyCSRProblem(const AdqPatchParams& adqPatchParams, PROBLEME_HEBDO* p):
74 adqPatchParams_(adqPatchParams),
75 variableManager_(p->CorrespondanceVarNativesVarOptim,
76 p->NumeroDeVariableStockFinal,
77 p->NumeroDeVariableDeTrancheDeStock,
78 p->NombreDePasDeTempsPourUneOptimisation),
79 problemeHebdo_(p)
80 {
81 double temp = pow(10, -adqPatchParams.curtailmentSharing.thresholdVarBoundsRelaxation);
82 belowThisThresholdSetToZero = std::min(temp, 0.1);
83
84 allocateProblem();
85 }
86
87 HourlyCSRProblem(const HourlyCSRProblem&) = delete;
88 HourlyCSRProblem& operator=(const HourlyCSRProblem&) = delete;
89
90 inline void setHour(int hour)
91 {
92 triggeredHour = hour;
93 }
94
95 void run(uint week, uint year);
96
97private:
98 void calculateCsrParameters();
99
100 void buildProblemVariables();
101 void setVariableBounds();
102 void buildProblemConstraintsLHS();
103 void buildProblemConstraintsRHS();
104 void setProblemCost();
105 void solveProblem(uint week, int year);
106 void allocateProblem();
107
108 // variable construction
109 void constructVariableENS();
110 void constructVariableSpilledEnergy();
111 void constructVariableFlows();
112
113 // variable bounds
114 void setBoundsOnENS();
115 void setBoundsOnSpilledEnergy();
116 void setBoundsOnFlows();
117
118 // Constraints
119 void setRHSvalueOnFlows();
120 void setRHSnodeBalanceValue();
121 void setRHSbindingConstraintsValue();
122
123 // Costs
124 void setQuadraticCost();
125 void setLinearCost();
126
127public:
128 // TODO [gp] : try to make these members private
129 double belowThisThresholdSetToZero;
130 std::map<int, int> numberOfConstraintCsrAreaBalance;
131 std::set<int> ensVariablesInsideAdqPatch; // place inside only ENS inside adq-patch
132 std::set<int> varToBeSetToZeroIfBelowThreshold; // place inside only ENS and Spillage variable
133 int triggeredHour;
134
135 const AdqPatchParams& adqPatchParams_;
137
138 PROBLEME_HEBDO* problemeHebdo_;
139 PROBLEME_ANTARES_A_RESOUDRE problemeAResoudre_;
140
141 std::map<int, int> numberOfConstraintCsrEns;
142 std::map<int, int> numberOfConstraintCsrFlowDissociation;
143 std::map<int, int> numberOfConstraintCsrHourlyBinding; // length is number of binding constraint
144 // contains interco 2-2
145
146 std::map<int, double> rhsAreaBalanceValues;
147
148 // links between two areas inside the adq-patch domain
149 std::map<int, LinkVariable> linkInsideAdqPatch;
150};
int thresholdVarBoundsRelaxation
CSR Variables relaxation threshold.
Definition adq-patch-params.h:75
Definition hourly_csr_problem.h:69
Definition VariableManagement.h:12
Definition adq-patch-params.h:91
Definition hourly_csr_problem.h:35
Definition opt_structure_probleme_a_resoudre.h:37
Definition sim_structure_probleme_economique.h:403