Antares Simulator
Power System Simulator
BindingConstraint.hxx
1 /*
2 ** Copyright 2007-2025, 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 #pragma once
22 #include <ranges>
23 
24 namespace Antares::Data
25 {
26 inline const ConstraintName& BindingConstraint::name() const
27 {
28  return pName;
29 }
30 
31 inline const ConstraintName& BindingConstraint::id() const
32 {
33  return pID;
34 }
35 
36 inline const YString& BindingConstraint::comments() const
37 {
38  return pComments;
39 }
40 
41 inline void BindingConstraint::comments(const AnyString& newcomments)
42 {
43  pComments = newcomments;
44 }
45 
46 inline uint BindingConstraint::linkCount() const
47 {
48  return (uint)pLinkWeights.size();
49 }
50 
52 {
53  return std::ranges::count_if(pClusterWeights | std::views::keys,
54  [](const Data::ThermalCluster* coeff)
55  { return coeff->isActive(); });
56 }
57 
58 inline bool BindingConstraint::enabled() const
59 {
60  return pEnabled;
61 }
62 
63 inline BindingConstraint::Operator BindingConstraint::operatorType() const
64 {
65  return pOperator;
66 }
67 
69 {
70  return pType;
71 }
72 
74 {
75  if (t != typeUnknown and t != typeMax)
76  {
77  pType = t;
78  }
79 }
80 
81 inline bool BindingConstraint::skipped() const
82 {
83  return linkCount() == 0 && clusterCount() == 0;
84 }
85 
86 inline bool BindingConstraint::isActive() const
87 {
88  return enabled() && !skipped();
89 }
90 
91 inline BindingConstraint::iterator BindingConstraint::begin()
92 {
93  return pLinkWeights.begin();
94 }
95 
96 inline BindingConstraint::iterator BindingConstraint::end()
97 {
98  return pLinkWeights.end();
99 }
100 
101 inline BindingConstraint::const_iterator BindingConstraint::begin() const
102 {
103  return pLinkWeights.begin();
104 }
105 
106 inline BindingConstraint::const_iterator BindingConstraint::end() const
107 {
108  return pLinkWeights.end();
109 }
110 
111 template<class Env>
112 inline std::string BindingConstraint::timeSeriesFileName(const Env& env) const
113 {
114  switch (operatorType())
115  {
116  case BindingConstraint::opLess:
117  return std::string() + env.folder.c_str() + Yuni::IO::Separator + id().c_str() + "_lt"
118  + ".txt";
119  case BindingConstraint::opGreater:
120  return std::string() + env.folder.c_str() + Yuni::IO::Separator + id().c_str() + "_gt"
121  + ".txt";
122  case BindingConstraint::opEquality:
123  return std::string() + env.folder.c_str() + Yuni::IO::Separator + id().c_str() + "_eq"
124  + ".txt";
125  default:
126  logs.error("Cannot load/save time series of type other that eq/gt/lt");
127  return "";
128  }
129 }
130 
131 } // namespace Antares::Data
const YString & comments() const
Get the comments.
Definition: BindingConstraint.hxx:36
void setTimeGranularity(Type t)
Set the type of the binding constraint.
Definition: BindingConstraint.hxx:73
uint clusterCount() const
Get how many thermal clusters the binding constraint contains.
Definition: BindingConstraint.hxx:51
bool enabled() const
Get if the binding constraint is enabled.
Definition: BindingConstraint.hxx:58
const ConstraintName & id() const
Get the ID of the binding constraint.
Definition: BindingConstraint.hxx:31
linkWeightMap::iterator iterator
Iterator.
Definition: BindingConstraint.h:92
Type type() const
Get the type of the binding constraint.
Definition: BindingConstraint.hxx:68
linkWeightMap::const_iterator const_iterator
Const iterator.
Definition: BindingConstraint.h:94
Type
Definition: BindingConstraint.h:55
@ typeMax
The maximum number of types.
Definition: BindingConstraint.h:65
@ typeUnknown
Unknown status.
Definition: BindingConstraint.h:57
const ConstraintName & name() const
Get the name of the binding constraint.
Definition: BindingConstraint.hxx:26
uint linkCount() const
Get how many links the binding constraint contains.
Definition: BindingConstraint.hxx:46
A single thermal cluster.
Definition: cluster.h:76