修改判读方案算法
This commit is contained in:
@@ -2,6 +2,7 @@ package com.cnbm.qualityPlanning.common;
|
||||
|
||||
|
||||
import com.cnbm.qualityPlanning.entity.*;
|
||||
import io.swagger.models.auth.In;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
@@ -608,76 +609,109 @@ public class StatisticalControlledTest {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* name : 规则5
|
||||
* desc : 连续 m 点中 有 n 点 落在中心线同一侧,B区以外。( 默认 m:3 , n:2 )
|
||||
* 注意: 如果存在满足rule5的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
||||
* 注意:
|
||||
* ① 如果存在满足rule5的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
||||
* ② 如果如果存在UB外和 LB外的连续 数据也是算的
|
||||
* return :
|
||||
* 存在满足rule5的点 => true
|
||||
* 不存在满足rule5的点 => false
|
||||
*
|
||||
* Test status: OK(CaiXiang)
|
||||
*
|
||||
* */
|
||||
public static Boolean rule5(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
||||
Boolean result = false;
|
||||
Integer upi = 0;
|
||||
List<Point> upforMarkKey = new ArrayList<>();
|
||||
List<Point> downforMarkKey = new ArrayList<>();
|
||||
// Double[] dataArray = (Double[])data.toArray();
|
||||
Object[] dataArray = data.toArray();
|
||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||
System.out.println("controlLimitDetail : "+controlLimitDetail.toString());
|
||||
Boolean lastFlag = false;
|
||||
while(upi < data.size()){
|
||||
Point[] keyList = new Point[m];
|
||||
if(m>=(data.size()-upi)){
|
||||
if(lastFlag){
|
||||
break;
|
||||
}
|
||||
//System.arraycopy(dataArray , 10 , keyList , 0 , 2 );
|
||||
System.arraycopy(dataArray,upi,keyList,0,(data.size()-upi));
|
||||
lastFlag = true;
|
||||
}else {
|
||||
System.arraycopy(dataArray,upi,keyList,0,m);
|
||||
private static void rule5Core(List<Point> data,Integer m,Integer n){
|
||||
//开始
|
||||
Stack<Point> stack = new Stack<Point>();
|
||||
int seqNum = 0;
|
||||
int i = 0;
|
||||
while((i+1)< data.size()){
|
||||
if(stack.size()==0){
|
||||
stack.push(data.get(i));
|
||||
i++;
|
||||
seqNum++;
|
||||
}
|
||||
|
||||
Integer upTimes = 0;
|
||||
Integer downTimes = 0;
|
||||
for(Point i:keyList){
|
||||
if(i.getValueForInterpretation()>controlLimitDetail.getUB()[1]){
|
||||
upTimes++;
|
||||
upforMarkKey.add(i);
|
||||
System.out.println();
|
||||
}
|
||||
if(i.getValueForInterpretation()<controlLimitDetail.getLB()[0]){
|
||||
downTimes++;
|
||||
downforMarkKey.add(i);
|
||||
}
|
||||
}
|
||||
if(upTimes>=n || downTimes>=n){
|
||||
result = true;
|
||||
if(upTimes>=n){
|
||||
for(Point i:upforMarkKey){
|
||||
i.getUnsatisfiedRules().add(rule5Number);
|
||||
}
|
||||
upforMarkKey = new ArrayList<>();
|
||||
// return true;
|
||||
}
|
||||
if(downTimes>=n){
|
||||
for(Point i:downforMarkKey){
|
||||
i.getUnsatisfiedRules().add(rule5Number);
|
||||
}
|
||||
downforMarkKey = new ArrayList<>();
|
||||
// return true;
|
||||
}
|
||||
|
||||
// return true;
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(data.get(i));
|
||||
}else {
|
||||
upforMarkKey = new ArrayList<>();
|
||||
downforMarkKey = new ArrayList<>();
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
Boolean seqNumIsOK = (seqNum>=m);
|
||||
if(stackIsFull && seqNumIsOK){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule5Number);
|
||||
}
|
||||
}
|
||||
stack.clear();
|
||||
stack.push(data.get(i));
|
||||
}
|
||||
upi++;
|
||||
|
||||
i++;
|
||||
seqNum++;
|
||||
}
|
||||
//判断最后一次情况
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(data.get(i));
|
||||
seqNum++;
|
||||
}else {
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
Boolean seqNumIsOK = (seqNum>=m);
|
||||
if(stackIsFull && seqNumIsOK){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule5Number);
|
||||
}
|
||||
}
|
||||
stack.clear();
|
||||
stack.push(data.get(i));
|
||||
}
|
||||
|
||||
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
Boolean seqNumIsOK = (seqNum>=m);
|
||||
if(stackIsFull && seqNumIsOK){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule5Number);
|
||||
}
|
||||
}
|
||||
//结束
|
||||
}
|
||||
public static Boolean rule5(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
||||
Boolean result = false;
|
||||
|
||||
List<Point> upforMarkKey = new ArrayList<>();
|
||||
List<Point> downforMarkKey = new ArrayList<>();
|
||||
|
||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||
System.out.println("controlLimitDetail : "+controlLimitDetail.toString());
|
||||
|
||||
|
||||
//1.先把异常数据都整理出来
|
||||
// for(Point i:data){
|
||||
// if(i.getValueForInterpretation()>controlLimitDetail.getUB()[1] || i.getValueForInterpretation()<controlLimitDetail.getLB()[0]){
|
||||
// upforMarkKey.add(i);
|
||||
// }
|
||||
// }
|
||||
for(Point i:data){
|
||||
if(i.getValueForInterpretation()>controlLimitDetail.getUB()[1]){
|
||||
upforMarkKey.add(i);
|
||||
}
|
||||
if(i.getValueForInterpretation()<controlLimitDetail.getLB()[0]){
|
||||
downforMarkKey.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
//2.再用rule5进行分析
|
||||
rule5Core(upforMarkKey,m,n);
|
||||
rule5Core(downforMarkKey,m,n);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -688,73 +722,165 @@ public class StatisticalControlledTest {
|
||||
* return :
|
||||
* 存在满足rule6的点 => true
|
||||
* 不存在满足rule6的点 => false
|
||||
* Test status: OK(CaiXiang)
|
||||
* */
|
||||
public static Boolean rule6(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
||||
Boolean result = false;
|
||||
Integer upi = 0;
|
||||
List<Point> upforMarkKey = new ArrayList<>();
|
||||
List<Point> downforMarkKey = new ArrayList<>();
|
||||
// Double[] dataArray = (Double[])data.toArray();
|
||||
Object[] dataArray = data.toArray();
|
||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||
System.out.println("controlLimitDetail : "+controlLimitDetail.toString());
|
||||
Boolean lastFlag = false;
|
||||
while(upi < data.size()){
|
||||
Point[] keyList = new Point[m];
|
||||
if(m>=(data.size()-upi)){
|
||||
if(lastFlag){
|
||||
break;
|
||||
}
|
||||
//System.arraycopy(dataArray , 10 , keyList , 0 , 2 );
|
||||
System.arraycopy(dataArray,upi,keyList,0,(data.size()-upi));
|
||||
lastFlag = true;
|
||||
// public static Boolean rule6(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
||||
// Boolean result = false;
|
||||
// Integer upi = 0;
|
||||
// List<Point> upforMarkKey = new ArrayList<>();
|
||||
// List<Point> downforMarkKey = new ArrayList<>();
|
||||
//// Double[] dataArray = (Double[])data.toArray();
|
||||
// Object[] dataArray = data.toArray();
|
||||
// ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||
// System.out.println("controlLimitDetail : "+controlLimitDetail.toString());
|
||||
// Boolean lastFlag = false;
|
||||
// while(upi < data.size()){
|
||||
// Point[] keyList = new Point[m];
|
||||
// if(m>=(data.size()-upi)){
|
||||
// if(lastFlag){
|
||||
// break;
|
||||
// }
|
||||
// //System.arraycopy(dataArray , 10 , keyList , 0 , 2 );
|
||||
// System.arraycopy(dataArray,upi,keyList,0,(data.size()-upi));
|
||||
// lastFlag = true;
|
||||
// }else {
|
||||
// System.arraycopy(dataArray,upi,keyList,0,m);
|
||||
// }
|
||||
//
|
||||
// Integer upTimes = 0;
|
||||
// Integer downTimes = 0;
|
||||
// for(Point i:keyList){
|
||||
// if(i.getValueForInterpretation()>controlLimitDetail.getUC()[1]){
|
||||
// upTimes++;
|
||||
// upforMarkKey.add(i);
|
||||
//
|
||||
// }
|
||||
// if(i.getValueForInterpretation()<controlLimitDetail.getLC()[0]){
|
||||
// downTimes++;
|
||||
// downforMarkKey.add(i);
|
||||
// }
|
||||
// }
|
||||
// if(upTimes>=n || downTimes>=n){
|
||||
// result = true;
|
||||
// if(upTimes>=n){
|
||||
// for(Point i:upforMarkKey){
|
||||
//
|
||||
// i.getUnsatisfiedRules().add(rule6Number);
|
||||
// }
|
||||
// upforMarkKey = new ArrayList<>();
|
||||
//// return true;
|
||||
// }
|
||||
// if(downTimes>=n){
|
||||
// for(Point i:downforMarkKey){
|
||||
// if(i.getPosition() == 13){
|
||||
// System.out.println(1);
|
||||
// }
|
||||
// i.getUnsatisfiedRules().add(rule6Number);
|
||||
// }
|
||||
//// return true;
|
||||
// downforMarkKey = new ArrayList<>();
|
||||
// }
|
||||
//
|
||||
//// return true;
|
||||
// }else {
|
||||
// upforMarkKey = new ArrayList<>();
|
||||
// downforMarkKey = new ArrayList<>();
|
||||
// }
|
||||
// upi++;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
private static void rule6Core(List<Point> data,Integer m,Integer n){
|
||||
//开始
|
||||
Stack<Point> stack = new Stack<Point>();
|
||||
int seqNum = 0;
|
||||
int i = 0;
|
||||
while((i+1)< data.size()){
|
||||
if(stack.size()==0){
|
||||
stack.push(data.get(i));
|
||||
i++;
|
||||
seqNum++;
|
||||
}
|
||||
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(data.get(i));
|
||||
}else {
|
||||
System.arraycopy(dataArray,upi,keyList,0,m);
|
||||
}
|
||||
|
||||
Integer upTimes = 0;
|
||||
Integer downTimes = 0;
|
||||
for(Point i:keyList){
|
||||
if(i.getValueForInterpretation()>controlLimitDetail.getUC()[1]){
|
||||
upTimes++;
|
||||
upforMarkKey.add(i);
|
||||
|
||||
}
|
||||
if(i.getValueForInterpretation()<controlLimitDetail.getLC()[0]){
|
||||
downTimes++;
|
||||
downforMarkKey.add(i);
|
||||
}
|
||||
}
|
||||
if(upTimes>=n || downTimes>=n){
|
||||
result = true;
|
||||
if(upTimes>=n){
|
||||
for(Point i:upforMarkKey){
|
||||
|
||||
i.getUnsatisfiedRules().add(rule6Number);
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
Boolean seqNumIsOK = (seqNum>=m);
|
||||
if(stackIsFull && seqNumIsOK){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule6Number);
|
||||
}
|
||||
upforMarkKey = new ArrayList<>();
|
||||
// return true;
|
||||
}
|
||||
if(downTimes>=n){
|
||||
for(Point i:downforMarkKey){
|
||||
if(i.getPosition() == 13){
|
||||
System.out.println(1);
|
||||
}
|
||||
i.getUnsatisfiedRules().add(rule6Number);
|
||||
}
|
||||
// return true;
|
||||
downforMarkKey = new ArrayList<>();
|
||||
}
|
||||
|
||||
// return true;
|
||||
}else {
|
||||
upforMarkKey = new ArrayList<>();
|
||||
downforMarkKey = new ArrayList<>();
|
||||
stack.clear();
|
||||
stack.push(data.get(i));
|
||||
}
|
||||
upi++;
|
||||
|
||||
i++;
|
||||
seqNum++;
|
||||
}
|
||||
//判断最后一次情况
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(data.get(i));
|
||||
seqNum++;
|
||||
}else {
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
Boolean seqNumIsOK = (seqNum>=m);
|
||||
if(stackIsFull && seqNumIsOK){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule6Number);
|
||||
}
|
||||
}
|
||||
stack.clear();
|
||||
stack.push(data.get(i));
|
||||
}
|
||||
|
||||
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
Boolean seqNumIsOK = (seqNum>=m);
|
||||
if(stackIsFull && seqNumIsOK){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule6Number);
|
||||
}
|
||||
}
|
||||
//结束
|
||||
}
|
||||
public static Boolean rule6(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
||||
Boolean result = false;
|
||||
|
||||
List<Point> upforMarkKey = new ArrayList<>();
|
||||
List<Point> downforMarkKey = new ArrayList<>();
|
||||
|
||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||
System.out.println("controlLimitDetail : "+controlLimitDetail.toString());
|
||||
|
||||
|
||||
//1.先把异常数据都整理出来
|
||||
// for(Point i:data){
|
||||
// if(i.getValueForInterpretation()>controlLimitDetail.getUB()[1] || i.getValueForInterpretation()<controlLimitDetail.getLB()[0]){
|
||||
// upforMarkKey.add(i);
|
||||
// }
|
||||
// }
|
||||
for(Point i:data){
|
||||
if(i.getValueForInterpretation()>controlLimitDetail.getUC()[1]){
|
||||
upforMarkKey.add(i);
|
||||
}
|
||||
if(i.getValueForInterpretation()<controlLimitDetail.getLC()[0]){
|
||||
downforMarkKey.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
//2.再用rule5进行分析
|
||||
rule6Core(upforMarkKey,m,n);
|
||||
rule6Core(downforMarkKey,m,n);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -765,65 +891,151 @@ public class StatisticalControlledTest {
|
||||
* return :
|
||||
* 存在满足rule7的点 => true
|
||||
* 不存在满足rule7的点 => false
|
||||
* Test status: OK(CaiXiang)
|
||||
* */
|
||||
public static Boolean rule7(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||
|
||||
Boolean result = false;
|
||||
|
||||
//Integer upi = 0;
|
||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||
System.out.println(controlLimitDetail.toString());
|
||||
Integer times = 0;
|
||||
List<Point> markKey = new ArrayList<>();
|
||||
|
||||
|
||||
for(int i=0;i<data.size();i++){
|
||||
//判断最后一次
|
||||
if((i+1) == data.size()){
|
||||
Point point = data.get(i);
|
||||
if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()<controlLimitDetail.getUC()[1]){
|
||||
times++;
|
||||
markKey.add(point);
|
||||
if(times.equals(n)){
|
||||
for(Point j:markKey){
|
||||
j.getUnsatisfiedRules().add(rule7Number);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
times = 0;
|
||||
markKey = new ArrayList<>();
|
||||
}
|
||||
break;
|
||||
// public static Boolean rule7(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||
//
|
||||
// Boolean result = false;
|
||||
//
|
||||
// //Integer upi = 0;
|
||||
// ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||
// System.out.println(controlLimitDetail.toString());
|
||||
// Integer times = 0;
|
||||
// List<Point> markKey = new ArrayList<>();
|
||||
//
|
||||
//
|
||||
// for(int i=0;i<data.size();i++){
|
||||
// //判断最后一次
|
||||
// if((i+1) == data.size()){
|
||||
// Point point = data.get(i);
|
||||
// if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()<controlLimitDetail.getUC()[1]){
|
||||
// times++;
|
||||
// markKey.add(point);
|
||||
// if(times.equals(n)){
|
||||
// for(Point j:markKey){
|
||||
// j.getUnsatisfiedRules().add(rule7Number);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// }else {
|
||||
// times = 0;
|
||||
// markKey = new ArrayList<>();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// //通常情况
|
||||
// Point point = data.get(i);
|
||||
// if( isBetween( data.get(i),data.get(i+1) ) ){
|
||||
// if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()<controlLimitDetail.getUC()[1]){
|
||||
// times++;
|
||||
// markKey.add(point);
|
||||
// if(times.equals(n)){
|
||||
// for(Point j:markKey){
|
||||
// j.getUnsatisfiedRules().add(rule7Number);
|
||||
// }
|
||||
//// return true;
|
||||
// result = true;
|
||||
// times = 0;
|
||||
// markKey = new ArrayList<>();
|
||||
// }
|
||||
// }else {
|
||||
// times = 0;
|
||||
// markKey = new ArrayList<>();
|
||||
// }
|
||||
// }else {
|
||||
// times = 0;
|
||||
// markKey = new ArrayList<>();
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
private static void rule7Core(List<Point> data,Integer n){
|
||||
//开始
|
||||
Stack<Point> stack = new Stack<Point>();
|
||||
int i = 0;
|
||||
while((i+1)< data.size()){
|
||||
if(stack.size()==0){
|
||||
stack.push(data.get(i));
|
||||
i++;
|
||||
}
|
||||
|
||||
//通常情况
|
||||
Point point = data.get(i);
|
||||
if( isBetween( data.get(i),data.get(i+1) ) ){
|
||||
if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()<controlLimitDetail.getUC()[1]){
|
||||
times++;
|
||||
markKey.add(point);
|
||||
if(times.equals(n)){
|
||||
for(Point j:markKey){
|
||||
j.getUnsatisfiedRules().add(rule7Number);
|
||||
}
|
||||
// return true;
|
||||
result = true;
|
||||
times = 0;
|
||||
markKey = new ArrayList<>();
|
||||
}
|
||||
}else {
|
||||
times = 0;
|
||||
markKey = new ArrayList<>();
|
||||
}
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(data.get(i));
|
||||
}else {
|
||||
times = 0;
|
||||
markKey = new ArrayList<>();
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
|
||||
if(stackIsFull){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule7Number);
|
||||
}
|
||||
}
|
||||
stack.clear();
|
||||
stack.push(data.get(i));
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
//判断最后一次情况
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(data.get(i));
|
||||
|
||||
}else {
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
|
||||
if(stackIsFull){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule7Number);
|
||||
}
|
||||
}
|
||||
stack.clear();
|
||||
stack.push(data.get(i));
|
||||
}
|
||||
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
|
||||
if(stackIsFull){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule7Number);
|
||||
}
|
||||
}
|
||||
//结束
|
||||
}
|
||||
|
||||
public static Boolean rule7(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||
Boolean result = false;
|
||||
|
||||
// List<Point> upforMarkKey = new ArrayList<>();
|
||||
// List<Point> downforMarkKey = new ArrayList<>();
|
||||
List<Point> errforMarkKey = new ArrayList<>();
|
||||
|
||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||
System.out.println("controlLimitDetail : "+controlLimitDetail.toString());
|
||||
|
||||
|
||||
//1.先把异常数据都整理出来
|
||||
for(Point i:data){
|
||||
if(i.getValueForInterpretation()>controlLimitDetail.getLC()[0] && i.getValueForInterpretation()<controlLimitDetail.getUC()[1]){
|
||||
errforMarkKey.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//2.再用rule5进行分析
|
||||
rule7Core(errforMarkKey,n);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* name : 规则8
|
||||
* desc : 连续 n 点 落在中心线两侧,且无一点在C区内。( 默认 n:8 )
|
||||
@@ -831,63 +1043,144 @@ public class StatisticalControlledTest {
|
||||
* return :
|
||||
* 存在满足rule8的点 => true
|
||||
* 不存在满足rule8的点 => false
|
||||
* Test status: OK(CaiXiang)
|
||||
* */
|
||||
public static Boolean rule8(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||
|
||||
Boolean result = true;
|
||||
//Integer upi = 0;
|
||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||
System.out.println(controlLimitDetail.toString());
|
||||
Integer times = 0;
|
||||
List<Point> markKey = new ArrayList<>();
|
||||
|
||||
|
||||
for(int i=0;i<data.size();i++){
|
||||
//判断最后一次
|
||||
if((i+1) == data.size()){
|
||||
Point point = data.get(i);
|
||||
if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()<controlLimitDetail.getLC()[0] ){
|
||||
times++;
|
||||
markKey.add(point);
|
||||
if(times.equals(n)){
|
||||
for(Point j:markKey){
|
||||
j.getUnsatisfiedRules().add(rule8Number);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
times = 0;
|
||||
markKey = new ArrayList<>();
|
||||
}
|
||||
break;
|
||||
// public static Boolean rule8(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||
//
|
||||
// Boolean result = true;
|
||||
// //Integer upi = 0;
|
||||
// ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||
// System.out.println(controlLimitDetail.toString());
|
||||
// Integer times = 0;
|
||||
// List<Point> markKey = new ArrayList<>();
|
||||
//
|
||||
//
|
||||
// for(int i=0;i<data.size();i++){
|
||||
// //判断最后一次
|
||||
// if((i+1) == data.size()){
|
||||
// Point point = data.get(i);
|
||||
// if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()<controlLimitDetail.getLC()[0] ){
|
||||
// times++;
|
||||
// markKey.add(point);
|
||||
// if(times.equals(n)){
|
||||
// for(Point j:markKey){
|
||||
// j.getUnsatisfiedRules().add(rule8Number);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// }else {
|
||||
// times = 0;
|
||||
// markKey = new ArrayList<>();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// //通常情况
|
||||
// Point point = data.get(i);
|
||||
// if( isBetween( data.get(i),data.get(i+1) ) ){
|
||||
// if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()<controlLimitDetail.getLC()[0] ){
|
||||
// times++;
|
||||
// markKey.add(point);
|
||||
// if(times.equals(n)){
|
||||
// for(Point j:markKey){
|
||||
// j.getUnsatisfiedRules().add(rule8Number);
|
||||
// }
|
||||
// result = true;
|
||||
// times = 0;
|
||||
// markKey = new ArrayList<>();
|
||||
// }
|
||||
// }else {
|
||||
// times = 0;
|
||||
// markKey = new ArrayList<>();
|
||||
// }
|
||||
// }else {
|
||||
// times = 0;
|
||||
// markKey = new ArrayList<>();
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
private static void rule8Core(List<Point> data,Integer n){
|
||||
//开始
|
||||
Stack<Point> stack = new Stack<Point>();
|
||||
int i = 0;
|
||||
while((i+1)< data.size()){
|
||||
if(stack.size()==0){
|
||||
stack.push(data.get(i));
|
||||
i++;
|
||||
}
|
||||
|
||||
//通常情况
|
||||
Point point = data.get(i);
|
||||
if( isBetween( data.get(i),data.get(i+1) ) ){
|
||||
if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()<controlLimitDetail.getLC()[0] ){
|
||||
times++;
|
||||
markKey.add(point);
|
||||
if(times.equals(n)){
|
||||
for(Point j:markKey){
|
||||
j.getUnsatisfiedRules().add(rule8Number);
|
||||
}
|
||||
result = true;
|
||||
times = 0;
|
||||
markKey = new ArrayList<>();
|
||||
}
|
||||
}else {
|
||||
times = 0;
|
||||
markKey = new ArrayList<>();
|
||||
}
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(data.get(i));
|
||||
}else {
|
||||
times = 0;
|
||||
markKey = new ArrayList<>();
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
|
||||
if(stackIsFull){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule8Number);
|
||||
}
|
||||
}
|
||||
stack.clear();
|
||||
stack.push(data.get(i));
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
//判断最后一次情况
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(data.get(i));
|
||||
|
||||
}else {
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
|
||||
if(stackIsFull){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule8Number);
|
||||
}
|
||||
}
|
||||
stack.clear();
|
||||
stack.push(data.get(i));
|
||||
}
|
||||
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
|
||||
if(stackIsFull){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(rule8Number);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
//结束
|
||||
}
|
||||
|
||||
public static Boolean rule8(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||
Boolean result = false;
|
||||
|
||||
// List<Point> upforMarkKey = new ArrayList<>();
|
||||
// List<Point> downforMarkKey = new ArrayList<>();
|
||||
List<Point> errforMarkKey = new ArrayList<>();
|
||||
|
||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||
System.out.println("controlLimitDetail : "+controlLimitDetail.toString());
|
||||
|
||||
//1.先把异常数据都整理出来
|
||||
for(Point i:data){
|
||||
if(i.getValueForInterpretation()>controlLimitDetail.getUC()[1] && i.getValueForInterpretation()<controlLimitDetail.getLC()[0]){
|
||||
errforMarkKey.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//2.再用rule5进行分析
|
||||
rule8Core(errforMarkKey,n);
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 如果 这两个点是相邻的 ==》 true
|
||||
* */
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.cnbm.qualityPlanning.common.test;
|
||||
|
||||
import com.cnbm.qualityPlanning.entity.Point;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* @Desc: ""
|
||||
* @Author: caixiang
|
||||
* @DATE: 2022/11/29 10:49
|
||||
*/
|
||||
public class MainRule5TEST {
|
||||
|
||||
public static void rule5Core(List<Point> upforMarkKey){
|
||||
//开始
|
||||
Stack<Point> stack = new Stack<Point>();
|
||||
int seqNum = 0;
|
||||
int i = 0;
|
||||
while((i+1)< upforMarkKey.size()){
|
||||
if(stack.size()==0){
|
||||
stack.push(upforMarkKey.get(i));
|
||||
i++;
|
||||
seqNum++;
|
||||
}
|
||||
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == upforMarkKey.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(upforMarkKey.get(i));
|
||||
}else {
|
||||
Boolean stackIsFull = (stack.size()>=3);
|
||||
Boolean seqNumIsOK = (seqNum>=5);
|
||||
if(stackIsFull && seqNumIsOK){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(5);
|
||||
}
|
||||
}
|
||||
stack.clear();
|
||||
stack.push(upforMarkKey.get(i));
|
||||
}
|
||||
|
||||
i++;
|
||||
seqNum++;
|
||||
}
|
||||
//判断最后一次情况
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == upforMarkKey.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(upforMarkKey.get(i));
|
||||
seqNum++;
|
||||
}else {
|
||||
Boolean stackIsFull = (stack.size()>=3);
|
||||
Boolean seqNumIsOK = (seqNum>=5);
|
||||
if(stackIsFull && seqNumIsOK){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(5);
|
||||
}
|
||||
}
|
||||
stack.clear();
|
||||
stack.push(upforMarkKey.get(i));
|
||||
}
|
||||
|
||||
|
||||
Boolean stackIsFull = (stack.size()>=3);
|
||||
Boolean seqNumIsOK = (seqNum>=5);
|
||||
if(stackIsFull && seqNumIsOK){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(5);
|
||||
}
|
||||
}
|
||||
//结束
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
List<Point> upforMarkKey = new ArrayList<>();
|
||||
Point point1 = new Point(1,1.0);
|
||||
Point point2 = new Point(2,1.0);
|
||||
Point point3 = new Point(4,1.0);
|
||||
Point point4 = new Point(5,1.0);
|
||||
Point point5 = new Point(6,1.0);
|
||||
Point point6 = new Point(7,1.0);
|
||||
Point point7 = new Point(8,1.0);
|
||||
Point point8 = new Point(10,1.0);
|
||||
Point point9 = new Point(11,1.0);
|
||||
Point point10 = new Point(13,1.0);
|
||||
Point point11 = new Point(14,1.0);
|
||||
Point point12 = new Point(15,1.0);
|
||||
Point point13 = new Point(16,1.0);
|
||||
Point point14 = new Point(17,1.0);
|
||||
|
||||
|
||||
upforMarkKey.add(point1);
|
||||
upforMarkKey.add(point2);
|
||||
upforMarkKey.add(point3);
|
||||
upforMarkKey.add(point4);
|
||||
upforMarkKey.add(point5);
|
||||
upforMarkKey.add(point6);
|
||||
upforMarkKey.add(point7);
|
||||
upforMarkKey.add(point8);
|
||||
upforMarkKey.add(point9);
|
||||
upforMarkKey.add(point10);
|
||||
upforMarkKey.add(point11);
|
||||
upforMarkKey.add(point12);
|
||||
upforMarkKey.add(point13);
|
||||
upforMarkKey.add(point14);
|
||||
|
||||
|
||||
rule5Core(upforMarkKey);
|
||||
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.cnbm.qualityPlanning.common.test;
|
||||
|
||||
import com.cnbm.qualityPlanning.entity.Point;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* @Desc: ""
|
||||
* @Author: caixiang
|
||||
* @DATE: 2022/11/29 10:49
|
||||
*/
|
||||
public class MainRule7TEST {
|
||||
|
||||
private static void rule7Core(List<Point> data,Integer n){
|
||||
//开始
|
||||
Stack<Point> stack = new Stack<Point>();
|
||||
int i = 0;
|
||||
while((i+1)< data.size()){
|
||||
if(stack.size()==0){
|
||||
stack.push(data.get(i));
|
||||
i++;
|
||||
}
|
||||
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(data.get(i));
|
||||
}else {
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
|
||||
if(stackIsFull){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(7);
|
||||
}
|
||||
}
|
||||
stack.clear();
|
||||
stack.push(data.get(i));
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
//判断最后一次情况
|
||||
Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition());
|
||||
if( sequence ){
|
||||
stack.push(data.get(i));
|
||||
|
||||
}else {
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
|
||||
if(stackIsFull){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(7);
|
||||
}
|
||||
}
|
||||
stack.clear();
|
||||
stack.push(data.get(i));
|
||||
}
|
||||
|
||||
Boolean stackIsFull = (stack.size()>=n);
|
||||
|
||||
if(stackIsFull){
|
||||
int size = stack.size();
|
||||
for(int s=0;s<size;s++){
|
||||
stack.pop().getUnsatisfiedRules().add(7);
|
||||
}
|
||||
}
|
||||
//结束
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
List<Point> upforMarkKey = new ArrayList<>();
|
||||
Point point1 = new Point(1,1.0);
|
||||
Point point2 = new Point(2,1.0);
|
||||
Point point3 = new Point(4,1.0);
|
||||
Point point4 = new Point(5,1.0);
|
||||
Point point5 = new Point(6,1.0);
|
||||
Point point6 = new Point(7,1.0);
|
||||
Point point7 = new Point(8,1.0);
|
||||
Point point8 = new Point(10,1.0);
|
||||
Point point9 = new Point(11,1.0);
|
||||
Point point10 = new Point(13,1.0);
|
||||
Point point11 = new Point(14,1.0);
|
||||
Point point12 = new Point(15,1.0);
|
||||
Point point13 = new Point(16,1.0);
|
||||
Point point14 = new Point(17,1.0);
|
||||
|
||||
|
||||
upforMarkKey.add(point1);
|
||||
upforMarkKey.add(point2);
|
||||
upforMarkKey.add(point3);
|
||||
upforMarkKey.add(point4);
|
||||
upforMarkKey.add(point5);
|
||||
upforMarkKey.add(point6);
|
||||
upforMarkKey.add(point7);
|
||||
upforMarkKey.add(point8);
|
||||
upforMarkKey.add(point9);
|
||||
upforMarkKey.add(point10);
|
||||
upforMarkKey.add(point11);
|
||||
upforMarkKey.add(point12);
|
||||
upforMarkKey.add(point13);
|
||||
upforMarkKey.add(point14);
|
||||
|
||||
|
||||
rule7Core(upforMarkKey,3);
|
||||
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,10 @@ public class ControlLimitDetail {
|
||||
Double agv1 = (this.UCL-this.CL)/3;
|
||||
this.UC[0] = this.CL;
|
||||
this.UC[1] = this.CL+agv1;
|
||||
this.UB[0] = this.UC[0];
|
||||
this.UB[1] = this.UC[0]+agv1;
|
||||
this.UA[0] = this.UB[0];
|
||||
this.UA[1] = this.UB[0]+agv1;
|
||||
this.UB[0] = this.UC[1];
|
||||
this.UB[1] = this.UB[0]+agv1;
|
||||
this.UA[0] = this.UB[1];
|
||||
this.UA[1] = this.UA[0]+agv1;
|
||||
|
||||
Double agv2 = (this.CL-this.LCL)/3;
|
||||
this.LC[0] = this.CL-agv2;
|
||||
|
||||
Reference in New Issue
Block a user