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