Antares Xpansion
Investment simulations for Antares studies
Loading...
Searching...
No Matches
WeightsFileReader.h
1#ifndef SRC_CPP_LPNAMER_INPUTREADER_WEIGHTSFILEREADER_H
2#define SRC_CPP_LPNAMER_INPUTREADER_WEIGHTSFILEREADER_H
3#include <filesystem>
4#include <stdexcept>
5#include <vector>
6
7#include "antares-xpansion/xpansion_interfaces/LogUtils.h"
8#include "antares-xpansion/lpnamer/helper/ProblemGenerationLogger.h"
9
11 private:
12 std::filesystem::path weights_file_path_;
13 size_t number_of_active_years_;
14 std::shared_ptr<ProblemGenerationLog::ProblemGenerationLogger> logger_;
15 bool null_weights = true;
16 std::vector<double> weights_list_;
17
18 int CountValues() const;
19 bool AreAllWeightsNull() const;
20 double GetWeightFromLine(const std::string& line, int idx) const;
21 void CheckValue(const double line, int idx);
22 void CheckFileIsNotEmpty(std::ifstream& file) const;
23
24 public:
25 explicit WeightsFileReader(
26 const std::filesystem::path& weights_file_path,
27 const size_t number_of_active_years,
28 std::shared_ptr<ProblemGenerationLog::ProblemGenerationLogger> logger)
29 : weights_file_path_(weights_file_path),
30 number_of_active_years_(number_of_active_years),
31 logger_(logger) {}
32 class WeightsFileError : public LogUtils::XpansionError<std::runtime_error> {
33 using LogUtils::XpansionError<std::runtime_error>::XpansionError;
34 };
36 using WeightsFileError::WeightsFileError;
37 };
39 using WeightsFileError::WeightsFileError;
40 };
42 using WeightsFileError::WeightsFileError;
43 };
45 using WeightsFileError::WeightsFileError;
46 };
48 using WeightsFileError::WeightsFileError;
49 };
50
53 // column of non-negative weights
54 // sum of weights is positive
55 // nb_weight equal nb_active_yearse
57 bool CheckWeightsFile();
58 std::vector<double> WeightsList() const { return weights_list_; }
59};
60#endif // SRC_CPP_LPNAMER_INPUTREADER_WEIGHTSFILEREADER_H
Definition WeightsFileReader.h:41
Definition WeightsFileReader.h:38
Definition WeightsFileReader.h:44
Definition WeightsFileReader.h:32
Definition WeightsFileReader.h:47
Definition WeightsFileReader.h:35
Definition WeightsFileReader.h:10
bool CheckWeightsFile()
checks that the yearly-weights file exists and has correct format:
Definition WeightsFileReader.cpp:9