ilm
This commit is contained in:
parent
041c3211bc
commit
4348f9a222
@ -29,26 +29,39 @@ func NonLinearCoolingModel(daysDiff int, period string, config map[string]float6
|
||||
minutes := periodToMinutes(period)
|
||||
|
||||
// 可配置的系数
|
||||
timeDecayFactor := config["timeDecayFactor"] // 距今时间因子
|
||||
periodGranularityFactor := config["periodGranularityFactor"] // 时间框架粒度因子
|
||||
warmPhaseMultiplier := config["warmPhaseMultiplier"] // warm阶段乘数
|
||||
coldPhaseMultiplier := config["coldPhaseMultiplier"] // cold阶段乘数
|
||||
deletePhaseMultiplier := config["deletePhaseMultiplier"] // delete阶段乘数
|
||||
timeDecayFactor := config["timeDecayFactor"] // 距今时间因子
|
||||
// periodGranularityFactor := config["periodGranularityFactor"] // 时间框架粒度因子
|
||||
// warmPhaseMultiplier := config["warmPhaseMultiplier"] // warm阶段乘数
|
||||
// coldPhaseMultiplier := config["coldPhaseMultiplier"] // cold阶段乘数
|
||||
// deletePhaseMultiplier := config["deletePhaseMultiplier"] // delete阶段乘数
|
||||
|
||||
// 距今时间因子:越久远,冷却越快
|
||||
timeFactor := 1 - math.Pow(float64(daysDiff), timeDecayFactor)/100
|
||||
if timeFactor < 0 {
|
||||
timeFactor = 0
|
||||
// 时间衰减因子反转:越新的数据保留越久
|
||||
timeFactor := math.Pow(100.0, timeDecayFactor) / math.Pow(float64(daysDiff+1), timeDecayFactor)
|
||||
if timeFactor > 1 {
|
||||
timeFactor = 1
|
||||
}
|
||||
|
||||
// 时间框架因子:粒度越细,冷却越快
|
||||
periodFactor := math.Pow(float64(minutes), periodGranularityFactor) / math.Pow(43200, periodGranularityFactor)
|
||||
// 时间框架因子调整:粒度越细保留时间越长
|
||||
periodFactor := math.Pow(float64(minutes)/1440, 0.5) // 基于天数的平方根比例
|
||||
|
||||
// 计算各个阶段的时间
|
||||
warmDays := int(float64(daysDiff) * warmPhaseMultiplier * timeFactor * periodFactor)
|
||||
coldDays := int(float64(daysDiff) * coldPhaseMultiplier * timeFactor * periodFactor)
|
||||
deleteDays := int(float64(daysDiff) * deletePhaseMultiplier * timeFactor * periodFactor)
|
||||
// 基础保留天数计算(与时间框架成正比)
|
||||
baseDays := int(30 * periodFactor) // 30天基础值
|
||||
|
||||
// 阶段持续时间计算(与距今时间成反比)
|
||||
warmDays := baseDays + int(float64(1000)/float64(daysDiff+1))
|
||||
coldDays := 2*baseDays + int(float64(2000)/float64(daysDiff+1))
|
||||
deleteDays := 3*baseDays + int(float64(3000)/float64(daysDiff+1))
|
||||
|
||||
// 保证最小阶段关系
|
||||
if warmDays < baseDays {
|
||||
warmDays = baseDays
|
||||
}
|
||||
if coldDays < 2*baseDays {
|
||||
coldDays = 2 * baseDays
|
||||
}
|
||||
if deleteDays < 3*baseDays {
|
||||
deleteDays = 3 * baseDays
|
||||
}
|
||||
return warmDays, coldDays, deleteDays
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user