public static void addPotentialPoints(Item i, List <PotentialPoint> potentialPoints) { PotentialPoint xAxis = new PotentialPoint(i.getBottomLeftFront().x + i.getWidth(), i.getBottomLeftFront().y, i.getBottomLeftFront().z); PotentialPoint yAxis = new PotentialPoint(i.getBottomLeftFront().x, i.getBottomLeftFront().y + i.getHeight(), i.getBottomLeftFront().z); PotentialPoint zAxis = new PotentialPoint(i.getBottomLeftFront().x, i.getBottomLeftFront().y, i.getBottomLeftFront().z + i.getDepth()); if (!potentialPoints.Contains(xAxis)) { potentialPoints.Add(xAxis); } if (!potentialPoints.Contains(yAxis) && i.isStackable()) { potentialPoints.Add(yAxis); } if (!potentialPoints.Contains(zAxis)) { potentialPoints.Add(zAxis); } for (int j = 0; j < potentialPoints.Count; j++) { if (potentialPoints[j].equals(i.getBottomLeftFront())) { potentialPoints.RemoveAt(j); } } }
public static PotentialPoint createXAxisPotentialPointProjectionMax(Item i, int j, List <PotentialPoint> potentialPoints) { PotentialPoint cPointXAxisProjection = new PotentialPoint(i.getBottomRightRear().getX(), 0, i.getBottomLeftRear().getZ(), potentialPoints[j].getMaxXAllowed(), potentialPoints[j].getMaxYAllowed(), potentialPoints[j].getMaxZAllowed() - i.getDepth()); return(cPointXAxisProjection); }
public static PotentialPoint createYAxisPotentialPointRight(Item i, int j, List <PotentialPoint> potentialPoints) { PotentialPoint cPointYAxis = new PotentialPoint(i.getBottomRightFront().getX(), i.getBottomRightFront().getY() + i.getHeight(), i.getBottomLeftFront().getZ(), i.getWidth(), potentialPoints[j].getMaxYAllowed() - i.getHeight(), i.getDepth()); return(cPointYAxis); }
public static PotentialPoint createPointProjectionZ(Item i, int j, List <PotentialPoint> potentialPoints) { PotentialPoint cPointXAxis = new PotentialPoint(0, i.getBottomLeftFront().getY(), i.getBottomRightFront().getZ(), potentialPoints[j].getMaxXAllowed() - i.getWidth(), potentialPoints[j].getMaxYAllowed(), potentialPoints[j].getMaxZAllowed() - i.getDepth()); return(cPointXAxis); }
public bool checkAddItem(Item i, List <PotentialPoint> supportPoints, double minHeight) { //SHUFFLE if (supportPoints.Any() && this.weightFits(i)) { // supportPoints.sort(Comparator.comparing(PotentialPoint::getY).thenComparing(PotentialPoint::getZ)); // int randomNum = ThreadLocalRandom.current().nextInt(1, 6); for (int j = 0; j < supportPoints.Count; j++) { PotentialPoint supportPoint = supportPoints[j]; i.setBottomLeftFront(supportPoint); if ((!this.itemsOverlapping(i)) && (this.dimensionsFit(i)) && (supportPoint.cornerCheck(i, this, minHeight))) { PotentialPoint cPointXAxis = PotentialPoint.createXAxisPotentialPoint(i, j, supportPoints); PotentialPoint cPointZAxis = PotentialPoint.createZAxisPotentialPoint(i, j, supportPoints); PotentialPoint.addPointToPotentialPoints(cPointXAxis, supportPoints); PotentialPoint.addPointToPotentialPoints(cPointZAxis, supportPoints); if (i.isStackable()) { PotentialPoint cPointYAxis = PotentialPoint.createYAxisPotentialPoint(i, j, supportPoints); PotentialPoint.addPointToPotentialPoints(cPointYAxis, supportPoints); } PotentialPoint cPointXAxisProjectionMax = PotentialPoint.createXAxisPotentialPointProjectionMax(i, j, supportPoints); PotentialPoint.addPointToPotentialPoints(cPointXAxisProjectionMax, supportPoints); /*Remove chosen support point*/ PotentialPoint.usedPotentialPoints.Add(supportPoints[j]); bool removed = supportPoints.Remove(supportPoints[j]); return(true); } } } return(false); }
public static void addToUsedPotentialPoints(PotentialPoint sp) { usedPotentialPoints.Add(sp); }
/** * * @param p * @param potentialPoints */ public static void addPointToPotentialPoints(PotentialPoint p, List <PotentialPoint> potentialPoints) { potentialPoints.Add(p); }
/** * * @param i * @param supportPoints * @param minHeight * @return */ public bool checkAddItemRevisitedRight(Item i, List <PotentialPoint> supportPoints, double minHeight) { StopwatchTimer.Start("add"); double zone1, zone2, zone3, zone4; zone1 = this.getZonesDepth(); zone2 = zone1 * 2; zone3 = zone1 * 3; zone4 = this.getDepth(); bool weightOk = true; double rnd = StaticRandom.NextDouble(); // Need to use usableSpace in relation with item to be added // supportPoints.sort(Comparator.comparing(PotentialPoint::getUsableSpace)); if (supportPoints.Any() && this.weightFits(i)) { for (int j = 0; j < supportPoints.Count; j++) { PotentialPoint supportPoint = supportPoints[j]; i.setBottomRightFront(supportPoint); if (((i.bottomLeftFront.getZ() < zone1) && (this.getZone1Weight() + i.getWeight() > this.maxZone1Weight * (1 + weightSurplusPerameter))) || (((i.bottomLeftFront.z >= zone1) && (i.bottomLeftFront.getZ() < zone2)) && (this.getZone2Weight() + i.getWeight() > this.maxZone2Weight * (1 + weightSurplusPerameter))) || (((i.bottomLeftFront.z >= zone2) && (i.bottomLeftFront.getZ() < zone3)) && (this.getZone3Weight() + i.getWeight() > this.maxZone3Weight * (1 + weightSurplusPerameter))) || (((i.bottomLeftFront.z >= zone3) && (i.bottomLeftFront.getZ() < zone4)) && (this.getZone4Weight() + i.getWeight() > this.maxZone3Weight * (1 + weightSurplusPerameter)))) { weightOk = false; } else { weightOk = true; } if ((!this.itemsOverlapping(i)) && (this.dimensionsFitRight(i)) && (supportPoint.cornerCheck(i, this, minHeight)) && weightOk) { PotentialPoint cPointXAxis = PotentialPoint.createXAxisPotentialPoint(i, j, supportPoints); PotentialPoint cPointZAxis = PotentialPoint.createZAxisPotentialPointRight(i, j, supportPoints); // TEST--------------- if (cPointXAxis.x != 0) { PotentialPoint nspZzero = new PotentialPoint(0, cPointXAxis.y, cPointXAxis.z); PotentialPoint.addPointToPotentialPoints(nspZzero, supportPoints); } PotentialPoint.addPointToPotentialPoints(cPointXAxis, supportPoints); PotentialPoint.addPointToPotentialPoints(cPointZAxis, supportPoints); if (i.isStackable()) { PotentialPoint cPointYAxis = PotentialPoint.createYAxisPotentialPointRight(i, j, supportPoints); PotentialPoint.addPointToPotentialPoints(cPointYAxis, supportPoints); int dim = supportPoints.Count; List <PotentialPoint> newList = new List <PotentialPoint>(); double maxSubst; foreach (PotentialPoint sp in supportPoints) { if ((!sp.equals(cPointYAxis)) && sp.getZ() == cPointYAxis.getZ() && sp.getY() == cPointYAxis.getY()) { if (sp.getMaxXAllowed() > cPointYAxis.getMaxXAllowed()) { maxSubst = sp.getMaxXAllowed(); } else { maxSubst = cPointYAxis.getMaxXAllowed(); } PotentialPoint toAdd = new PotentialPoint(sp.getX(), sp.getY(), sp.getZ(), maxSubst, sp.getMaxYAllowed(), sp.getMaxZAllowed()); newList.Add(toAdd); } } foreach (PotentialPoint sp in newList) { // System.err.println("ADDED"); supportPoints.Add(sp); } } /* PotentialPoint cPointXAxisProjectionMax = PotentialPoint.createXAxisPotentialPointProjectionMax(i, j, supportPoints); * PotentialPoint.addPointToPotentialPoints(cPointXAxisProjectionMax, supportPoints);*/ PotentialPoint cPointProjectionZ = PotentialPoint.createPointProjectionZ(i, j, supportPoints); PotentialPoint.addPointToPotentialPoints(cPointProjectionZ, supportPoints); /*°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°*/ /*Remove chosen support point*/ PotentialPoint.usedPotentialPoints.Add(supportPoints[j]); supportPoints.Remove(supportPoints[j]); StopwatchTimer.Stop("add"); return(true); } } } StopwatchTimer.Stop("add"); return(false); }