Create more aggressive probability tables.

Bug: 13197276

Change-Id: I1451dcbe61088d7301bbef5ceedc72f5649e6764
main
Keisuke Kuroyanagi 2014-02-26 19:36:57 +09:00
parent 7e70e9dc49
commit 70566266be
2 changed files with 44 additions and 6 deletions

View File

@ -148,7 +148,15 @@ const ForgettingCurveUtils::ProbabilityTable ForgettingCurveUtils::sProbabilityT
return (TimeKeeper::peekCurrentTime() - timestamp) / TIME_STEP_DURATION_IN_SECONDS;
}
const int ForgettingCurveUtils::ProbabilityTable::PROBABILITY_TABLE_COUNT = 1;
const int ForgettingCurveUtils::ProbabilityTable::PROBABILITY_TABLE_COUNT = 4;
const int ForgettingCurveUtils::ProbabilityTable::WEAK_PROBABILITY_TABLE_ID = 0;
const int ForgettingCurveUtils::ProbabilityTable::MODEST_PROBABILITY_TABLE_ID = 1;
const int ForgettingCurveUtils::ProbabilityTable::STRONG_PROBABILITY_TABLE_ID = 2;
const int ForgettingCurveUtils::ProbabilityTable::AGGRESSIVE_PROBABILITY_TABLE_ID = 3;
const int ForgettingCurveUtils::ProbabilityTable::MODEST_BASE_PROBABILITY = 32;
const int ForgettingCurveUtils::ProbabilityTable::STRONG_BASE_PROBABILITY = 35;
const int ForgettingCurveUtils::ProbabilityTable::AGGRESSIVE_BASE_PROBABILITY = 40;
ForgettingCurveUtils::ProbabilityTable::ProbabilityTable() : mTables() {
mTables.resize(PROBABILITY_TABLE_COUNT);
@ -156,8 +164,8 @@ ForgettingCurveUtils::ProbabilityTable::ProbabilityTable() : mTables() {
mTables[tableId].resize(MAX_LEVEL + 1);
for (int level = 0; level <= MAX_LEVEL; ++level) {
mTables[tableId][level].resize(MAX_ELAPSED_TIME_STEP_COUNT + 1);
const float initialProbability =
static_cast<float>(MAX_COMPUTED_PROBABILITY / (1 << (MAX_LEVEL - level)));
const float initialProbability = getBaseProbabilityForLevel(tableId, level);
const float endProbability = getBaseProbabilityForLevel(tableId, level - 1);
for (int timeStepCount = 0; timeStepCount <= MAX_ELAPSED_TIME_STEP_COUNT;
++timeStepCount) {
if (level == 0) {
@ -166,9 +174,10 @@ ForgettingCurveUtils::ProbabilityTable::ProbabilityTable() : mTables() {
}
const int elapsedTime = timeStepCount * TIME_STEP_DURATION_IN_SECONDS;
const float probability = initialProbability
* powf(2.0f, -1.0f * static_cast<float>(elapsedTime)
/ static_cast<float>(TIME_STEP_DURATION_IN_SECONDS
* (MAX_ELAPSED_TIME_STEP_COUNT + 1)));
* powf(initialProbability / endProbability,
-1.0f * static_cast<float>(elapsedTime)
/ static_cast<float>(TIME_STEP_DURATION_IN_SECONDS
* (MAX_ELAPSED_TIME_STEP_COUNT + 1)));
mTables[tableId][level][timeStepCount] =
min(max(static_cast<int>(probability), 1), MAX_COMPUTED_PROBABILITY);
}
@ -176,4 +185,23 @@ ForgettingCurveUtils::ProbabilityTable::ProbabilityTable() : mTables() {
}
}
/* static */ int ForgettingCurveUtils::ProbabilityTable::getBaseProbabilityForLevel(
const int tableId, const int level) {
if (tableId == WEAK_PROBABILITY_TABLE_ID) {
// Max probability is 127.
return static_cast<float>(MAX_COMPUTED_PROBABILITY / (1 << (MAX_LEVEL - level)));
} else if (tableId == MODEST_PROBABILITY_TABLE_ID) {
// Max probability is 128.
return static_cast<float>(MODEST_BASE_PROBABILITY * (level + 1));
} else if (tableId == STRONG_PROBABILITY_TABLE_ID) {
// Max probability is 140.
return static_cast<float>(STRONG_BASE_PROBABILITY * (level + 1));
} else if (tableId == AGGRESSIVE_PROBABILITY_TABLE_ID) {
// Max probability is 160.
return static_cast<float>(AGGRESSIVE_BASE_PROBABILITY * (level + 1));
} else {
return NOT_A_PROBABILITY;
}
}
} // namespace latinime

View File

@ -68,8 +68,18 @@ class ForgettingCurveUtils {
DISALLOW_COPY_AND_ASSIGN(ProbabilityTable);
static const int PROBABILITY_TABLE_COUNT;
static const int WEAK_PROBABILITY_TABLE_ID;
static const int MODEST_PROBABILITY_TABLE_ID;
static const int STRONG_PROBABILITY_TABLE_ID;
static const int AGGRESSIVE_PROBABILITY_TABLE_ID;
static const int MODEST_BASE_PROBABILITY;
static const int STRONG_BASE_PROBABILITY;
static const int AGGRESSIVE_BASE_PROBABILITY;
std::vector<std::vector<std::vector<int> > > mTables;
static int getBaseProbabilityForLevel(const int tableId, const int level);
};
static const int MAX_COMPUTED_PROBABILITY;