Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
model.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#pragma once
22
23#include <map>
24#include <vector>
25
26#include <antares/expressions/expression.h>
27
28#include "constraint.h"
29#include "parameter.h"
30#include "port.h"
31#include "portFieldDefinition.h"
32#include "variable.h"
33
34namespace Antares::Study::SystemModel
35{
36
41// TODO: add unit tests for this class
42class Model
43{
44public:
45 Model() = default;
46 Model(Model&&) = default;
47 Model(const Model&) = delete;
48 ~Model() = default;
49
50 Model& operator=(Model&&) = default;
51 Model& operator=(const Model&) = delete;
52
53 const std::string& Id() const
54 {
55 return id_;
56 }
57
58 const Expression& Objective() const
59 {
60 return objective_;
61 }
62
63 const std::map<std::string, Constraint>& getConstraints() const
64 {
65 return constraints_;
66 }
67
68 const std::map<std::string, Parameter>& Parameters() const
69 {
70 return parameters_;
71 }
72
73 const std::map<std::string, Variable>& Variables() const
74 {
75 // TODO : convert to vector?
76 return variables_;
77 }
78
79 const std::map<std::string, Port>& Ports() const
80 {
81 return ports_;
82 }
83
84 const std::map<std::string, PortFieldDefinition>& PortFieldDefinitions() const
85 {
86 return portFieldDefinitions_;
87 }
88
89private:
90 friend class ModelBuilder;
91 std::string id_;
92 Expression objective_;
93
94 std::map<std::string, Parameter> parameters_;
95 std::map<std::string, Variable> variables_;
96 std::map<std::string, Constraint> constraints_;
97 std::map<std::string, Port> ports_;
98 std::map<std::string, PortFieldDefinition> portFieldDefinitions_;
99};
100
102{
103public:
104 ModelBuilder& withId(std::string_view id);
106 ModelBuilder& withParameters(std::vector<Parameter>&& parameters);
107 ModelBuilder& withVariables(std::vector<Variable>&& variables);
108 ModelBuilder& withPorts(std::vector<Port>&& ports);
109 Model build();
110
111 ModelBuilder& withConstraints(std::vector<Constraint>&& constraints);
112 ModelBuilder& withPortFieldDefinitions(std::vector<PortFieldDefinition>&& portFieldDefinitions);
113
114private:
115 Model model_;
116};
117
118} // namespace Antares::Study::SystemModel
Definition expression.h:37
ModelBuilder & withConstraints(std::vector< Constraint > &&constraints)
Sets the ID of the library.
Definition model.cpp:138
ModelBuilder & withPorts(std::vector< Port > &&ports)
Sets the ports of the model.
Definition model.cpp:117
ModelBuilder & withObjective(Expression &&objective)
Sets the objective of the model.
Definition model.cpp:62
Model build()
Builds and returns the Model object.
Definition model.cpp:37
ModelBuilder & withVariables(std::vector< Variable > &&variables)
Sets the variables of the model.
Definition model.cpp:97
ModelBuilder & withParameters(std::vector< Parameter > &&parameters)
Sets the parameters of the model.
Definition model.cpp:76
ModelBuilder & withId(std::string_view id)
Sets the ID of the model.
Definition model.cpp:50
ModelBuilder & withPortFieldDefinitions(std::vector< PortFieldDefinition > &&portFieldDefinitions)
Sets the ports of the model.
Definition model.cpp:159