|
@@ -6,17 +6,9 @@ import index.alg.analyse.CalHpTimeDistance;
|
|
|
import index.entity.OccupyPerX;
|
|
|
import index.entity.Point;
|
|
|
import index.entity.WholeIndexOccupy;
|
|
|
-import index.file.OperateFile;
|
|
|
import index.fit.Fit;
|
|
|
-import index.plot.Plot;
|
|
|
-import org.apache.commons.math3.analysis.function.Gaussian;
|
|
|
-
|
|
|
-import java.io.FileNotFoundException;
|
|
|
-import java.sql.SQLException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
public class Cal {
|
|
|
ArrayList<OccupyPerX> occupyPerXArrayList = new ArrayList<>();//占用情况
|
|
@@ -27,9 +19,7 @@ public class Cal {
|
|
|
GetPoints getPoints = new GetPoints();
|
|
|
getPoints.getPoints(workDirection);
|
|
|
ArrayList<Point> realShapePoints = getPoints.realShapePoints;//实际形状的平面坐标
|
|
|
-// GetPoints getPoints = new GetPoints();//所有待计算点
|
|
|
ArrayList<Point> allPoints = getPoints.allPoints;//所有待计算点,铲车作业平面坐标
|
|
|
-
|
|
|
///
|
|
|
ArrayList<ArrayList<Date>> dateForAna = getPoints.dateForAna;
|
|
|
CalHpTimeDistance calHpTimeDistance = new CalHpTimeDistance(dateForAna);
|
|
@@ -41,9 +31,6 @@ public class Cal {
|
|
|
ArrayList<Double> xIndexCorList = split.xIndexCorList;//格点横坐标List
|
|
|
ArrayList<Double> yIndexCorList = split.yIndexCorList;//格点纵坐标List
|
|
|
WholeIndexOccupy wholeIndexOccupy = split.wholeIndexOccupy;//初始垛位的占用情况
|
|
|
-// ArrayList<Point> occupyShapeList = wholeIndexOccupy.getOccupyPointsArrayList();//坐标形式的初始形状
|
|
|
- System.out.println(occupyPerXArrayList);
|
|
|
-// wholeIndexOccupy.printOccupy();
|
|
|
Double xGap = split.xGap;//横向上采用的间隔
|
|
|
Double yGap = split.yGap;//纵向上采用的间隔
|
|
|
Double minX = xIndexCorList.get(0);
|
|
@@ -53,11 +40,6 @@ public class Cal {
|
|
|
wholeIndexOccupy.printOccupy(minX,minY,xGap,yGap);
|
|
|
ArrayList<Point> occupyShapeList = wholeIndexOccupy.getOccupyPointsArrayList();//坐标形式的初始形状
|
|
|
ArrayList<Point> pointAfterExclude = new ArrayList<>();//过滤后的所有点的坐标
|
|
|
- OperateFile operateFile = new OperateFile();
|
|
|
- //所有的作业轨迹点,只是点,不用连成直线
|
|
|
-// operateFile.printPoint("Y:\\allpoints.txt",allPoints);
|
|
|
- operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/allpoints.txt",allPoints);
|
|
|
- operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/initialcor.txt",occupyShapeList);
|
|
|
//对待计算点,进行过滤,过滤掉在网格以外的,这部分后面单独写个过滤类
|
|
|
for(int i = 0 ; i < allPoints.size();i++){
|
|
|
Point point = allPoints.get(i);
|
|
@@ -74,25 +56,11 @@ public class Cal {
|
|
|
boxFlow.start(realShapePoints,pointAfterExclude);
|
|
|
//
|
|
|
|
|
|
- //对所有的轨迹点经过排除后剩下来的点
|
|
|
-// operateFile.printPoint("Y:\\pointsexclude.txt",pointAfterExclude);
|
|
|
- operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/pointsexclude.txt",pointAfterExclude);
|
|
|
-
|
|
|
|
|
|
|
|
|
//占用的网格为1,不占用的网格0
|
|
|
ArrayList<ArrayList<Integer>> occupyList = changeWholeIndexOccupyToList(wholeIndexOccupy);
|
|
|
-// for (int i = 0; i < occupyList.size();i++){
|
|
|
-//
|
|
|
-// System.out.println("ceshi");
|
|
|
-// System.out.println(occupyList.get(i));
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-// System.out.println(occupyList);
|
|
|
-
|
|
|
|
|
|
-// System.out.println("print all points---------------" );
|
|
|
|
|
|
for (int i = 0; i < pointAfterExclude.size();i++){
|
|
|
|
|
@@ -101,7 +69,6 @@ public class Cal {
|
|
|
Double y = point.getColY();
|
|
|
|
|
|
|
|
|
-// System.out.println( x + " " + y);
|
|
|
|
|
|
Integer xIndex = split.identifyXIndex(x);
|
|
|
Integer yIndex = split.identifyYIndex(y);
|
|
@@ -113,7 +80,6 @@ public class Cal {
|
|
|
occupyList.set(xIndex,arrayList);
|
|
|
}
|
|
|
}
|
|
|
-// System.out.println("print all points end -----------");
|
|
|
|
|
|
for (int i = 0 ; i < occupyList.size();i++){
|
|
|
ArrayList<Integer> arrayList = occupyList.get(i);
|
|
@@ -122,7 +88,6 @@ public class Cal {
|
|
|
StringBuffer sb1 = new StringBuffer();
|
|
|
for (int jj = 0 ; jj < arrayList.size();jj++){
|
|
|
if (arrayList.get(jj).toString().equals("0")){
|
|
|
-// System.out.println("该列有空格");
|
|
|
sb.append(" ");
|
|
|
sb1.append("+");
|
|
|
}
|
|
@@ -133,7 +98,6 @@ public class Cal {
|
|
|
}
|
|
|
String arrayListString = sb.toString();
|
|
|
String arrayListString1 = sb1.toString();
|
|
|
- System.out.println("print string----------" + arrayListString1);
|
|
|
String[] arrays = arrayListString.split("\\s+");
|
|
|
String maxString ="";
|
|
|
//这里需要再想想
|
|
@@ -160,19 +124,7 @@ public class Cal {
|
|
|
point.setColX(xCor);
|
|
|
point.setColY(yCor);
|
|
|
shape.add(point);
|
|
|
-// OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
|
|
|
-// Double xCor1 = minX + i * xGap;
|
|
|
-// Double xCor2 = minX + i * xGap + xGap;
|
|
|
-// Integer yIndex = occupyPerX.maxYIndex;
|
|
|
-// Double yCor = minY + yIndex * yGap + 0.5 * yGap;
|
|
|
-// Point point1 = new Point();
|
|
|
-// point1.setColX(xCor1);
|
|
|
-// point1.setColY(yCor);
|
|
|
-// Point point2 = new Point();
|
|
|
-// point2.setColX(xCor2);
|
|
|
-// point2.setColY(yCor);
|
|
|
-// shape.add(point1);
|
|
|
-// shape.add(point2);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
for (int i = (occupyPerXArrayList.size() -1) ; i >=0;i--){
|
|
@@ -184,19 +136,7 @@ public class Cal {
|
|
|
point.setColX(xCor);
|
|
|
point.setColY(yCor);
|
|
|
shape.add(point);
|
|
|
-// OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
|
|
|
-// Double xCor1 = minX + i * xGap;
|
|
|
-// Double xCor2 = minX + i * xGap + xGap;
|
|
|
-// Integer yIndex = occupyPerX.minYIndex;
|
|
|
-// Double yCor = minY + yIndex * yGap + 0.5 * yGap;
|
|
|
-// Point point1 = new Point();
|
|
|
-// point1.setColX(xCor1);
|
|
|
-// point1.setColY(yCor);
|
|
|
-// Point point2 = new Point();
|
|
|
-// point2.setColX(xCor2);
|
|
|
-// point2.setColY(yCor);
|
|
|
-// shape.add(point2);
|
|
|
-// shape.add(point1);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//对算法结果做一些调整
|
|
@@ -207,26 +147,8 @@ public class Cal {
|
|
|
|
|
|
//填充空值
|
|
|
Adjust adjust = new Adjust();
|
|
|
-// ArrayList<Point> shapeFill = fit.allCircleFitDefault(afterAdjustPointsList);
|
|
|
-// shape = fit.excludePoints(shape);
|
|
|
shape.add(shape.get(0));
|
|
|
ArrayList<Point> afterAdjustPointsList = adjust.fillArrayListPlus(occupyShapeList,shape,10);
|
|
|
-// System.out.println(shape.size());
|
|
|
-// for (int i = 0 ; i < shape.size() ; i++){
|
|
|
-// System.out.println(shape.get(i).getColX() + " " + shape.get(i).getColY() );
|
|
|
-// System.out.println(shape.get(i).getColY());
|
|
|
-// }
|
|
|
-
|
|
|
- //计算后垛位形状,已经网格化处理
|
|
|
-// operateFile.printPoint("Y:\\changed.txt",shape);
|
|
|
-// Special special = new Special();
|
|
|
- operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/changed.txt",shape);
|
|
|
-// operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/changedFill.txt",shapeFill);
|
|
|
- //拟合
|
|
|
- operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/changedFill.txt",shapeFill);
|
|
|
- //对计算结果进行修正,
|
|
|
-// operateFile.printPoint("Y:\\adjustchanged.txt",afterAdjustPointsList);
|
|
|
- operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/adjustchanged.txt",afterAdjustPointsList);
|
|
|
|
|
|
///打印,临时用的,主要是为了调整坐标
|
|
|
PointXYCorRevise pointXYCorRevise = new PointXYCorRevise();
|
|
@@ -234,7 +156,6 @@ public class Cal {
|
|
|
for (int i = 0 ; i <realShapePoints.size();i++){
|
|
|
|
|
|
Point point = realShapePoints.get(i);
|
|
|
- System.out.println(point.getColX() + " " + point.getColY());
|
|
|
|
|
|
}
|
|
|
|
|
@@ -245,44 +166,11 @@ public class Cal {
|
|
|
for (int i = 0 ; i < realShapePoints.size();i++){
|
|
|
|
|
|
Point point = realShapePoints.get(i);
|
|
|
- System.out.println(point.getColX() + " " + point.getColY());
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/revise/initial.txt",realShapePoints);
|
|
|
- operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/revise/adjustchanged.txt",afterAdjustPointsList);
|
|
|
- operateFile.printPoint("/Users/haoqianpan/file/programfile/meanshift/out/revise/pointsexclude.txt",pointAfterExclude);
|
|
|
-
|
|
|
-
|
|
|
-// Plot plot = new Plot();
|
|
|
-// Map mapInitialShape = new HashMap();
|
|
|
-// Map mapAdjustChanged = new HashMap();
|
|
|
-// Map mapPointExclude = new HashMap();
|
|
|
-//
|
|
|
-// mapInitialShape.put("FILE_NAME","initial.txt");
|
|
|
-// mapInitialShape.put("POINTS_LIST",realShapePoints);
|
|
|
-//
|
|
|
-// mapAdjustChanged.put("FILE_NAME","adjustchanged.txt");
|
|
|
-// mapAdjustChanged.put("POINTS_LIST",afterAdjustPointsList);
|
|
|
-//
|
|
|
-// mapPointExclude.put("FILE_NAME","pointsexclude.txt");
|
|
|
-// mapPointExclude.put("POINTS_LIST",pointAfterExclude);
|
|
|
-//
|
|
|
-// ArrayList<Map> mapArrayList = new ArrayList<>();
|
|
|
-// mapArrayList.add(mapInitialShape);
|
|
|
-// mapArrayList.add(mapAdjustChanged);
|
|
|
-// mapArrayList.add(mapPointExclude);
|
|
|
-//
|
|
|
-// plot.revisePlot("/Users/haoqianpan/file/programfile/meanshift/out/revise/",mapArrayList);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return shape;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -291,7 +179,6 @@ public class Cal {
|
|
|
|
|
|
ArrayList<OccupyPerX> occupyPerXArrayList = wholeIndexOccupy.getOccupyPerXArrayList();
|
|
|
|
|
|
- System.out.println(occupyPerXArrayList);
|
|
|
|
|
|
Integer numOfGaps = occupyPerXArrayList.size();
|
|
|
|
|
@@ -319,7 +206,6 @@ public class Cal {
|
|
|
|
|
|
ArrayList<Integer> arrayList = occupyList.get(i);
|
|
|
|
|
|
-// if ()
|
|
|
|
|
|
for (int j = minYIndex ; j < (maxYIndex + 1); j++){
|
|
|
|
|
@@ -338,24 +224,18 @@ public class Cal {
|
|
|
|
|
|
public ArrayList<Point> adjustShape(ArrayList<Point> initialShapeList,ArrayList<Point> changedShapeList,Integer adjustSize){
|
|
|
|
|
|
-// Integer size = initialShapeList.size() - 1;
|
|
|
Integer size = initialShapeList.size();
|
|
|
//
|
|
|
- System.out.println(size + "size");
|
|
|
-
|
|
|
ArrayList<Point> afterAdjustPointsList = new ArrayList<>();
|
|
|
|
|
|
Integer round = size / adjustSize;
|
|
|
|
|
|
- System.out.println(round + "round");
|
|
|
-
|
|
|
for (int i = 0; i < round ;i++){
|
|
|
|
|
|
Integer indexBegin = i * adjustSize;
|
|
|
Integer indexEnd = indexBegin + adjustSize;
|
|
|
|
|
|
Double avgDec = 0.0;
|
|
|
- //
|
|
|
ArrayList<Point> pointArrayList = new ArrayList<>();//存放差值,借用arraylist<point>
|
|
|
|
|
|
for (int j = indexBegin;j < indexEnd; j++){
|
|
@@ -366,53 +246,24 @@ public class Cal {
|
|
|
pointDis.setColX(chaPoint.getColX());
|
|
|
pointArrayList.add(pointDis);
|
|
|
avgDec = avgDec + chaPoint.getColY() - iniPoint.getColY();
|
|
|
- System.out.println("差值" + (chaPoint.getColY() - iniPoint.getColY()));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-// double[] param = fit.gaussFit(pointArrayList);
|
|
|
- //求高斯分布值
|
|
|
-// Gaussian gaussian = new Gaussian(param[0],param[1],param[2]);
|
|
|
-// ArrayList<Double> dPoint = new ArrayList<>();
|
|
|
-// for (int ii = 0 ; ii < pointArrayList.size();ii++){
|
|
|
-//
|
|
|
-// Point point = pointArrayList.get(ii);
|
|
|
-// Double x = point.getColX();
|
|
|
-// Double y = gaussian.value(x);
|
|
|
-// dPoint.add(y);
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
avgDec = avgDec / adjustSize;
|
|
|
-// System.out.println(avgDec + " avgdec");
|
|
|
|
|
|
for (int j = indexBegin ; j < indexEnd;j++){
|
|
|
|
|
|
-// Point chaPoint = changedShapeList.get(j);
|
|
|
Point intPoint = initialShapeList.get(j);
|
|
|
Point adjustPoint = new Point();
|
|
|
adjustPoint.setColX(intPoint.getColX());
|
|
|
adjustPoint.setColY(intPoint.getColY() + avgDec);
|
|
|
-// adjustPoint.setColY(intPoint.getColY() + gaussian.value(intPoint.getColX()));
|
|
|
-// System.out.println(new Date());
|
|
|
|
|
|
afterAdjustPointsList.add(adjustPoint);
|
|
|
}
|
|
|
//后面扩充不整除的情况
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-// afterAdjustPointsList.add(afterAdjustPointsList.get(0));
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return afterAdjustPointsList;
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|