riku
2021-06-21 62a55369aa23d4b9cee5e66e0520b3803c33de6f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.flightfeather.uav.model
 
/**
 * 权重
 * 某种影响因素在不同情况下对某种监测数据产生的权重影响
 */
abstract class BaseWeight {
 
//    区间阈值
    abstract val sectionValues: List<Double>
//    区间对应权重
    abstract val weights: List<Double>
 
    /**
     * 权重计算
     * @param value 影响因素的值
     */
    fun weightCal(value: Double): Double {
        for (i in sectionValues.indices) {
            if (value < sectionValues[i]) {
                return weights[i]
            }
        }
        return weights.last()
    }
}