|
@@ -39,30 +39,58 @@ void MatterElementAnalysis::evaluate(const QVector<double> &weights)
|
|
evaluationlevel(weights);
|
|
evaluationlevel(weights);
|
|
}
|
|
}
|
|
|
|
|
|
-void MatterElementAnalysis::associatedValue(int sam, int index, double value)
|
|
|
|
|
|
+static double correlationP(double value, double left, double right)
|
|
{
|
|
{
|
|
- auto pFunc = [](double v, double left, double right) {
|
|
|
|
- return std::abs(v - (left + right) / 2) - (right - left) / 2;
|
|
|
|
- };
|
|
|
|
|
|
+ return std::abs(value - (left + right) / 2) - (right - left) / 2;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static bool containValue(double value, bool left_close, bool right_close, double left, double right)
|
|
|
|
+{
|
|
|
|
+ if (value > left && value < right)
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ if (value == left && left_close)
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ if (value == right && right_close)
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
|
|
|
|
+void MatterElementAnalysis::associatedValue(int sam, int index, double value)
|
|
|
|
+{
|
|
double r = 0;
|
|
double r = 0;
|
|
- for (int i = 0; i < ranges_.count() - 1; ++i) // i是等级,index是指标
|
|
|
|
|
|
+ for (int i = 0; i < ranges_.count() - 1; ++i) //i是等级,index是指标
|
|
{
|
|
{
|
|
- // Q_ASSERT(ranges_.at(i).at(index).index == index);
|
|
|
|
|
|
+ Q_ASSERT(ranges_.at(i).at(index).index == index);
|
|
double minValue = ranges_.at(i).at(index).min_value;
|
|
double minValue = ranges_.at(i).at(index).min_value;
|
|
double maxValue = ranges_.at(i).at(index).max_value;
|
|
double maxValue = ranges_.at(i).at(index).max_value;
|
|
- double minend = ranges_.last().at(index).min_value;
|
|
|
|
- double maxend = ranges_.last().at(index).max_value;
|
|
|
|
- double r1 = pFunc(value, minValue, maxValue);
|
|
|
|
- double r2 = pFunc(value, minend, maxend);
|
|
|
|
-
|
|
|
|
- if (abs(r1 - r2) <= 0.00000001) {
|
|
|
|
- r = -r1 - 1;
|
|
|
|
- } else {
|
|
|
|
- r = r1 / (r2 - r1);
|
|
|
|
|
|
+ bool leftValueClose = ranges_.at(i).at(index).left_close;
|
|
|
|
+ bool rightValueClose = ranges_.at(i).at(index).right_close;
|
|
|
|
+ double r1 = correlationP(value, minValue, maxValue);
|
|
|
|
+
|
|
|
|
+ if (containValue(value, leftValueClose, rightValueClose, minValue, maxValue))
|
|
|
|
+ {
|
|
|
|
+ r = -r1 / abs(maxValue - minValue);
|
|
}
|
|
}
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ double minEnd = ranges_.last().at(index).min_value;
|
|
|
|
+ double maxEnd = ranges_.last().at(index).max_value;
|
|
|
|
+ double r2 = correlationP(value, minEnd, maxEnd);
|
|
|
|
+ if (abs(r1 - r2) <= 0.00000001)
|
|
|
|
+ {
|
|
|
|
+ r = -r1 - 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ r = r1 / (r2 - r1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
range_cvt_[sam][index][i] = r;
|
|
range_cvt_[sam][index][i] = r;
|
|
- // 结果放在range_cvt_
|
|
|
|
|
|
+ //结果放在range_cvt_
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|