Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
VariableDictionary.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#include <functional>
25#include <optional>
26#include <string>
27#include <unordered_map>
28#include <vector>
29
30#include <antares/solver/optim-model-filler/FullKey.h>
31
33{
34class IMipVariable;
35}
36
38{
39
41{
42 unsigned int initialTime = 0;
43 unsigned int finalTime = 0;
44
46 {
47 public:
48 explicit Iterator(unsigned int current);
49 unsigned int operator*() const;
50 Iterator& operator++();
51 bool operator!=(const Iterator& other) const;
52
53 private:
54 unsigned int current_;
55 };
56
57 Iterator begin() const
58 {
59 return Iterator(initialTime);
60 }
61
62 Iterator end() const
63 {
64 return Iterator(finalTime + 1);
65 } // Make it inclusive
66
67 std::size_t size() const
68 {
69 return finalTime - initialTime + 1;
70 }
71};
72
74{
75public:
76 Dimensions() = default;
77 Dimensions(std::optional<IntegerInterval> scenarioInterval,
78 std::optional<IntegerInterval> timeInterval);
79 bool isTimeDependent() const;
80 bool isScenarioDependent() const;
81 IntegerInterval getTimesteps() const;
82 IntegerInterval getScenarioIndices() const;
83 unsigned int getNumberOfTimesteps() const;
84
85private:
86 std::optional<IntegerInterval> scenarioInterval;
87 std::optional<IntegerInterval> timeInterval;
88};
89
91{
92 unsigned int scenario;
93 unsigned int timestep;
94};
95
97{
99
100 class VectorWithOffset
101 {
102 public:
103 VectorWithOffset() = default;
104 void resize(size_t initial_size, unsigned offset);
105 Value& operator[](unsigned int index);
106 const Value& operator[](unsigned int index) const;
107 const Value& at(unsigned int index) const;
108 Value& at(unsigned int index);
109
110 private:
111 std::vector<Value> values_ = {};
112 unsigned int offset_ = 0;
113 };
114
115 using TwoIndexVector = std::vector<VectorWithOffset>;
116 using HashMapVector = std::unordered_map<PartialKey, TwoIndexVector, PartialKeyHash>;
117
118 HashMapVector hmv;
119 const TwoIndexVector& operator[](const PartialKey& k) const;
120
121public:
122 void addVariable(const Dimensions& dimensions,
123 const PartialKey& key,
124 std::function<Value(const TimeAndScenario&, const std::string&)>&& func);
125
126 Value operator[](const FullKey& k) const;
127 Value& operator[](const FullKey& k);
128
129 Value operator()(const std::string& component, const std::string& variable) const;
130 Value& operator()(const std::string& component, const std::string& variable);
131
132 Value operator()(const std::string& component,
133 const std::string& variable,
134 unsigned int scenario,
135 unsigned int timestep) const;
136
137 Value& operator()(const std::string& component,
138 const std::string& variable,
139 unsigned int scenario,
140 unsigned int timestep);
141 Value operator()(const FullKey& fullKey) const;
142
143 Value& operator()(const FullKey& fullKey);
144};
145} // namespace Antares::Optimization
Definition VariableDictionary.h:74
Definition FullKey.h:42
Definition VariableDictionary.h:46
Definition PartialKey.h:29
Definition VariableDictionary.h:97
Namespace for the classes related to the linear problem API.
Definition EvaluationContext.h:9
Definition constraint-slack-analysis.cpp:45
Definition VariableDictionary.h:41
Definition VariableDictionary.h:91