power-grid-model 1.11.48__py3-none-win_amd64.whl → 1.12.72__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of power-grid-model might be problematic. Click here for more details.
- power_grid_model/__init__.py +54 -54
- power_grid_model/_core/__init__.py +3 -3
- power_grid_model/_core/buffer_handling.py +493 -487
- power_grid_model/_core/data_handling.py +195 -141
- power_grid_model/_core/data_types.py +143 -132
- power_grid_model/_core/dataset_definitions.py +109 -109
- power_grid_model/_core/enum.py +226 -226
- power_grid_model/_core/error_handling.py +206 -206
- power_grid_model/_core/errors.py +130 -130
- power_grid_model/_core/index_integer.py +17 -17
- power_grid_model/_core/options.py +71 -71
- power_grid_model/_core/power_grid_core.py +563 -563
- power_grid_model/_core/power_grid_dataset.py +535 -535
- power_grid_model/_core/power_grid_meta.py +257 -243
- power_grid_model/_core/power_grid_model.py +969 -686
- power_grid_model/_core/power_grid_model_c/__init__.py +3 -3
- power_grid_model/_core/power_grid_model_c/bin/power_grid_model_c.dll +0 -0
- power_grid_model/_core/power_grid_model_c/get_pgm_dll_path.py +63 -63
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/basics.h +255 -255
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/buffer.h +108 -108
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset.h +316 -316
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h +1052 -1052
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/handle.h +99 -99
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/meta_data.h +189 -189
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/model.h +125 -125
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/options.h +142 -142
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/serialization.h +118 -118
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c.h +36 -36
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/basics.hpp +65 -65
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/buffer.hpp +61 -61
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/dataset.hpp +220 -220
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/handle.hpp +108 -108
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/meta_data.hpp +84 -84
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/model.hpp +63 -63
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/options.hpp +52 -52
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/serialization.hpp +124 -124
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/utils.hpp +81 -81
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp.hpp +19 -19
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfigVersion.cmake +3 -3
- power_grid_model/_core/power_grid_model_c/lib/power_grid_model_c.lib +0 -0
- power_grid_model/_core/serialization.py +317 -317
- power_grid_model/_core/typing.py +20 -20
- power_grid_model/_core/utils.py +798 -793
- power_grid_model/data_types.py +321 -321
- power_grid_model/enum.py +27 -27
- power_grid_model/errors.py +37 -37
- power_grid_model/typing.py +43 -43
- power_grid_model/utils.py +473 -469
- power_grid_model/validation/__init__.py +25 -25
- power_grid_model/validation/_rules.py +1171 -1176
- power_grid_model/validation/_validation.py +1172 -1172
- power_grid_model/validation/assertions.py +93 -93
- power_grid_model/validation/errors.py +602 -602
- power_grid_model/validation/utils.py +313 -314
- {power_grid_model-1.11.48.dist-info → power_grid_model-1.12.72.dist-info}/METADATA +4 -2
- power_grid_model-1.12.72.dist-info/RECORD +65 -0
- {power_grid_model-1.11.48.dist-info → power_grid_model-1.12.72.dist-info}/WHEEL +1 -1
- power_grid_model-1.11.48.dist-info/RECORD +0 -65
- {power_grid_model-1.11.48.dist-info → power_grid_model-1.12.72.dist-info}/entry_points.txt +0 -0
- {power_grid_model-1.11.48.dist-info → power_grid_model-1.12.72.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
|
|
5
|
-
#pragma once
|
|
6
|
-
#ifndef POWER_GRID_MODEL_CPP_META_DATA_HPP
|
|
7
|
-
#define POWER_GRID_MODEL_CPP_META_DATA_HPP
|
|
8
|
-
|
|
9
|
-
#include "basics.hpp"
|
|
10
|
-
#include "handle.hpp"
|
|
11
|
-
|
|
12
|
-
#include "power_grid_model_c/meta_data.h"
|
|
13
|
-
|
|
14
|
-
namespace power_grid_model_cpp {
|
|
15
|
-
class MetaData {
|
|
16
|
-
public:
|
|
17
|
-
static Idx n_datasets() { return PGM_meta_n_datasets(nullptr); }
|
|
18
|
-
|
|
19
|
-
static MetaDataset const* get_dataset_by_idx(Idx idx) {
|
|
20
|
-
Handle const handle{};
|
|
21
|
-
return handle.call_with(PGM_meta_get_dataset_by_idx, idx);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static MetaDataset const* get_dataset_by_name(std::string const& dataset) {
|
|
25
|
-
Handle const handle{};
|
|
26
|
-
return handle.call_with(PGM_meta_get_dataset_by_name, dataset.c_str());
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static std::string dataset_name(MetaDataset const* dataset) {
|
|
30
|
-
return std::string{PGM_meta_dataset_name(nullptr, dataset)};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static Idx n_components(MetaDataset const* dataset) { return PGM_meta_n_components(nullptr, dataset); }
|
|
34
|
-
|
|
35
|
-
static MetaComponent const* get_component_by_idx(MetaDataset const* dataset, Idx idx) {
|
|
36
|
-
Handle const handle{};
|
|
37
|
-
return handle.call_with(PGM_meta_get_component_by_idx, dataset, idx);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static MetaComponent const* get_component_by_name(std::string const& dataset, std::string const& component) {
|
|
41
|
-
Handle const handle{};
|
|
42
|
-
return handle.call_with(PGM_meta_get_component_by_name, dataset.c_str(), component.c_str());
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static std::string component_name(MetaComponent const* component) {
|
|
46
|
-
return std::string{PGM_meta_component_name(nullptr, component)};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static size_t component_size(MetaComponent const* component) { return PGM_meta_component_size(nullptr, component); }
|
|
50
|
-
|
|
51
|
-
static size_t component_alignment(MetaComponent const* component) {
|
|
52
|
-
return PGM_meta_component_alignment(nullptr, component);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static Idx n_attributes(MetaComponent const* component) { return PGM_meta_n_attributes(nullptr, component); }
|
|
56
|
-
|
|
57
|
-
static MetaAttribute const* get_attribute_by_idx(MetaComponent const* component, Idx idx) {
|
|
58
|
-
Handle const handle{};
|
|
59
|
-
return handle.call_with(PGM_meta_get_attribute_by_idx, component, idx);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static MetaAttribute const* get_attribute_by_name(std::string const& dataset, std::string const& component,
|
|
63
|
-
std::string const& attribute) {
|
|
64
|
-
Handle const handle{};
|
|
65
|
-
return handle.call_with(PGM_meta_get_attribute_by_name, dataset.c_str(), component.c_str(), attribute.c_str());
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
static std::string attribute_name(MetaAttribute const* attribute) {
|
|
69
|
-
return std::string{PGM_meta_attribute_name(nullptr, attribute)};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
static PGM_CType attribute_ctype(MetaAttribute const* attribute) {
|
|
73
|
-
return static_cast<PGM_CType>(PGM_meta_attribute_ctype(nullptr, attribute));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static size_t attribute_offset(MetaAttribute const* attribute) {
|
|
77
|
-
return PGM_meta_attribute_offset(nullptr, attribute);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static int is_little_endian() { return PGM_is_little_endian(nullptr); }
|
|
81
|
-
};
|
|
82
|
-
} // namespace power_grid_model_cpp
|
|
83
|
-
|
|
84
|
-
#endif // POWER_GRID_MODEL_CPP_META_DATA_HPP
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
#ifndef POWER_GRID_MODEL_CPP_META_DATA_HPP
|
|
7
|
+
#define POWER_GRID_MODEL_CPP_META_DATA_HPP
|
|
8
|
+
|
|
9
|
+
#include "basics.hpp"
|
|
10
|
+
#include "handle.hpp"
|
|
11
|
+
|
|
12
|
+
#include "power_grid_model_c/meta_data.h"
|
|
13
|
+
|
|
14
|
+
namespace power_grid_model_cpp {
|
|
15
|
+
class MetaData {
|
|
16
|
+
public:
|
|
17
|
+
static Idx n_datasets() { return PGM_meta_n_datasets(nullptr); }
|
|
18
|
+
|
|
19
|
+
static MetaDataset const* get_dataset_by_idx(Idx idx) {
|
|
20
|
+
Handle const handle{};
|
|
21
|
+
return handle.call_with(PGM_meta_get_dataset_by_idx, idx);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static MetaDataset const* get_dataset_by_name(std::string const& dataset) {
|
|
25
|
+
Handle const handle{};
|
|
26
|
+
return handle.call_with(PGM_meta_get_dataset_by_name, dataset.c_str());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static std::string dataset_name(MetaDataset const* dataset) {
|
|
30
|
+
return std::string{PGM_meta_dataset_name(nullptr, dataset)};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static Idx n_components(MetaDataset const* dataset) { return PGM_meta_n_components(nullptr, dataset); }
|
|
34
|
+
|
|
35
|
+
static MetaComponent const* get_component_by_idx(MetaDataset const* dataset, Idx idx) {
|
|
36
|
+
Handle const handle{};
|
|
37
|
+
return handle.call_with(PGM_meta_get_component_by_idx, dataset, idx);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static MetaComponent const* get_component_by_name(std::string const& dataset, std::string const& component) {
|
|
41
|
+
Handle const handle{};
|
|
42
|
+
return handle.call_with(PGM_meta_get_component_by_name, dataset.c_str(), component.c_str());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static std::string component_name(MetaComponent const* component) {
|
|
46
|
+
return std::string{PGM_meta_component_name(nullptr, component)};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static size_t component_size(MetaComponent const* component) { return PGM_meta_component_size(nullptr, component); }
|
|
50
|
+
|
|
51
|
+
static size_t component_alignment(MetaComponent const* component) {
|
|
52
|
+
return PGM_meta_component_alignment(nullptr, component);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static Idx n_attributes(MetaComponent const* component) { return PGM_meta_n_attributes(nullptr, component); }
|
|
56
|
+
|
|
57
|
+
static MetaAttribute const* get_attribute_by_idx(MetaComponent const* component, Idx idx) {
|
|
58
|
+
Handle const handle{};
|
|
59
|
+
return handle.call_with(PGM_meta_get_attribute_by_idx, component, idx);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static MetaAttribute const* get_attribute_by_name(std::string const& dataset, std::string const& component,
|
|
63
|
+
std::string const& attribute) {
|
|
64
|
+
Handle const handle{};
|
|
65
|
+
return handle.call_with(PGM_meta_get_attribute_by_name, dataset.c_str(), component.c_str(), attribute.c_str());
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static std::string attribute_name(MetaAttribute const* attribute) {
|
|
69
|
+
return std::string{PGM_meta_attribute_name(nullptr, attribute)};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static PGM_CType attribute_ctype(MetaAttribute const* attribute) {
|
|
73
|
+
return static_cast<PGM_CType>(PGM_meta_attribute_ctype(nullptr, attribute));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static size_t attribute_offset(MetaAttribute const* attribute) {
|
|
77
|
+
return PGM_meta_attribute_offset(nullptr, attribute);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static int is_little_endian() { return PGM_is_little_endian(nullptr); }
|
|
81
|
+
};
|
|
82
|
+
} // namespace power_grid_model_cpp
|
|
83
|
+
|
|
84
|
+
#endif // POWER_GRID_MODEL_CPP_META_DATA_HPP
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
|
|
5
|
-
#pragma once
|
|
6
|
-
#ifndef POWER_GRID_MODEL_CPP_MODEL_HPP
|
|
7
|
-
#define POWER_GRID_MODEL_CPP_MODEL_HPP
|
|
8
|
-
|
|
9
|
-
#include "basics.hpp"
|
|
10
|
-
#include "dataset.hpp"
|
|
11
|
-
#include "handle.hpp"
|
|
12
|
-
#include "options.hpp"
|
|
13
|
-
|
|
14
|
-
#include "power_grid_model_c/model.h"
|
|
15
|
-
|
|
16
|
-
namespace power_grid_model_cpp {
|
|
17
|
-
class Model {
|
|
18
|
-
public:
|
|
19
|
-
Model(double system_frequency, DatasetConst const& input_dataset)
|
|
20
|
-
: model_{handle_.call_with(PGM_create_model, system_frequency, input_dataset.get())} {}
|
|
21
|
-
Model(Model const& other) : model_{handle_.call_with(PGM_copy_model, other.get())} {}
|
|
22
|
-
Model& operator=(Model const& other) {
|
|
23
|
-
if (this != &other) {
|
|
24
|
-
model_.reset(handle_.call_with(PGM_copy_model, other.get()));
|
|
25
|
-
}
|
|
26
|
-
return *this;
|
|
27
|
-
}
|
|
28
|
-
Model(Model&& other) noexcept : handle_{std::move(other.handle_)}, model_{std::move(other.model_)} {}
|
|
29
|
-
Model& operator=(Model&& other) noexcept {
|
|
30
|
-
if (this != &other) {
|
|
31
|
-
handle_ = std::move(other.handle_);
|
|
32
|
-
model_ = std::move(other.model_);
|
|
33
|
-
}
|
|
34
|
-
return *this;
|
|
35
|
-
}
|
|
36
|
-
~Model() = default;
|
|
37
|
-
|
|
38
|
-
PowerGridModel const* get() const { return model_.get(); }
|
|
39
|
-
PowerGridModel* get() { return model_.get(); }
|
|
40
|
-
|
|
41
|
-
void update(DatasetConst const& update_dataset) {
|
|
42
|
-
handle_.call_with(PGM_update_model, get(), update_dataset.get());
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
void get_indexer(std::string const& component, Idx size, ID const* ids, Idx* indexer) const {
|
|
46
|
-
handle_.call_with(PGM_get_indexer, get(), component.c_str(), size, ids, indexer);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
void calculate(Options const& opt, DatasetMutable const& output_dataset, DatasetConst const& batch_dataset) {
|
|
50
|
-
handle_.call_with(PGM_calculate, get(), opt.get(), output_dataset.get(), batch_dataset.get());
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
void calculate(Options const& opt, DatasetMutable const& output_dataset) {
|
|
54
|
-
handle_.call_with(PGM_calculate, get(), opt.get(), output_dataset.get(), nullptr);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private:
|
|
58
|
-
Handle handle_{};
|
|
59
|
-
detail::UniquePtr<PowerGridModel, &PGM_destroy_model> model_;
|
|
60
|
-
};
|
|
61
|
-
} // namespace power_grid_model_cpp
|
|
62
|
-
|
|
63
|
-
#endif // POWER_GRID_MODEL_CPP_MODEL_HPP
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
#ifndef POWER_GRID_MODEL_CPP_MODEL_HPP
|
|
7
|
+
#define POWER_GRID_MODEL_CPP_MODEL_HPP
|
|
8
|
+
|
|
9
|
+
#include "basics.hpp"
|
|
10
|
+
#include "dataset.hpp"
|
|
11
|
+
#include "handle.hpp"
|
|
12
|
+
#include "options.hpp"
|
|
13
|
+
|
|
14
|
+
#include "power_grid_model_c/model.h"
|
|
15
|
+
|
|
16
|
+
namespace power_grid_model_cpp {
|
|
17
|
+
class Model {
|
|
18
|
+
public:
|
|
19
|
+
Model(double system_frequency, DatasetConst const& input_dataset)
|
|
20
|
+
: model_{handle_.call_with(PGM_create_model, system_frequency, input_dataset.get())} {}
|
|
21
|
+
Model(Model const& other) : model_{handle_.call_with(PGM_copy_model, other.get())} {}
|
|
22
|
+
Model& operator=(Model const& other) {
|
|
23
|
+
if (this != &other) {
|
|
24
|
+
model_.reset(handle_.call_with(PGM_copy_model, other.get()));
|
|
25
|
+
}
|
|
26
|
+
return *this;
|
|
27
|
+
}
|
|
28
|
+
Model(Model&& other) noexcept : handle_{std::move(other.handle_)}, model_{std::move(other.model_)} {}
|
|
29
|
+
Model& operator=(Model&& other) noexcept {
|
|
30
|
+
if (this != &other) {
|
|
31
|
+
handle_ = std::move(other.handle_);
|
|
32
|
+
model_ = std::move(other.model_);
|
|
33
|
+
}
|
|
34
|
+
return *this;
|
|
35
|
+
}
|
|
36
|
+
~Model() = default;
|
|
37
|
+
|
|
38
|
+
PowerGridModel const* get() const { return model_.get(); }
|
|
39
|
+
PowerGridModel* get() { return model_.get(); }
|
|
40
|
+
|
|
41
|
+
void update(DatasetConst const& update_dataset) {
|
|
42
|
+
handle_.call_with(PGM_update_model, get(), update_dataset.get());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void get_indexer(std::string const& component, Idx size, ID const* ids, Idx* indexer) const {
|
|
46
|
+
handle_.call_with(PGM_get_indexer, get(), component.c_str(), size, ids, indexer);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void calculate(Options const& opt, DatasetMutable const& output_dataset, DatasetConst const& batch_dataset) {
|
|
50
|
+
handle_.call_with(PGM_calculate, get(), opt.get(), output_dataset.get(), batch_dataset.get());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void calculate(Options const& opt, DatasetMutable const& output_dataset) {
|
|
54
|
+
handle_.call_with(PGM_calculate, get(), opt.get(), output_dataset.get(), nullptr);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private:
|
|
58
|
+
Handle handle_{};
|
|
59
|
+
detail::UniquePtr<PowerGridModel, &PGM_destroy_model> model_;
|
|
60
|
+
};
|
|
61
|
+
} // namespace power_grid_model_cpp
|
|
62
|
+
|
|
63
|
+
#endif // POWER_GRID_MODEL_CPP_MODEL_HPP
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
|
|
5
|
-
#pragma once
|
|
6
|
-
#ifndef POWER_GRID_MODEL_CPP_OPTIONS_HPP
|
|
7
|
-
#define POWER_GRID_MODEL_CPP_OPTIONS_HPP
|
|
8
|
-
|
|
9
|
-
#include "basics.hpp"
|
|
10
|
-
#include "handle.hpp"
|
|
11
|
-
|
|
12
|
-
#include "power_grid_model_c/options.h"
|
|
13
|
-
|
|
14
|
-
namespace power_grid_model_cpp {
|
|
15
|
-
class Options {
|
|
16
|
-
public:
|
|
17
|
-
Options() : options_{handle_.call_with(PGM_create_options)} {}
|
|
18
|
-
|
|
19
|
-
RawOptions* get() { return options_.get(); }
|
|
20
|
-
RawOptions const* get() const { return options_.get(); }
|
|
21
|
-
|
|
22
|
-
void set_calculation_type(Idx type) { handle_.call_with(PGM_set_calculation_type, get(), type); }
|
|
23
|
-
|
|
24
|
-
void set_calculation_method(Idx method) { handle_.call_with(PGM_set_calculation_method, get(), method); }
|
|
25
|
-
|
|
26
|
-
void set_symmetric(Idx sym) { handle_.call_with(PGM_set_symmetric, get(), sym); }
|
|
27
|
-
|
|
28
|
-
void set_err_tol(double err_tol) { handle_.call_with(PGM_set_err_tol, get(), err_tol); }
|
|
29
|
-
|
|
30
|
-
void set_max_iter(Idx max_iter) { handle_.call_with(PGM_set_max_iter, get(), max_iter); }
|
|
31
|
-
|
|
32
|
-
void set_threading(Idx threading) { handle_.call_with(PGM_set_threading, get(), threading); }
|
|
33
|
-
|
|
34
|
-
void set_short_circuit_voltage_scaling(Idx short_circuit_voltage_scaling) {
|
|
35
|
-
handle_.call_with(PGM_set_short_circuit_voltage_scaling, get(), short_circuit_voltage_scaling);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
void set_tap_changing_strategy(Idx tap_changing_strategy) {
|
|
39
|
-
handle_.call_with(PGM_set_tap_changing_strategy, get(), tap_changing_strategy);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
void set_experimental_features(Idx experimental_features) {
|
|
43
|
-
handle_.call_with(PGM_set_experimental_features, get(), experimental_features);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private:
|
|
47
|
-
Handle handle_{};
|
|
48
|
-
detail::UniquePtr<RawOptions, &PGM_destroy_options> options_;
|
|
49
|
-
};
|
|
50
|
-
} // namespace power_grid_model_cpp
|
|
51
|
-
|
|
52
|
-
#endif // POWER_GRID_MODEL_CPP_OPTIONS_HPP
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
#ifndef POWER_GRID_MODEL_CPP_OPTIONS_HPP
|
|
7
|
+
#define POWER_GRID_MODEL_CPP_OPTIONS_HPP
|
|
8
|
+
|
|
9
|
+
#include "basics.hpp"
|
|
10
|
+
#include "handle.hpp"
|
|
11
|
+
|
|
12
|
+
#include "power_grid_model_c/options.h"
|
|
13
|
+
|
|
14
|
+
namespace power_grid_model_cpp {
|
|
15
|
+
class Options {
|
|
16
|
+
public:
|
|
17
|
+
Options() : options_{handle_.call_with(PGM_create_options)} {}
|
|
18
|
+
|
|
19
|
+
RawOptions* get() { return options_.get(); }
|
|
20
|
+
RawOptions const* get() const { return options_.get(); }
|
|
21
|
+
|
|
22
|
+
void set_calculation_type(Idx type) { handle_.call_with(PGM_set_calculation_type, get(), type); }
|
|
23
|
+
|
|
24
|
+
void set_calculation_method(Idx method) { handle_.call_with(PGM_set_calculation_method, get(), method); }
|
|
25
|
+
|
|
26
|
+
void set_symmetric(Idx sym) { handle_.call_with(PGM_set_symmetric, get(), sym); }
|
|
27
|
+
|
|
28
|
+
void set_err_tol(double err_tol) { handle_.call_with(PGM_set_err_tol, get(), err_tol); }
|
|
29
|
+
|
|
30
|
+
void set_max_iter(Idx max_iter) { handle_.call_with(PGM_set_max_iter, get(), max_iter); }
|
|
31
|
+
|
|
32
|
+
void set_threading(Idx threading) { handle_.call_with(PGM_set_threading, get(), threading); }
|
|
33
|
+
|
|
34
|
+
void set_short_circuit_voltage_scaling(Idx short_circuit_voltage_scaling) {
|
|
35
|
+
handle_.call_with(PGM_set_short_circuit_voltage_scaling, get(), short_circuit_voltage_scaling);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
void set_tap_changing_strategy(Idx tap_changing_strategy) {
|
|
39
|
+
handle_.call_with(PGM_set_tap_changing_strategy, get(), tap_changing_strategy);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void set_experimental_features(Idx experimental_features) {
|
|
43
|
+
handle_.call_with(PGM_set_experimental_features, get(), experimental_features);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private:
|
|
47
|
+
Handle handle_{};
|
|
48
|
+
detail::UniquePtr<RawOptions, &PGM_destroy_options> options_;
|
|
49
|
+
};
|
|
50
|
+
} // namespace power_grid_model_cpp
|
|
51
|
+
|
|
52
|
+
#endif // POWER_GRID_MODEL_CPP_OPTIONS_HPP
|
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
|
|
5
|
-
#pragma once
|
|
6
|
-
#ifndef POWER_GRID_MODEL_CPP_SERIALIZATION_HPP
|
|
7
|
-
#define POWER_GRID_MODEL_CPP_SERIALIZATION_HPP
|
|
8
|
-
|
|
9
|
-
#include "basics.hpp"
|
|
10
|
-
#include "dataset.hpp"
|
|
11
|
-
#include "handle.hpp"
|
|
12
|
-
#include "meta_data.hpp"
|
|
13
|
-
|
|
14
|
-
#include "power_grid_model_c/serialization.h"
|
|
15
|
-
|
|
16
|
-
#include <cstring>
|
|
17
|
-
|
|
18
|
-
namespace power_grid_model_cpp {
|
|
19
|
-
class Deserializer {
|
|
20
|
-
public:
|
|
21
|
-
Deserializer(std::vector<std::byte> const& data, Idx serialization_format)
|
|
22
|
-
: deserializer_{handle_.call_with(PGM_create_deserializer_from_binary_buffer,
|
|
23
|
-
reinterpret_cast<const char*>(data.data()), static_cast<Idx>(data.size()),
|
|
24
|
-
serialization_format)},
|
|
25
|
-
dataset_{handle_.call_with(PGM_deserializer_get_dataset, get())} {}
|
|
26
|
-
Deserializer(std::vector<char> const& data, Idx serialization_format)
|
|
27
|
-
: deserializer_{handle_.call_with(PGM_create_deserializer_from_binary_buffer, data.data(),
|
|
28
|
-
static_cast<Idx>(data.size()), serialization_format)},
|
|
29
|
-
dataset_{handle_.call_with(PGM_deserializer_get_dataset, get())} {}
|
|
30
|
-
Deserializer(std::string const& data_string, Idx serialization_format)
|
|
31
|
-
: deserializer_{handle_.call_with(PGM_create_deserializer_from_null_terminated_string, data_string.c_str(),
|
|
32
|
-
serialization_format)},
|
|
33
|
-
dataset_{handle_.call_with(PGM_deserializer_get_dataset, get())} {}
|
|
34
|
-
|
|
35
|
-
RawDeserializer* get() { return deserializer_.get(); }
|
|
36
|
-
RawDeserializer const* get() const { return deserializer_.get(); }
|
|
37
|
-
|
|
38
|
-
DatasetWritable& get_dataset() { return dataset_; }
|
|
39
|
-
|
|
40
|
-
void parse_to_buffer() { handle_.call_with(PGM_deserializer_parse_to_buffer, get()); }
|
|
41
|
-
|
|
42
|
-
private:
|
|
43
|
-
Handle handle_{};
|
|
44
|
-
detail::UniquePtr<RawDeserializer, &PGM_destroy_deserializer> deserializer_;
|
|
45
|
-
DatasetWritable dataset_;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
class Serializer {
|
|
49
|
-
public:
|
|
50
|
-
Serializer(DatasetConst const& dataset, Idx serialization_format)
|
|
51
|
-
: serializer_{handle_.call_with(PGM_create_serializer, dataset.get(), serialization_format)} {}
|
|
52
|
-
|
|
53
|
-
RawSerializer* get() { return serializer_.get(); }
|
|
54
|
-
RawSerializer const* get() const { return serializer_.get(); }
|
|
55
|
-
|
|
56
|
-
std::string_view get_to_binary_buffer(Idx use_compact_list) {
|
|
57
|
-
char const* temp_data{};
|
|
58
|
-
Idx buffer_size{};
|
|
59
|
-
handle_.call_with(PGM_serializer_get_to_binary_buffer, get(), use_compact_list, &temp_data, &buffer_size);
|
|
60
|
-
if (temp_data == nullptr) {
|
|
61
|
-
return std::string_view{};
|
|
62
|
-
} // empty data
|
|
63
|
-
return std::string_view{temp_data, static_cast<size_t>(buffer_size)};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
void get_to_binary_buffer(Idx use_compact_list, std::vector<std::byte>& data) {
|
|
67
|
-
auto temp_data = get_to_binary_buffer(use_compact_list);
|
|
68
|
-
if (!temp_data.empty()) {
|
|
69
|
-
data.resize(temp_data.size());
|
|
70
|
-
std::memcpy(data.data(), temp_data.data(), temp_data.size());
|
|
71
|
-
} else {
|
|
72
|
-
data.resize(0); // empty data
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
void get_to_binary_buffer(Idx use_compact_list, std::vector<char>& data) {
|
|
77
|
-
auto temp_data = get_to_binary_buffer(use_compact_list);
|
|
78
|
-
if (!temp_data.empty()) {
|
|
79
|
-
data.assign(temp_data.begin(), temp_data.end());
|
|
80
|
-
} else {
|
|
81
|
-
data.resize(0); // empty data
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
std::string get_to_zero_terminated_string(Idx use_compact_list, Idx indent) {
|
|
86
|
-
return std::string{
|
|
87
|
-
handle_.call_with(PGM_serializer_get_to_zero_terminated_string, get(), use_compact_list, indent)};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private:
|
|
91
|
-
power_grid_model_cpp::Handle handle_{};
|
|
92
|
-
detail::UniquePtr<RawSerializer, &PGM_destroy_serializer> serializer_;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
inline OwningDataset create_owning_dataset(DatasetWritable& writable_dataset) {
|
|
96
|
-
auto const& info = writable_dataset.get_info();
|
|
97
|
-
bool const is_batch = info.is_batch();
|
|
98
|
-
Idx const batch_size = info.batch_size();
|
|
99
|
-
auto const& dataset_name = info.name();
|
|
100
|
-
DatasetMutable dataset_mutable{dataset_name, is_batch, batch_size};
|
|
101
|
-
OwningMemory storage{};
|
|
102
|
-
|
|
103
|
-
for (Idx component_idx{}; component_idx < info.n_components(); ++component_idx) {
|
|
104
|
-
auto const& component_name = info.component_name(component_idx);
|
|
105
|
-
auto const& component_meta = MetaData::get_component_by_name(dataset_name, component_name);
|
|
106
|
-
Idx const component_size = info.component_total_elements(component_idx);
|
|
107
|
-
Idx const elements_per_scenario = info.component_elements_per_scenario(component_idx);
|
|
108
|
-
|
|
109
|
-
auto& current_indptr = storage.indptrs.emplace_back(elements_per_scenario < 0 ? batch_size + 1 : 0);
|
|
110
|
-
if (!current_indptr.empty()) {
|
|
111
|
-
current_indptr.at(0) = 0;
|
|
112
|
-
current_indptr.at(batch_size) = component_size;
|
|
113
|
-
}
|
|
114
|
-
Idx* const indptr = current_indptr.empty() ? nullptr : current_indptr.data();
|
|
115
|
-
auto& current_buffer = storage.buffers.emplace_back(component_meta, component_size);
|
|
116
|
-
writable_dataset.set_buffer(component_name, indptr, current_buffer);
|
|
117
|
-
dataset_mutable.add_buffer(component_name, elements_per_scenario, component_size, indptr, current_buffer);
|
|
118
|
-
}
|
|
119
|
-
return OwningDataset{// NOLINT(modernize-use-designated-initializers)
|
|
120
|
-
std::move(dataset_mutable), std::move(storage)};
|
|
121
|
-
}
|
|
122
|
-
} // namespace power_grid_model_cpp
|
|
123
|
-
|
|
124
|
-
#endif // POWER_GRID_MODEL_CPP_SERIALIZATION_HPP
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
#ifndef POWER_GRID_MODEL_CPP_SERIALIZATION_HPP
|
|
7
|
+
#define POWER_GRID_MODEL_CPP_SERIALIZATION_HPP
|
|
8
|
+
|
|
9
|
+
#include "basics.hpp"
|
|
10
|
+
#include "dataset.hpp"
|
|
11
|
+
#include "handle.hpp"
|
|
12
|
+
#include "meta_data.hpp"
|
|
13
|
+
|
|
14
|
+
#include "power_grid_model_c/serialization.h"
|
|
15
|
+
|
|
16
|
+
#include <cstring>
|
|
17
|
+
|
|
18
|
+
namespace power_grid_model_cpp {
|
|
19
|
+
class Deserializer {
|
|
20
|
+
public:
|
|
21
|
+
Deserializer(std::vector<std::byte> const& data, Idx serialization_format)
|
|
22
|
+
: deserializer_{handle_.call_with(PGM_create_deserializer_from_binary_buffer,
|
|
23
|
+
reinterpret_cast<const char*>(data.data()), static_cast<Idx>(data.size()),
|
|
24
|
+
serialization_format)},
|
|
25
|
+
dataset_{handle_.call_with(PGM_deserializer_get_dataset, get())} {}
|
|
26
|
+
Deserializer(std::vector<char> const& data, Idx serialization_format)
|
|
27
|
+
: deserializer_{handle_.call_with(PGM_create_deserializer_from_binary_buffer, data.data(),
|
|
28
|
+
static_cast<Idx>(data.size()), serialization_format)},
|
|
29
|
+
dataset_{handle_.call_with(PGM_deserializer_get_dataset, get())} {}
|
|
30
|
+
Deserializer(std::string const& data_string, Idx serialization_format)
|
|
31
|
+
: deserializer_{handle_.call_with(PGM_create_deserializer_from_null_terminated_string, data_string.c_str(),
|
|
32
|
+
serialization_format)},
|
|
33
|
+
dataset_{handle_.call_with(PGM_deserializer_get_dataset, get())} {}
|
|
34
|
+
|
|
35
|
+
RawDeserializer* get() { return deserializer_.get(); }
|
|
36
|
+
RawDeserializer const* get() const { return deserializer_.get(); }
|
|
37
|
+
|
|
38
|
+
DatasetWritable& get_dataset() { return dataset_; }
|
|
39
|
+
|
|
40
|
+
void parse_to_buffer() { handle_.call_with(PGM_deserializer_parse_to_buffer, get()); }
|
|
41
|
+
|
|
42
|
+
private:
|
|
43
|
+
Handle handle_{};
|
|
44
|
+
detail::UniquePtr<RawDeserializer, &PGM_destroy_deserializer> deserializer_;
|
|
45
|
+
DatasetWritable dataset_;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
class Serializer {
|
|
49
|
+
public:
|
|
50
|
+
Serializer(DatasetConst const& dataset, Idx serialization_format)
|
|
51
|
+
: serializer_{handle_.call_with(PGM_create_serializer, dataset.get(), serialization_format)} {}
|
|
52
|
+
|
|
53
|
+
RawSerializer* get() { return serializer_.get(); }
|
|
54
|
+
RawSerializer const* get() const { return serializer_.get(); }
|
|
55
|
+
|
|
56
|
+
std::string_view get_to_binary_buffer(Idx use_compact_list) {
|
|
57
|
+
char const* temp_data{};
|
|
58
|
+
Idx buffer_size{};
|
|
59
|
+
handle_.call_with(PGM_serializer_get_to_binary_buffer, get(), use_compact_list, &temp_data, &buffer_size);
|
|
60
|
+
if (temp_data == nullptr) {
|
|
61
|
+
return std::string_view{};
|
|
62
|
+
} // empty data
|
|
63
|
+
return std::string_view{temp_data, static_cast<size_t>(buffer_size)};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void get_to_binary_buffer(Idx use_compact_list, std::vector<std::byte>& data) {
|
|
67
|
+
auto temp_data = get_to_binary_buffer(use_compact_list);
|
|
68
|
+
if (!temp_data.empty()) {
|
|
69
|
+
data.resize(temp_data.size());
|
|
70
|
+
std::memcpy(data.data(), temp_data.data(), temp_data.size());
|
|
71
|
+
} else {
|
|
72
|
+
data.resize(0); // empty data
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void get_to_binary_buffer(Idx use_compact_list, std::vector<char>& data) {
|
|
77
|
+
auto temp_data = get_to_binary_buffer(use_compact_list);
|
|
78
|
+
if (!temp_data.empty()) {
|
|
79
|
+
data.assign(temp_data.begin(), temp_data.end());
|
|
80
|
+
} else {
|
|
81
|
+
data.resize(0); // empty data
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
std::string get_to_zero_terminated_string(Idx use_compact_list, Idx indent) {
|
|
86
|
+
return std::string{
|
|
87
|
+
handle_.call_with(PGM_serializer_get_to_zero_terminated_string, get(), use_compact_list, indent)};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private:
|
|
91
|
+
power_grid_model_cpp::Handle handle_{};
|
|
92
|
+
detail::UniquePtr<RawSerializer, &PGM_destroy_serializer> serializer_;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
inline OwningDataset create_owning_dataset(DatasetWritable& writable_dataset) {
|
|
96
|
+
auto const& info = writable_dataset.get_info();
|
|
97
|
+
bool const is_batch = info.is_batch();
|
|
98
|
+
Idx const batch_size = info.batch_size();
|
|
99
|
+
auto const& dataset_name = info.name();
|
|
100
|
+
DatasetMutable dataset_mutable{dataset_name, is_batch, batch_size};
|
|
101
|
+
OwningMemory storage{};
|
|
102
|
+
|
|
103
|
+
for (Idx component_idx{}; component_idx < info.n_components(); ++component_idx) {
|
|
104
|
+
auto const& component_name = info.component_name(component_idx);
|
|
105
|
+
auto const& component_meta = MetaData::get_component_by_name(dataset_name, component_name);
|
|
106
|
+
Idx const component_size = info.component_total_elements(component_idx);
|
|
107
|
+
Idx const elements_per_scenario = info.component_elements_per_scenario(component_idx);
|
|
108
|
+
|
|
109
|
+
auto& current_indptr = storage.indptrs.emplace_back(elements_per_scenario < 0 ? batch_size + 1 : 0);
|
|
110
|
+
if (!current_indptr.empty()) {
|
|
111
|
+
current_indptr.at(0) = 0;
|
|
112
|
+
current_indptr.at(batch_size) = component_size;
|
|
113
|
+
}
|
|
114
|
+
Idx* const indptr = current_indptr.empty() ? nullptr : current_indptr.data();
|
|
115
|
+
auto& current_buffer = storage.buffers.emplace_back(component_meta, component_size);
|
|
116
|
+
writable_dataset.set_buffer(component_name, indptr, current_buffer);
|
|
117
|
+
dataset_mutable.add_buffer(component_name, elements_per_scenario, component_size, indptr, current_buffer);
|
|
118
|
+
}
|
|
119
|
+
return OwningDataset{// NOLINT(modernize-use-designated-initializers)
|
|
120
|
+
std::move(dataset_mutable), std::move(storage)};
|
|
121
|
+
}
|
|
122
|
+
} // namespace power_grid_model_cpp
|
|
123
|
+
|
|
124
|
+
#endif // POWER_GRID_MODEL_CPP_SERIALIZATION_HPP
|