Add test cases for neuhauser.

This commit is contained in:
Gerhard Hoffmann 2023-12-06 10:52:35 +01:00
parent 54e9a0f86d
commit 6b76c4c2dd

View File

@ -33,13 +33,66 @@ extern "C" char* strptime(const char* s,
#include "calculator_functions.h" #include "calculator_functions.h"
#include <calculate_price.h> #include <calculate_price.h>
#define SZEGED (1)
#define NEUHAUSER_KORNEUBURG (0)
int main() { int main() {
//std::ifstream input("/tmp/tariff_korneuburg.json"); #if NEUHAUSER_KORNEUBURG==1
std::ifstream input("/tmp/tariff_korneuburg.json");
int pop_max_time; int pop_max_time;
std::stringstream sstr;
while(input >> sstr.rdbuf());
std::string json(sstr.str());
Calculator calculator;
Configuration cfg;
bool isParsed = cfg.ParseJson(&cfg, json.c_str());
cout << endl;
if (isParsed) {
{
pop_max_time = 3*60;
bool nextDay = false;
bool prePaid = true;
// zone 1 (lila)
QDateTime s(QDate(2023, 11, 30), QTime());
QDateTime end;
for (int duration = 30; duration <= pop_max_time; duration += 5) {
for (int offset = 420; offset < 1140; ++offset) {
if (offset > 720 && offset < 840) {
continue;
}
QDateTime start = s.addSecs(offset * 60);
//qCritical() << "start" << start.toString(Qt::ISODate);
double cost = calculator.GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
//Q_ASSERT(cost == duration*2.5);
//qCritical() << "";
//qCritical() << "start" << start.toString(Qt::ISODate)
// << "end" << end.toString(Qt::ISODate)
// << "duration" << duration
// << "cost" << cost;
std::string duration = calculator.GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
//Q_ASSERT(cost == duration*2.5);
qCritical() << "start" << start.toString(Qt::ISODate)
<< "cost" << cost
<< "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
}
}
}
}
return 0;
#elif SZEGED==1
std::ifstream input; std::ifstream input;
for (int t=1; t < 7; t+=20) { int pop_max_time;
for (int t=6; t < 7; t+=20) {
switch (t) { switch (t) {
case 1: { case 1: {
input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff01.json"); input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff01.json");
@ -123,6 +176,7 @@ int main() {
return 0; return 0;
#endif
#if 0 #if 0