Change testcase for Szeged
This commit is contained in:
		@@ -31,13 +31,13 @@ extern "C" char* strptime(const char* s,
 | 
			
		||||
#include <fstream>
 | 
			
		||||
#include <sstream>
 | 
			
		||||
#include "calculator_functions.h"
 | 
			
		||||
#include <calculate_price.h>
 | 
			
		||||
#include "calculate_price.h"
 | 
			
		||||
 | 
			
		||||
#define SZEGED                                  (0)
 | 
			
		||||
#define SZEGED                                  (1)
 | 
			
		||||
#define SCHOENAU_KOENIGSEE                      (0)
 | 
			
		||||
#define NEUHAUSER_KORNEUBURG                    (0)
 | 
			
		||||
#define NEUHAUSER_LINSINGER_MASCHINENBAU        (0)
 | 
			
		||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (1)
 | 
			
		||||
#define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0)
 | 
			
		||||
#define NEUHAUSER_BILEXA_GALTUER                (0)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -230,33 +230,37 @@ int main() {
 | 
			
		||||
 | 
			
		||||
#elif SZEGED==1
 | 
			
		||||
    std::ifstream input;
 | 
			
		||||
    int pop_min_time;
 | 
			
		||||
    int pop_max_time;
 | 
			
		||||
    int pop_min_price;
 | 
			
		||||
    int pop_max_price;
 | 
			
		||||
 | 
			
		||||
    for (int t=6; t < 7; t+=20) {
 | 
			
		||||
    for (int t=2; t < 3; ++t) {
 | 
			
		||||
    //for (int t=6; t < 7; t+=20) {
 | 
			
		||||
        switch (t) {
 | 
			
		||||
        case 1: {
 | 
			
		||||
            input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff01.json");
 | 
			
		||||
            pop_max_time = 6*60;
 | 
			
		||||
            //pop_max_time = 6*60;
 | 
			
		||||
        } break;
 | 
			
		||||
        case 2: {
 | 
			
		||||
            input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff02.json");
 | 
			
		||||
            pop_max_time = 5*60;
 | 
			
		||||
            //pop_max_time = 5*60;
 | 
			
		||||
        } break;
 | 
			
		||||
        case 3: {
 | 
			
		||||
            input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff03.json");
 | 
			
		||||
            pop_max_time = 6*60;
 | 
			
		||||
            //pop_max_time = 6*60;
 | 
			
		||||
        } break;
 | 
			
		||||
        case 4: {
 | 
			
		||||
            input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff04.json");
 | 
			
		||||
            pop_max_time = 4*60;
 | 
			
		||||
            //pop_max_time = 4*60;
 | 
			
		||||
        } break;
 | 
			
		||||
        case 5: {
 | 
			
		||||
            input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff05.json");
 | 
			
		||||
            pop_max_time = 6*60;
 | 
			
		||||
            //pop_max_time = 6*60;
 | 
			
		||||
        } break;
 | 
			
		||||
        case 6: {
 | 
			
		||||
            input.open("/opt/ptu5/opt/customer_281/etc/psa_tariff/tariff06.json");
 | 
			
		||||
            pop_max_time = 4*60;
 | 
			
		||||
            //pop_max_time = 4*60;
 | 
			
		||||
        } break;
 | 
			
		||||
        default:
 | 
			
		||||
            continue;
 | 
			
		||||
@@ -265,13 +269,24 @@ int main() {
 | 
			
		||||
        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) {
 | 
			
		||||
            // test library functions
 | 
			
		||||
 | 
			
		||||
            pop_min_time = get_minimal_parkingtime(&cfg);
 | 
			
		||||
            pop_max_time = get_maximal_parkingtime(&cfg);
 | 
			
		||||
            pop_min_price = get_minimal_parkingprice(&cfg);
 | 
			
		||||
            pop_max_price = get_maximal_parkingprice(&cfg);
 | 
			
		||||
 | 
			
		||||
            qCritical() << " pop_min_time: " << pop_min_time;
 | 
			
		||||
            qCritical() << " pop_max_time: " << pop_max_time;
 | 
			
		||||
            qCritical() << "pop_min_price: " << pop_min_price;
 | 
			
		||||
            qCritical() << "pop_max_price: " << pop_max_price;
 | 
			
		||||
 | 
			
		||||
            {
 | 
			
		||||
                // zone 1 (lila)
 | 
			
		||||
                QDateTime s(QDate(2023, 11, 30), QTime());
 | 
			
		||||
@@ -279,17 +294,17 @@ int main() {
 | 
			
		||||
                for (int duration = 15; duration <= pop_max_time; duration += 5) {
 | 
			
		||||
                    for (int offset = 480; offset < 1080; ++offset) {
 | 
			
		||||
                        QDateTime start = s.addSecs(offset * 60);
 | 
			
		||||
                        //qCritical() << "start" << start.toString(Qt::ISODate);
 | 
			
		||||
                        // qCritical() << "start" << start.toString(Qt::ISODate);
 | 
			
		||||
 | 
			
		||||
                        double cost = calculator.GetCostFromDuration(&cfg, 3, start, end, duration);
 | 
			
		||||
                        //Q_ASSERT(cost == duration*2.5);
 | 
			
		||||
                        //qCritical() << "";
 | 
			
		||||
                        //qCritical() << "start" << start.toString(Qt::ISODate)
 | 
			
		||||
                        //            << "end" << end.toString(Qt::ISODate)
 | 
			
		||||
                        //            << "duration" << duration
 | 
			
		||||
                        //            << "cost" << cost;
 | 
			
		||||
                        double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, duration);
 | 
			
		||||
                        // 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);
 | 
			
		||||
                        std::string duration = Calculator::GetInstance().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
 | 
			
		||||
@@ -297,20 +312,22 @@ int main() {
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
#if 0
 | 
			
		||||
            {
 | 
			
		||||
                QDateTime start(QDate(2023, 12, 1), QTime(18, 0));
 | 
			
		||||
                QDateTime end;
 | 
			
		||||
                double cost = calculator.GetCostFromDuration(&cfg, 3, start, end, 60);
 | 
			
		||||
                double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, 60);
 | 
			
		||||
               // Q_ASSERT(cost == 150);
 | 
			
		||||
                qCritical() << "end" << end.toString(Qt::ISODate) << "cost" << cost;
 | 
			
		||||
            }
 | 
			
		||||
            {
 | 
			
		||||
                QDateTime start(QDate(2023, 10, 31), QTime(18, 0));
 | 
			
		||||
                QDateTime end;
 | 
			
		||||
                double cost = calculator.GetCostFromDuration(&cfg, 3, start, end, 60);
 | 
			
		||||
                double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, 60);
 | 
			
		||||
                //Q_ASSERT(cost == 150);
 | 
			
		||||
                qCritical() << "end" << end.toString(Qt::ISODate) << "cost" << cost;
 | 
			
		||||
            }
 | 
			
		||||
#endif
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user