test case for kleipeda and fuchs

This commit is contained in:
Gerhard Hoffmann 2024-08-01 16:46:09 +02:00
parent 4bce854d77
commit 24d9d4a0ff

View File

@ -47,11 +47,11 @@ extern "C" char* strptime(const char* s,
#define NEUHAUSER_CHRISTOPH_REISEN (0)
#define NEUHAUSER_PERNEGG_AN_DER_MUR (0)
#define NEUHAUSER_STOCKERAU (0)
#define KLEIPEDA_LITAUEN (0)
#define KLEIPEDA_LITAUEN (1)
#define SEXTEN (0)
#define SCHNALS_LEITER_KIRCHL (0)
#define SCHNALS_STAUMAUER (SCHNALS_LEITER_KIRCHL)
#define VALSER_ALM (1)
#define VALSER_ALM (0)
#if NEUHAUSER_KIRCHDORF==1
static bool test_neuhauser_kirchdorf(int step, double cost) {
@ -354,7 +354,7 @@ int main() {
QList<int> timeSteps = Calculator::GetInstance().GetTimeSteps(&cfg);
qCritical() << "TimeSteps" << timeSteps;
return 0;
// return 0;
CalcState cs;
double cost;
@ -363,7 +363,7 @@ int main() {
// for (int day = Qt::Monday; day <= Qt::Sunday; ++day) {
for (int day = Qt::Monday; day <= Qt::Monday; ++day) {
QDateTime s(QDate(2024, 5, 19 + day), QTime()); // 20: (whit) monday,..., 26: sunday
QDateTime s(QDate(2024, 7, 29 + day), QTime()); // 20: (whit) monday,..., 26: sunday
QDateTime end;
switch (day) {
@ -401,9 +401,11 @@ int main() {
bool prepaid = true);
*/
for (int minutes = 0; minutes < 1440; ++minutes) {
QDateTime start = s.addSecs(minutes * 60);
QDateTime effectiveStart = start;
//for (int minutes = 0; minutes < 1440; ++minutes) {
for (int minutes = 540; minutes <= 540; ++minutes) {
// QDateTime start = s.addSecs(minutes * 60);
QDateTime start(QDateTime::currentDateTime());
QDateTime effectiveStart(QDateTime::currentDateTime());
if (start.time() < QTime(8, 0, 0)) {
effectiveStart.setTime(QTime(8, 0, 0));
@ -415,55 +417,18 @@ int main() {
effectiveStart.setTime(QTime(8, 0, 0)); // next day
}
for (int i = 0; i <= 2100; i += 10) {
for (int i = 30; i <= 30; i += 10) {
//for (int i = 2100; i <= 2100; i += 10) {
cost = i;
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
durationInMinutes = pop_min_time;
if (i > 0) {
durationInMinutes += (i/10) * 4;
}
offsetInMinutes = 0;
if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(22, 0, 0)) {
if (effectiveStart.time().secsTo(QTime(22, 0, 0)) < (durationInMinutes * 60)) {
offsetInMinutes = 600; // 22:00 -> 8:00
}
}
if (i == 0) {
i += 20;
}
if ((durationInMinutes + offsetInMinutes) == (effectiveStart.secsTo(end) / 60)) {
if (day == Qt::Monday && minutes >= 480 && minutes <= 1320) {
qCritical() << "| start ............................" << start.toString(Qt::ISODate);
qCritical() << "| cost ............................." << cost;
qCritical() << "| durationInMinutes ................" << durationInMinutes
<< "(" << (durationInMinutes - 60) << "+ 60 )";
qCritical() << "| offsetInMinutes .................." << offsetInMinutes;
qCritical() << "| end .............................." << end.toString(Qt::ISODate) << endl;
}
continue;
}
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) { // return value
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
<< "> end" << end.toString(Qt::ISODate);
}
if (!cs) {
qCritical() << "ERROR CalcState" << cs.toString() << endl;
} else {
qCritical() << cs.toString();
}
qCritical() << __LINE__ << "start ............................" << start.toString(Qt::ISODate);
qCritical() << __LINE__ << "effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
qCritical() << __LINE__ << "cost ............................." << cost;
qCritical() << __LINE__ << "durationInMinutes ................" << durationInMinutes;
qCritical() << __LINE__ << "offsetInMinutes .................." << offsetInMinutes;
qCritical() << __LINE__ << "effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
qCritical() << __LINE__ << "end .............................." << end.toString(Qt::ISODate) << endl;
exit(-1);
}
}
}
@ -552,7 +517,7 @@ int main() {
*/
//for (int minutes = 0; minutes < 1440; ++minutes) {
for (int minutes = 0; minutes < 1440; minutes += 1) {
for (int minutes = 480; minutes <= 480; minutes += 1) {
QDateTime start = s.addSecs(minutes * 60);
// qCritical() << "start" << start.toString(Qt::ISODate);
@ -569,66 +534,32 @@ int main() {
effectiveStart.setTime(QTime(8, 0, 0)); // next day
}
/*
for (int i = 10; i <= 400; i += 10) {
//for (int i = 2100; i <= 2100; i += 10) {
cost = i;
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) { // return value
qCritical() << "start" << start.toString(Qt::ISODate) << "< cost" << cost
<< "> end" << end.toString(Qt::ISODate);
durationInMinutes = pop_min_time;
if (i > 0) {
durationInMinutes += (i/10) * 4;
}
offsetInMinutes = 0;
if (effectiveStart.time() >= QTime(8, 0, 0) && effectiveStart.time() <= QTime(19, 0, 0)) {
if (effectiveStart.time().secsTo(QTime(19, 0, 0)) < (durationInMinutes * 60)) {
offsetInMinutes = 780; // 19:00 -> 8:00
}
}
if (i == 0) {
i += 20;
}
#if 0
if ((durationInMinutes + offsetInMinutes) == (effectiveStart.secsTo(end) / 60)) {
if (day == Qt::Monday && minutes >= 480 && minutes <= 1140) {
qCritical() << "| start ............................" << start.toString(Qt::ISODate);
qCritical() << "| cost ............................." << cost;
qCritical() << "| durationInMinutes ................" << durationInMinutes
<< "(" << (durationInMinutes - 60) << "+ 60 )";
qCritical() << "| offsetInMinutes .................." << offsetInMinutes;
qCritical() << "| end .............................." << end.toString(Qt::ISODate) << endl;
}
continue;
}
#endif
}
if (!cs) {
qCritical() << "ERROR CalcState" << cs.toString() << endl;
} else {
// qCritical() << cs.toString();
}
}
*/
int netto_parking_time = 60;
struct price_t price;
#if 0
qCritical() << __LINE__ << "start ............................" << start.toString(Qt::ISODate);
qCritical() << __LINE__ << "effectiveStart ..................." << effectiveStart.toString(Qt::ISODate);
qCritical() << __LINE__ << "cost ............................." << cost;
qCritical() << __LINE__ << "durationInMinutes ................" << durationInMinutes;
qCritical() << __LINE__ << "offsetInMinutes .................." << offsetInMinutes;
qCritical() << __LINE__ << "effectiveStart.secsTo(end) / 60 .." << effectiveStart.secsTo(end) / 60;
qCritical() << __LINE__ << "end .............................." << end.toString(Qt::ISODate) << endl;
exit(-1);
#endif
qCritical() << "start" << start.toString(Qt::ISODate);
QDateTime const s = start;
if ((cs = compute_price_for_parking_ticket(&cfg, start, netto_parking_time, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
qCritical() << "start" << s.toString(Qt::ISODate)
<< "netto_parking_time" << netto_parking_time
<< "< price" << price.netto
<< "> end" << end.toString(Qt::ISODate);
}
}
}
@ -737,7 +668,7 @@ int main() {
effectiveStart.setTime(QTime(7, 0, 0)); // next day
}
#if 1
#if 0
PermitType permitType(PERMIT_TYPE::SHORT_TERM_PARKING);
for (int i = 200; i <= 200; i += 10) {
cost = i;
@ -760,7 +691,7 @@ int main() {
//for (int i = 2100; i <= 2100; i += 10) {
cost = i;
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end))) { // return value
if ((cs = compute_duration_for_parking_ticket(&cfg, start, cost, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW)))) { // return value
}
if (!cs) {
@ -898,7 +829,7 @@ int main() {
//qCritical() << calcState.toString();
calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)9000, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
(double)50, end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_BUS));
qCritical() << end.toString(Qt::ISODate);
qCritical() << calcState.toString();
}
@ -988,7 +919,7 @@ int main() {
s.setTime(QTime(12, 0, 0));
int minimal_parking_price = get_minimal_parkingprice(&cfg,
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING),
paymentOptionIndex, s);
qCritical() << "minimal parking price" << minimal_parking_price;
@ -996,14 +927,14 @@ int main() {
for (int i = 0; i < 8; ++i) {
calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)minimal_parking_price + i*800,
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
}
s.setTime(QTime(15, 0, 0));
minimal_parking_price = get_minimal_parkingprice(&cfg,
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW),
PermitType(PERMIT_TYPE::SHORT_TERM_PARKING),
paymentOptionIndex, s);
qCritical() << "minimal parking price" << minimal_parking_price;
@ -1011,7 +942,7 @@ int main() {
for (int i = 0; i < 8; ++i) {
calcState = compute_duration_for_parking_ticket(&cfg, s,
(double)minimal_parking_price + i*800,
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING_PKW));
end, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
qCritical() << "RUN" << i << end.toString(Qt::ISODate) << calcState.toString();
}
}
@ -1532,7 +1463,7 @@ int main() {
for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
QDateTime end = start.addSecs(timeSteps.at(i)*60);
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
if (cs.getStatus() != CalcState::State::SUCCESS) {
if (start.time().hour() >= 8 && start.time().hour() < 18) {
qCritical() << "ERROR CALC-STATE-1=" << QString(cs);
@ -1555,7 +1486,7 @@ int main() {
}
qCritical() << "compute_price_for_parking_ticket()/GetCostFromDuration() TIME: "
<< timeSteps.at(i) << "PRICE=" << price1;
<< timeSteps.at(i) << "PRICE=" << price1 << "end=" << end.toString(Qt::ISODate);
//std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 4,
@ -1639,7 +1570,7 @@ int main() {
double cost = 0;
CalcState cs;
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
cost = price.netto;
qCritical() << "step" << *step << ": cost" << cost;
} else {
@ -1723,7 +1654,7 @@ int main() {
double cost = 0;
CalcState cs;
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
cost = price.netto;
qCritical() << "step" << *step << ": cost" << cost;
} else {
@ -1808,7 +1739,7 @@ int main() {
double cost = 0;
CalcState cs;
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
cost = price.netto;
qCritical() << "step" << *step << ": cost" << cost;
} else {
@ -1866,7 +1797,7 @@ int main() {
double cost = 0;
CalcState cs;
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price))) {
if ((cs = compute_price_for_parking_ticket(&cfg, start, *step, end, &price, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING)))) {
cost = price.netto;
qCritical() << "step" << *step << ": cost" << cost;
} else {
@ -1969,7 +1900,7 @@ int main() {
CalcState cs;
for (int i = 13, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
QDateTime end = start.addSecs(timeSteps.at(i)*60);
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
qCritical() << endl;
}
@ -1994,7 +1925,7 @@ int main() {
for (int i = 0, j=timeSteps.size() ; i < timeSteps.size(); --j, ++i) {
QDateTime end = start.addSecs(timeSteps.at(i)*60);
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs);
cs = compute_price_for_parking_ticket(&cfg, start, timeSteps.at(i), end, &costs, PermitType(PERMIT_TYPE::SHORT_TERM_PARKING));
if (cs.getStatus() != CalcState::State::SUCCESS) {
if (start.time().hour() >= 8 && start.time().hour() < 18) {
qCritical() << "ERROR CALC-STATE-1=" << QString(cs);