Ref T298, matcher setup improvements (score only)

This commit is contained in:
Klaus Basan
2018-08-15 01:07:04 +02:00
parent f9b2304e1a
commit f2b6b093e4
2 changed files with 49 additions and 36 deletions

View File

@@ -16,7 +16,7 @@ namespace BlackMisc
{
CAircraftMatcherSetup::CAircraftMatcherSetup()
{
this->reset(MatchingScoreBased);
this->reset(MatchingStepwiseReducePlusScoreBased);
}
CAircraftMatcherSetup::CAircraftMatcherSetup(CAircraftMatcherSetup::MatchingAlgorithm algorithm)
@@ -50,7 +50,7 @@ namespace BlackMisc
Q_UNUSED(i18n);
return QStringLiteral("algorithm: '") % this->getMatchingAlgorithmAsString() %
QStringLiteral("' mode: '") % this->getMatchingModeAsString() %
QStringLiteral("' strategy: ") % this->getPickStrategyAsString() %
QStringLiteral("' strategy: '") % this->getPickStrategyAsString() %
QStringLiteral("'");
}
@@ -92,9 +92,12 @@ namespace BlackMisc
mode = ModeDefaultReduce;
break;
case MatchingScoreBased:
default:
mode = ModeDefaultScore;
break;
case MatchingStepwiseReducePlusScoreBased:
default:
mode = ModeDefaultReducePlusScore;
break;
}
this->setMatchingMode(mode);
this->setPickStrategy(PickByOrder);
@@ -102,15 +105,17 @@ namespace BlackMisc
const QString &CAircraftMatcherSetup::algorithmToString(CAircraftMatcherSetup::MatchingAlgorithm algorithm)
{
static const QString rs("reduce + score based");
static const QString s("score based");
static const QString r("stepwise reduce");
switch (algorithm)
{
case MatchingStepwiseReduce: return r;
case MatchingScoreBased:
case MatchingScoreBased: return s;
case MatchingStepwiseReducePlusScoreBased:
default: break;
}
return s;
return rs;
}
const QString &CAircraftMatcherSetup::modeFlagToString(MatchingModeFlag modeFlag)
@@ -121,7 +126,7 @@ namespace BlackMisc
static const QString icaoAirline("by ICAO, airline first");
static const QString family("by family");
static const QString livery("by livery");
static const QString combined("by combined combined");
static const QString combined("by combined code");
static const QString noZeros("scoring, ignore zero scores");
static const QString preferColorLiveries("scoring, prefer color liveries");
@@ -178,6 +183,7 @@ namespace BlackMisc
CAircraftMatcherSetup::MatchingMode CAircraftMatcherSetup::matchingMode(
bool byModelString, bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st, bool byFamily, bool byLivery, bool byCombinedType,
bool byMilitary, bool byVtol,
bool scoreIgnoreZeros, bool scorePreferColorLiveries)
{
MatchingMode mode = byModelString ? ByModelString : ModeNone;
@@ -186,6 +192,8 @@ namespace BlackMisc
if (byFamily) { mode |= ByFamily; }
if (byLivery) { mode |= ByLivery; }
if (byCombinedType) { mode |= ByCombinedType; }
if (byMilitary) { mode |= ByMilitary; }
if (byVtol) { mode |= ByVtol; }
if (scoreIgnoreZeros) { mode |= ScoreIgnoreZeros; }
if (scorePreferColorLiveries) { mode |= ScorePreferColorLiveries; }
return mode;

View File

@@ -28,6 +28,7 @@ namespace BlackMisc
enum MatchingAlgorithm
{
MatchingScoreBased,
MatchingStepwiseReducePlusScoreBased,
MatchingStepwiseReduce
};
@@ -39,16 +40,20 @@ namespace BlackMisc
ByFamily = 1 << 2,
ByLivery = 1 << 3,
ByCombinedType = 1 << 4,
ByIcaoOrderAircraftFirst = (1 << 5) | ByIcaoData,
ByIcaoOrderAirlineFirst = (1 << 6) | ByIcaoData,
ByManufacturer = 1 << 5,
ByMilitary = 1 << 6,
ByVtol = 1 << 7,
ByIcaoOrderAircraftFirst = (1 << 8) | ByIcaoData,
ByIcaoOrderAirlineFirst = (1 << 9) | ByIcaoData,
// --- score based matching ---
ScoreIgnoreZeros = 1 << 7, //!< zero scores are ignored
ScorePreferColorLiveries = 1 << 8, //!< prefer color liveries
ScoreIgnoreZeros = 1 << 10, //!< zero scores are ignored
ScorePreferColorLiveries = 1 << 11, //!< prefer color liveries
// --- others ---
ModeNone = 0,
ModeScoreDefault = ScoreIgnoreZeros | ScorePreferColorLiveries,
ModeDefaultScore = ByIcaoOrderAircraftFirst | ByModelString | ByCombinedType | ModeScoreDefault,
ModeDefaultReduce = ByModelString | ByFamily | ByLivery | ByCombinedType | ByIcaoOrderAircraftFirst
ModeByFLags = ByMilitary | ByVtol,
ModeDefaultScore = ScoreIgnoreZeros | ScorePreferColorLiveries,
ModeDefaultReduce = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ByLivery,
ModeDefaultReducePlusScore = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ModeDefaultScore,
};
Q_DECLARE_FLAGS(MatchingMode, MatchingModeFlag)
@@ -129,13 +134,13 @@ namespace BlackMisc
static const QString &strategyToString(PickSimilarStrategy strategy);
//! Mode by flags
static MatchingMode matchingMode(
bool byModelString, bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st, bool byFamily, bool byLivery, bool byCombinedType,
static MatchingMode matchingMode(bool byModelString, bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st,
bool byFamily, bool byLivery, bool byCombinedType, bool byMilitary, bool byVtol,
bool scoreIgnoreZeros, bool scorePreferColorLiveries);
private:
int m_algorithm = static_cast<int>(MatchingScoreBased);
int m_mode = static_cast<int>(ModeDefaultScore);
int m_algorithm = static_cast<int>(MatchingStepwiseReducePlusScoreBased);
int m_mode = static_cast<int>(ModeDefaultReducePlusScore);
int m_strategy = static_cast<int>(PickByOrder);
BLACK_METACLASS(