added test case for bus

This commit is contained in:
Gerhard Hoffmann 2024-07-29 11:30:36 +02:00
parent 9f4affca5a
commit 37620a06c1

View File

@ -49,9 +49,9 @@ extern "C" char* strptime(const char* s,
#define NEUHAUSER_STOCKERAU (0)
#define KLEIPEDA_LITAUEN (0)
#define SEXTEN (0)
#define SCHNALS_LEITER_KIRCHL (1)
#define SCHNALS_LEITER_KIRCHL (0)
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
#define VALSER_ALM (0)
#define VALSER_ALM (1)
#if NEUHAUSER_KIRCHDORF==1
static bool test_neuhauser_kirchdorf(int step, double cost) {
@ -801,7 +801,7 @@ int main() {
int pop_max_price;
int pop_daily_card_price;
int zone = 2;
int zone = 1;
if (zone == 1) {
input.open("/opt/ptu5/opt/customer_502/etc/psa_tariff/tariff01.json");
@ -823,6 +823,32 @@ int main() {
cout << endl;
if (isParsed) {
if (zone == 1) {
/*
pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_PKW);
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
qCritical() << " pop_min_time_pkw: " << pop_min_time;
qCritical() << " pop_max_time_pkw: " << pop_max_time;
qCritical() << " pop_min_price_pkw: " << pop_min_price;
qCritical() << " pop_max_price_pkw: " << pop_max_price;
pop_min_time = get_minimal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
pop_max_time = get_maximal_parkingtime(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
pop_min_price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
pop_max_price = get_maximal_parkingprice(&cfg, PERMIT_TYPE::SHORT_TERM_PARKING_BUS);
pop_daily_card_price = cfg.getPaymentOptions().pop_daily_card_price;
qCritical() << " pop_min_time_bus: " << pop_min_time;
qCritical() << " pop_max_time_bus: " << pop_max_time;
qCritical() << " pop_min_price_bus: " << pop_min_price;
qCritical() << " pop_max_price_bus: " << pop_max_price;
*/
} else {
pop_min_time = get_minimal_parkingtime(&cfg);
pop_max_time = get_maximal_parkingtime(&cfg);
pop_min_price = get_minimal_parkingprice(&cfg);
@ -833,12 +859,48 @@ int main() {
qCritical() << " pop_max_time: " << pop_max_time;
qCritical() << " pop_min_price: " << pop_min_price;
qCritical() << " pop_max_price: " << pop_max_price;
}
//QDateTime start = QDateTime::currentDateTime();
//start.setTime(QTime(12, 0, 0));
//QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg, 0, start);
//qCritical() << "TimeSteps" << timeSteps;
//return 0;
if (zone == 1) {
//int minParkingTime = get_minimal_parkingtime(&cfg);
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
qCritical() << timeSteps;
int Down = 0;
int Up = 1;
QDateTime const start = QDateTime::currentDateTime();
int paymentOptionIndex = cfg.getPaymentOptionIndex(start);
if (paymentOptionIndex < 0) {
qCritical() << "ERROR paymentOptionIndex" << paymentOptionIndex
<< "< 0 for start" << start.toString(Qt::ISODate);
exit(-1);
}
QSet<uint32_t> const prices_pkw{600, 1200, 1800, 2400, 3000, 3600, 4200};
QSet<uint32_t> const prices_bus{3000, 6000, 9000, 12000, 15000, 18000, 21000};
QDateTime end;
CalcState calcState;
QDateTime s(QDateTime::currentDateTime());
s.setTime(QTime(12, 0, 0));
//calcState = compute_duration_for_parking_ticket(&cfg, s,
// (double)1200, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
//qCritical() << end.toString(Qt::ISODate);
//qCritical() << calcState.toString();
calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)6000, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
qCritical() << end.toString(Qt::ISODate);
qCritical() << calcState.toString();
}
if (zone == 2) {
//int minParkingTime = get_minimal_parkingtime(&cfg);
@ -858,6 +920,16 @@ int main() {
QSet<uint32_t> const prices{600, 1200, 1800, 2400, 3000, 3600, 4200};
QDateTime end;
CalcState calcState;
QDateTime s(QDateTime::currentDateTime());
s.setTime(QTime(18, 0, 0));
calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)600, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
qCritical() << end.toString(Qt::ISODate);
qCritical() << calcState.toString();
#if 0
for (int i=0; i<timeSteps.size(); ++i) {
int nextTimeStep = compute_next_timestep(&cfg, timeSteps.at(i), Up);
@ -882,6 +954,7 @@ int main() {
<< "(price so far:" << price << ")";
}
#endif
}
if (zone == 3) {
int price;