fixed memory leak
This commit is contained in:
@ -24,6 +24,12 @@ add_executable(Sim_C__
|
||||
src/config.h
|
||||
src/services/Cost/NetworkProvider.cpp
|
||||
src/services/Cost/NetworkProvider.h
|
||||
src/services/Cost/CalculateFinalSums.cpp
|
||||
src/services/Cost/CalculateFinalSums.h
|
||||
src/services/Cost/GridCost/MeasurementServiceFee.cpp
|
||||
src/services/Cost/GridCost/MeasurementServiceFee.h
|
||||
src/services/Cost/GridCost/NetUsagePerformance.cpp
|
||||
src/services/Cost/GridCost/NetUsagePerformance.h
|
||||
src/services/Cost/BillCharge.cpp
|
||||
src/services/Cost/BillCharge.h
|
||||
src/services/CostHistory.cpp
|
||||
|
||||
@ -6,11 +6,30 @@
|
||||
#include "../Config.h"
|
||||
|
||||
class ICostComponent {
|
||||
protected:
|
||||
enum NET_LEVEL
|
||||
{
|
||||
NetLevel1,
|
||||
NetLevel2,
|
||||
NetLevel3,
|
||||
NetLevel4,
|
||||
NetLevel5,
|
||||
NetLevel6,
|
||||
NetLevel7mp,
|
||||
NetLevel7op,
|
||||
NetLevel7unt
|
||||
};
|
||||
enum MEASUREMENT_TYPE
|
||||
{
|
||||
NIEDER_WANDLERZAEHLER,
|
||||
MITTLE_WANDLERZAEHLER,
|
||||
DREHSTROM_ZEAHLUNG
|
||||
};
|
||||
public:
|
||||
std::bitset<MAX_CONDITIONS> applicableConditions;
|
||||
|
||||
template<typename... Conditions>
|
||||
ICostComponent(Conditions... conditions) {
|
||||
explicit ICostComponent(Conditions... conditions) {
|
||||
}
|
||||
|
||||
virtual ~ICostComponent() = default;
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
|
||||
#include "Building.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
float Building::Metadata::special_rate_consumption() const {
|
||||
return SpecialRateConsumption;
|
||||
}
|
||||
@ -60,6 +62,46 @@ void Building::Metadata::set_generation_net_price(const float value)
|
||||
GenerationNetPrice = value;
|
||||
}
|
||||
|
||||
float Building::Metadata::total_cost_with() const
|
||||
{
|
||||
return TotalCostWith;
|
||||
}
|
||||
|
||||
void Building::Metadata::set_total_cost_with(const float value)
|
||||
{
|
||||
TotalCostWith = value;
|
||||
}
|
||||
|
||||
float Building::Metadata::total_cost_without() const
|
||||
{
|
||||
return TotalCostWithout;
|
||||
}
|
||||
|
||||
void Building::Metadata::set_total_cost_without(const float value)
|
||||
{
|
||||
TotalCostWithout = value;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, float> Building::Metadata::total_by_category_with() const
|
||||
{
|
||||
return TotalByCategoryWith;
|
||||
}
|
||||
|
||||
void Building::Metadata::set_total_by_category_with(std::unordered_map<std::string, float> value)
|
||||
{
|
||||
TotalByCategoryWith = std::move(value);
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, float> Building::Metadata::total_by_category_without() const
|
||||
{
|
||||
return TotalByCategoryWithout;
|
||||
}
|
||||
|
||||
void Building::Metadata::set_total_by_category_without(std::unordered_map<std::string, float> value)
|
||||
{
|
||||
TotalByCategoryWithout = std::move(value);
|
||||
}
|
||||
|
||||
std::vector<float> &Building::Simulation_Values::generation_after_community() {
|
||||
return GenerationAfterCommunity;
|
||||
}
|
||||
|
||||
@ -18,8 +18,8 @@ namespace Building
|
||||
class Cost
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<CostHistory> CostValuesWith{};
|
||||
std::shared_ptr<CostHistory> CostValuesWithOut{};
|
||||
std::shared_ptr<CostHistory> CostValuesWith{std::make_shared<CostHistory>()};
|
||||
std::shared_ptr<CostHistory> CostValuesWithOut{std::make_shared<CostHistory>()};
|
||||
|
||||
public:
|
||||
std::shared_ptr<CostHistory>& get_cost_values_with() { return CostValuesWith; }
|
||||
@ -70,11 +70,11 @@ namespace Building
|
||||
|
||||
void set_needed_gen(std::vector<float> needed_gen);
|
||||
|
||||
float relativeSelfConsumption() const;
|
||||
[[nodiscard]] float relativeSelfConsumption() const;
|
||||
|
||||
void set_relativeSelfConsumption(float relativeSelfConsumption);
|
||||
|
||||
float relativeSelfGeneration() const;
|
||||
[[nodiscard]] float relativeSelfGeneration() const;
|
||||
|
||||
void set_relativeSelfGeneration(float relativeSelfGeneration);
|
||||
|
||||
@ -94,29 +94,29 @@ namespace Building
|
||||
|
||||
void consumption_from_community(const std::vector<float>& consumption_from_community);
|
||||
|
||||
float con_from_community_relative() const;
|
||||
[[nodiscard]] float con_from_community_relative() const;
|
||||
|
||||
void set_con_from_community_relative(float x);
|
||||
|
||||
float gen_to_community_relative() const;
|
||||
[[nodiscard]] float gen_to_community_relative() const;
|
||||
|
||||
void set_gen_to_community_relative(float x);
|
||||
|
||||
float consumption_after_own_coverage_sum() const;
|
||||
[[nodiscard]] float consumption_after_own_coverage_sum() const;
|
||||
void set_consumption_after_own_coverage_sum(float value);
|
||||
float own_usage_sum() const;
|
||||
[[nodiscard]] float own_usage_sum() const;
|
||||
void set_ownUsageSum(float value);
|
||||
float needed_con_sum() const;
|
||||
[[nodiscard]] float needed_con_sum() const;
|
||||
void set_neededConSum(float value);
|
||||
float needed_gen_sum() const;
|
||||
[[nodiscard]] float needed_gen_sum() const;
|
||||
void set_neededGenSum(float value);
|
||||
float consumption_after_community_sum() const;
|
||||
[[nodiscard]] float consumption_after_community_sum() const;
|
||||
void set_consumption_after_community_sum(float value);
|
||||
float generation_after_community_sum() const;
|
||||
[[nodiscard]] float generation_after_community_sum() const;
|
||||
void set_generation_after_community_sum(float value);
|
||||
float consumption_from_community_sum() const;
|
||||
[[nodiscard]] float consumption_from_community_sum() const;
|
||||
void set_consumption_from_community_sum(float value);
|
||||
float generation_to_community_sum() const;
|
||||
[[nodiscard]] float generation_to_community_sum() const;
|
||||
void set_generation_to_community_sum(float values);
|
||||
};
|
||||
|
||||
@ -138,17 +138,21 @@ namespace Building
|
||||
std::string GridOperator;
|
||||
float ConsumptionNetPrice{0.0f};
|
||||
float GenerationNetPrice{0.0f};
|
||||
float TotalCostWith{0.0f};
|
||||
float TotalCostWithout{0.0f};
|
||||
std::unordered_map<std::string, float> TotalByCategoryWith{};
|
||||
std::unordered_map<std::string, float> TotalByCategoryWithout{};
|
||||
|
||||
public:
|
||||
Metadata() = default;
|
||||
|
||||
std::string name() const;
|
||||
[[nodiscard]] std::string name() const;
|
||||
void set_name(const std::string& name);
|
||||
|
||||
float annual_consumption() const;
|
||||
[[nodiscard]] float annual_consumption() const;
|
||||
void set_annual_consumption(float annual_consumption);
|
||||
|
||||
float annual_generation() const;
|
||||
[[nodiscard]] float annual_generation() const;
|
||||
void set_annual_generation(float annual_generation);
|
||||
|
||||
std::vector<float>& consumption_profile();
|
||||
@ -157,43 +161,55 @@ namespace Building
|
||||
std::vector<float>& generation_profile();
|
||||
void set_generation_profile(std::vector<float> generation_profile);
|
||||
|
||||
std::string consumption_profile_name() const;
|
||||
[[nodiscard]] std::string consumption_profile_name() const;
|
||||
void set_consumption_profile_name(const std::string& consumption_profile_name);
|
||||
|
||||
std::string generation_profile_name() const;
|
||||
[[nodiscard]] std::string generation_profile_name() const;
|
||||
void set_generation_profile_name(const std::string& generation_profile_name);
|
||||
|
||||
short connection_power() const;
|
||||
[[nodiscard]] short connection_power() const;
|
||||
void set_connection_power(short connection_power);
|
||||
|
||||
short grid_power() const;
|
||||
[[nodiscard]] short grid_power() const;
|
||||
void set_grid_power(short grid_power);
|
||||
|
||||
float special_rate_consumption() const;
|
||||
[[nodiscard]] float special_rate_consumption() const;
|
||||
void set_special_rate_consumption(float special_rate_consumption);
|
||||
|
||||
float special_rate_generation() const;
|
||||
[[nodiscard]] float special_rate_generation() const;
|
||||
void set_special_rate_generation(float special_rate_generation);
|
||||
|
||||
short grid_level() const;
|
||||
[[nodiscard]] short grid_level() const;
|
||||
void set_grid_level(short value);
|
||||
|
||||
std::string grid_operator();
|
||||
void set_grid_operator(std::string value);
|
||||
|
||||
float consumption_net_price() const;
|
||||
[[nodiscard]] float consumption_net_price() const;
|
||||
void set_consumption_net_price(float value);
|
||||
|
||||
float generation_net_price() const;
|
||||
[[nodiscard]] float generation_net_price() const;
|
||||
void set_generation_net_price(float value);
|
||||
|
||||
[[nodiscard]] float total_cost_with() const;
|
||||
void set_total_cost_with(float value);
|
||||
|
||||
[[nodiscard]] float total_cost_without() const;
|
||||
void set_total_cost_without(float value);
|
||||
|
||||
[[nodiscard]] std::unordered_map<std::string, float> total_by_category_with() const;
|
||||
void set_total_by_category_with(std::unordered_map<std::string, float> value);
|
||||
|
||||
[[nodiscard]] std::unordered_map<std::string, float> total_by_category_without() const;
|
||||
void set_total_by_category_without(std::unordered_map<std::string, float> value);
|
||||
};
|
||||
|
||||
class Base : public Model<Base>
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<Cost> Cost{};
|
||||
std::shared_ptr<Simulation_Values> Values{};
|
||||
std::shared_ptr<Metadata> Metadata{};
|
||||
std::unique_ptr<Cost> Cost{std::make_unique<Building::Cost>()};
|
||||
std::shared_ptr<Simulation_Values> Values{std::make_unique<Building::Simulation_Values>()};
|
||||
std::shared_ptr<Metadata> Metadata{std::make_unique<Building::Metadata>()};
|
||||
|
||||
public:
|
||||
std::unique_ptr<Building::Cost>& cost();
|
||||
|
||||
@ -15,7 +15,9 @@
|
||||
|
||||
class Community : public Model<Community> {
|
||||
public:
|
||||
std::string name() const;
|
||||
float total{0.f};
|
||||
|
||||
[[nodiscard]] std::string name() const;
|
||||
|
||||
void set_name(const std::string &name);
|
||||
|
||||
@ -23,7 +25,7 @@ public:
|
||||
|
||||
void set_buildings(std::vector<std::unique_ptr<Building::Base> > buildings);
|
||||
|
||||
Energy_Tariff energy_tariff() const;
|
||||
[[nodiscard]] Energy_Tariff energy_tariff() const;
|
||||
|
||||
void set_energy_tariff(const Energy_Tariff &energy_tariff);
|
||||
|
||||
@ -39,8 +41,6 @@ public:
|
||||
|
||||
void set_is_gen_bigger_than_con(std::vector<bool> &isGenBiggerThanCon);
|
||||
|
||||
std::bitset<MAX_CONDITIONS> getConditionsBitmask() const;
|
||||
|
||||
static std::function<std::function<void(const std::function<void(Community &, Building::Base &)> &)>(const std::
|
||||
function<void(
|
||||
Community &)> &)>
|
||||
|
||||
@ -8,10 +8,10 @@
|
||||
|
||||
class Energy_Tariff {
|
||||
public:
|
||||
float consumption_tariff{0.0f};
|
||||
float generation_tariff{0.0f};
|
||||
float bill_charge{0.0f};
|
||||
float service_charge{0.0f};
|
||||
float consumption_tariff{1.0f};
|
||||
float generation_tariff{1.0f};
|
||||
float bill_charge{1.0f};
|
||||
float service_charge{1.0f};
|
||||
};
|
||||
|
||||
|
||||
|
||||
18
src/services/Cost/CalculateFinalSums.cpp
Normal file
18
src/services/Cost/CalculateFinalSums.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// Created by stani on 3/13/2025.
|
||||
//
|
||||
|
||||
#include "CalculateFinalSums.h"
|
||||
|
||||
void CalculateFinalSums::apply(std::unique_ptr<Building::Base>& building, std::unique_ptr<Community>& community)
|
||||
{
|
||||
const std::shared_ptr<CostHistory>& valuesWith = building->cost()->get_cost_values_with();
|
||||
const std::shared_ptr<CostHistory>& valuesWithout = building->cost()->get_cost_values_without();
|
||||
const auto& metadata = building->metadata();
|
||||
metadata->set_total_cost_with(valuesWith->total_cost());
|
||||
metadata->set_total_by_category_with(valuesWith->calculateCategories());
|
||||
|
||||
metadata->set_total_cost_without(valuesWithout->total_cost());
|
||||
metadata->set_total_by_category_without(valuesWithout->calculateCategories());
|
||||
community->total = valuesWithout->total_cost();
|
||||
}
|
||||
17
src/services/Cost/CalculateFinalSums.h
Normal file
17
src/services/Cost/CalculateFinalSums.h
Normal file
@ -0,0 +1,17 @@
|
||||
//
|
||||
// Created by stani on 3/13/2025.
|
||||
//
|
||||
|
||||
#ifndef CALCULATEFINALSUMS_H
|
||||
#define CALCULATEFINALSUMS_H
|
||||
#include "../../interfaces/ICostComponent.h"
|
||||
|
||||
|
||||
class CalculateFinalSums : public ICostComponent{
|
||||
public:
|
||||
void apply(std::unique_ptr<Building::Base>& building, std::unique_ptr<Community>& community) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //CALCULATEFINALSUMS_H
|
||||
@ -7,7 +7,6 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "NetworkProvider.h"
|
||||
#include "../../interfaces/ICostComponent.h"
|
||||
#include "../../model/Community.h"
|
||||
|
||||
@ -16,7 +15,7 @@ class CostPipeline {
|
||||
std::vector<std::shared_ptr<ICostComponent> > components;
|
||||
|
||||
public:
|
||||
CostPipeline(std::vector<std::unique_ptr<Community> > &communities) : communities(communities) {
|
||||
explicit CostPipeline(std::vector<std::unique_ptr<Community> > &communities) : communities(communities) {
|
||||
}
|
||||
|
||||
void addCostComponent(const std::shared_ptr<ICostComponent> &components);
|
||||
|
||||
35
src/services/Cost/GridCost/MeasurementServiceFee.cpp
Normal file
35
src/services/Cost/GridCost/MeasurementServiceFee.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// Created by stani on 3/13/2025.
|
||||
//
|
||||
|
||||
#include "MeasurementServiceFee.h"
|
||||
|
||||
void MeasurementServiceFee::apply(std::unique_ptr<Building::Base>& building, std::unique_ptr<Community>& community)
|
||||
{
|
||||
const auto& valuesWith = building->cost()->get_cost_values_with();
|
||||
const auto& valuesWithout = building->cost()->get_cost_values_without();
|
||||
const short grid_level = building->metadata()->grid_level();
|
||||
|
||||
//TODO use actual value
|
||||
float measurement_cost = 1.f;
|
||||
const short measurementType = getMeasurementServiceFeeType(grid_level);
|
||||
|
||||
valuesWith->add_cost_point("Messentgelt",measurement_cost,1.f);
|
||||
valuesWithout->add_cost_point("Messentgelt",measurement_cost,1.f);
|
||||
}
|
||||
|
||||
short MeasurementServiceFee::getMeasurementServiceFeeType(const short grid_level)
|
||||
{
|
||||
switch (grid_level)
|
||||
{
|
||||
case NetLevel6:
|
||||
case NetLevel7mp:
|
||||
return MITTLE_WANDLERZAEHLER;
|
||||
case NetLevel7op:
|
||||
case NetLevel7unt:
|
||||
return DREHSTROM_ZEAHLUNG;
|
||||
default:
|
||||
return NIEDER_WANDLERZAEHLER;
|
||||
}
|
||||
}
|
||||
|
||||
18
src/services/Cost/GridCost/MeasurementServiceFee.h
Normal file
18
src/services/Cost/GridCost/MeasurementServiceFee.h
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// Created by stani on 3/13/2025.
|
||||
//
|
||||
|
||||
#ifndef MEASUREMENTSERVICEFEE_H
|
||||
#define MEASUREMENTSERVICEFEE_H
|
||||
#include "../../../interfaces/ICostComponent.h"
|
||||
|
||||
|
||||
class MeasurementServiceFee : public ICostComponent{
|
||||
public:
|
||||
void apply(std::unique_ptr<Building::Base>& building, std::unique_ptr<Community>& community) override;
|
||||
[[nodiscard]] short getMeasurementServiceFeeType(short grid_level);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //MEASUREMENTSERVICEFEE_H
|
||||
22
src/services/Cost/GridCost/NetUsagePerformance.cpp
Normal file
22
src/services/Cost/GridCost/NetUsagePerformance.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// Created by stani on 3/13/2025.
|
||||
//
|
||||
|
||||
#include "NetUsagePerformance.h"
|
||||
|
||||
void NetUsagePerformance::apply(std::unique_ptr<Building::Base>& building, std::unique_ptr<Community>& community)
|
||||
{
|
||||
const auto& valuesWith = building->cost()->get_cost_values_with();
|
||||
const auto& valuesWithout = building->cost()->get_cost_values_without();
|
||||
const auto& data = building->metadata();
|
||||
float connectionPower = 1;
|
||||
//TODO use actual value
|
||||
float netznutzungLeistungspreis = 1.f;
|
||||
|
||||
if (data->grid_level()!=NetLevel7op)
|
||||
{
|
||||
connectionPower=data->connection_power();
|
||||
}
|
||||
valuesWith->add_cost_point("Netznutzungs Leistungspreis",netznutzungLeistungspreis*connectionPower,1.f);
|
||||
valuesWithout->add_cost_point("Netznutzungs Leistungspreis",netznutzungLeistungspreis*connectionPower,1.f);
|
||||
}
|
||||
17
src/services/Cost/GridCost/NetUsagePerformance.h
Normal file
17
src/services/Cost/GridCost/NetUsagePerformance.h
Normal file
@ -0,0 +1,17 @@
|
||||
//
|
||||
// Created by stani on 3/13/2025.
|
||||
//
|
||||
|
||||
#ifndef NETWORKUSAGEPERFORMANCE_H
|
||||
#define NETWORKUSAGEPERFORMANCE_H
|
||||
#include "../../../interfaces/ICostComponent.h"
|
||||
|
||||
|
||||
class NetUsagePerformance : public ICostComponent{
|
||||
public:
|
||||
void apply(std::unique_ptr<Building::Base>& building, std::unique_ptr<Community>& community) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //NETWORKUSAGEPERFORMANCE_H
|
||||
@ -11,7 +11,7 @@ class TaxComponent : public ICostComponent {
|
||||
double taxRate;
|
||||
|
||||
public:
|
||||
TaxComponent(double rate) : ICostComponent(), taxRate(rate) {
|
||||
explicit TaxComponent(const double rate) : ICostComponent(), taxRate(rate) {
|
||||
}
|
||||
|
||||
void apply(std::unique_ptr<Building::Base> &building, std::unique_ptr<Community> &community) override;
|
||||
|
||||
@ -9,19 +9,17 @@
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "../helper/StringOperations.h"
|
||||
|
||||
class CostHistory {
|
||||
private:
|
||||
struct CostPoint {
|
||||
std::string name;
|
||||
float value;
|
||||
float amount;
|
||||
float value{0.0f};
|
||||
float amount{0.f};
|
||||
|
||||
CostPoint(std::string name, const float value, const float amount)
|
||||
: name(std::move(name)), value(value), amount(amount) {}
|
||||
|
||||
float total() const {
|
||||
[[nodiscard]] float total() const {
|
||||
return value * amount;
|
||||
}
|
||||
};
|
||||
|
||||
@ -9,22 +9,17 @@
|
||||
#include <iostream>
|
||||
|
||||
void Surplus::CalculateSurplus() {
|
||||
auto iterateFunc = Community::iterateBuildings(communities);
|
||||
auto iterateFunc = Community::iterateBuildings(communities);
|
||||
|
||||
auto modifyCommunity = [this](Community &c) {
|
||||
auto modifyCommunity = [this](const Community &c) {
|
||||
this->consumptionAvailable = std::vector<float>(VALUE_COUNT, 0.f);
|
||||
this->generationAvailable = std::vector<float>(VALUE_COUNT, 0.f);
|
||||
|
||||
assert(!c.name().empty() && "Community name is empty!");
|
||||
LOG_DEBUG_INFO("Calculating Surplus for Community: {}", c.name());
|
||||
};
|
||||
|
||||
|
||||
auto modifyBuildingSurplus = [this](Community &community, Building::Base &building) {
|
||||
assert(building.metadata() != nullptr && "Building metadata is null!");
|
||||
|
||||
LOG_DEBUG_INFO("Calculating Surplus for Building: {} in Community: {}",
|
||||
building.metadata()->name(), community.name());
|
||||
|
||||
CalculateBuildingSurplus(community, building);
|
||||
|
||||
@ -52,10 +47,10 @@ void Surplus::CalculateSurplus() {
|
||||
}
|
||||
|
||||
void Surplus::CalculateBuildingSurplus(Community &community, Building::Base &building) {
|
||||
std::vector<float> ownCoverage = std::vector(VALUE_COUNT, 0.0f);
|
||||
std::vector<float> neededConsumption = std::vector(VALUE_COUNT, 0.0f);
|
||||
std::vector<float> neededGeneration = std::vector(VALUE_COUNT, 0.0f);
|
||||
std::vector<float> ownUsage = std::vector(VALUE_COUNT, 0.0f);
|
||||
auto ownCoverage = std::vector(VALUE_COUNT, 0.0f);
|
||||
auto neededConsumption = std::vector(VALUE_COUNT, 0.0f);
|
||||
auto neededGeneration = std::vector(VALUE_COUNT, 0.0f);
|
||||
auto ownUsage = std::vector(VALUE_COUNT, 0.0f);
|
||||
|
||||
assert(building.metadata() != nullptr && "Building metadata is null!");
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ private:
|
||||
std::vector<float> generationAvailable;
|
||||
|
||||
public:
|
||||
Surplus(std::vector<std::unique_ptr<Community> > &communities) : communities(communities),
|
||||
explicit Surplus(std::vector<std::unique_ptr<Community> > &communities) : communities(communities),
|
||||
consumptionAvailable(VALUE_COUNT, 0.0f),
|
||||
generationAvailable(VALUE_COUNT, 0.0f) {
|
||||
}
|
||||
@ -27,7 +27,7 @@ public:
|
||||
|
||||
void CalculateBuildingSurplus(Community &community, Building::Base &);
|
||||
|
||||
void CalculateSurplusCommunity(Community &community, Building::Base &base);
|
||||
static void CalculateSurplusCommunity(Community &community, Building::Base &base);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -25,13 +25,13 @@ public:
|
||||
auto neededGen = std::vector<float>();
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
// Populate with test values
|
||||
communityCoverage.push_back(i * 10.0f);
|
||||
ownUsage.push_back(i * 5.0f);
|
||||
neededCon.push_back(i * 3.0f);
|
||||
neededGen.push_back(i * 2.0f);
|
||||
communityCoverage.push_back(static_cast<float>(i) * 10.0f);
|
||||
ownUsage.push_back(static_cast<float>(i) * 5.0f);
|
||||
neededCon.push_back(static_cast<float>(i) * 3.0f);
|
||||
neededGen.push_back(static_cast<float>(i) * 2.0f);
|
||||
}
|
||||
|
||||
|
||||
values->set_community_coverage(std::move(communityCoverage));
|
||||
values->set_own_usage(std::move(ownUsage));
|
||||
values->set_needed_con(std::move(neededCon));
|
||||
@ -58,8 +58,8 @@ public:
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
// Populate with test values
|
||||
consumptionProfile.push_back(i * 100.0f);
|
||||
generationProfile.push_back(i * 50.0f);
|
||||
consumptionProfile.push_back(static_cast<float>(i) * 100.0f);
|
||||
generationProfile.push_back(static_cast<float>(i) * 50.0f);
|
||||
}
|
||||
|
||||
metadata->set_consumption_profile(std::move(consumptionProfile));
|
||||
|
||||
@ -2,11 +2,19 @@
|
||||
// Created by StanislausCichocki on 10.03.2025.
|
||||
//
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include "../../src/services/Surplus.h"
|
||||
#include "../../src/services/Cost/BillCharge.h"
|
||||
#include "../../src/services/Cost/CalculateFinalSums.h"
|
||||
#include "../../src/services/Cost/CostPipeline.h"
|
||||
#include "../../src/services/Cost/NetworkProvider.h"
|
||||
#include "../../src/services/Cost/ServiceCharge.h"
|
||||
#include "../../src/services/Cost/GridCost/MeasurementServiceFee.h"
|
||||
#include "../../src/services/Cost/GridCost/NetUsagePerformance.h"
|
||||
#include "doctest/doctest.h"
|
||||
#include "../model/Factory.h"
|
||||
#include "../../src/Config.h"
|
||||
|
||||
TEST_CASE("Testing add function") {
|
||||
std::vector<std::unique_ptr<Community> > communities;
|
||||
@ -17,5 +25,13 @@ TEST_CASE("Testing add function") {
|
||||
surplus.CalculateSurplus();
|
||||
CostPipeline costPipeline(communities);
|
||||
costPipeline.addCostComponent(std::make_shared<NetworkProvider>());
|
||||
costPipeline.addCostComponent(std::make_shared<BillCharge>());
|
||||
costPipeline.addCostComponent(std::make_shared<MeasurementServiceFee>());
|
||||
costPipeline.addCostComponent(std::make_shared<NetUsagePerformance>());
|
||||
costPipeline.addCostComponent(std::make_shared<ServiceCharge>());
|
||||
costPipeline.addCostComponent(std::make_shared<CalculateFinalSums>());
|
||||
costPipeline.calculateFinalCost();
|
||||
|
||||
LOG_DEBUG_INFO("{}",communities[0]->total);
|
||||
CHECK(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user