Example #1
0
        private void InitializeSolutionItemList()
        {
            _solutionItems = new List <SolutionItem>();

            bool   criterionReached = false;
            double zTop             = _analysis.Offset.Z;
            double weight           = _analysis.ContainerWeight;

            while (!criterionReached)
            {
                weight += _layers[0].Count * _analysis.ContentWeight;
                zTop   += _layers[0].BoxHeight;
                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);
                if (criterionReached)
                {
                    break;
                }
                else
                {
                    _solutionItems.Add(new SolutionItem(0, -1, false, false));
                }
            }
        }
Example #2
0
        private void InitializeSolutionItemList()
        {
            _solutionItems = new List <SolutionItem>();

            bool   criterionReached = false;
            double zTop = _analysis.Offset.Z;
            double weight = _analysis.ContainerWeight;
            bool   symetryX = false, symetryY = false;

            while (!criterionReached)
            {
                weight += _layerTypes[0].Count * _analysis.ContentWeight;
                zTop   += _layerTypes[0].LayerHeight;
                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);
                if (criterionReached)
                {
                    break;
                }
                else
                {
                    _solutionItems.Add(new SolutionItem(0, -1, symetryX, symetryY));
                }

                symetryX = _analysis.AlternateLayersPref ? !symetryX : symetryX;
                symetryY = _analysis.AlternateLayersPref ? !symetryY : symetryY;
            }
        }
Example #3
0
 public Vector3D GetOffset(ConstraintSetAbstract constraintSet)
 {
     if (!(constraintSet is ConstraintSetPackablePallet constraintSetPackablePallet))
     {
         throw new InvalidConstraintSetException();
     }
     return(new Vector3D(-constraintSetPackablePallet.Overhang.X, -constraintSetPackablePallet.Overhang.Y, Height));
 }
Example #4
0
        public List<Layer2D> BuildLayers(Vector3D dimBox, Vector2D dimContainer, ConstraintSetAbstract constraintSet, bool keepOnlyBest)
        {
            // instantiate list of layers
            List<Layer2D> listLayers0 = new List<Layer2D>();

            // loop through all patterns
            foreach (LayerPattern pattern in LayerPattern.All)
            {
                // loop through all orientation
                foreach (HalfAxis.HAxis axisOrtho in HalfAxis.All)
                {
                    // is orientation allowed
                    if ( !constraintSet.AllowOrientation(axisOrtho) )
                        continue;
                    // not swapped vs swapped pattern
                    for (int iSwapped = 0; iSwapped < 1; ++iSwapped)
                    {
                        // does swapping makes sense for this layer pattern ?
                        if (!pattern.CanBeSwapped && (iSwapped == 1))
                            continue;
                        // instantiate layer
                        Layer2D layer = new Layer2D(dimBox, dimContainer, axisOrtho, iSwapped == 1);
                        layer.PatternName = pattern.Name;
                        double actualLength = 0.0, actualWidth = 0.0;
                        if (!pattern.GetLayerDimensionsChecked(layer, out actualLength, out actualWidth))
                            continue;
                        pattern.GenerateLayer(layer, actualLength, actualWidth);
                        if (0 == layer.Count)
                            continue;
                        listLayers0.Add(layer);
                    }
                }
            }

            // keep only best layers
            if (keepOnlyBest)
            {
                // 1. get best count
                int bestCount = 0;
                foreach (Layer2D layer in listLayers0)
                    bestCount = Math.Max(layer.CountInHeight(constraintSet.OptMaxHeight.Value), bestCount);

                // 2. remove any layer that does not match the best count given its orientation
                List<Layer2D> listLayers1 = new List<Layer2D>();
                foreach (Layer2D layer in listLayers0)
                {
                    if (layer.CountInHeight(constraintSet.OptMaxHeight.Value) >= bestCount)
                        listLayers1.Add(layer);
                }
                // 3. copy back in original list
                listLayers0.Clear();
                listLayers0.AddRange(listLayers1);
            }
            if (constraintSet.OptMaxHeight.Activated)
                listLayers0.Sort(new LayerComparerCount(constraintSet.OptMaxHeight.Value));

            return listLayers0;
        }
Example #5
0
 public FastEvaluatorLayer2Pallet(
     ILayer2D layer, Packable packable, PalletProperties palletProperties,
     ConstraintSetAbstract constraintSet)
 {
     Layer         = layer;
     Content       = packable;
     Container     = palletProperties;
     ConstraintSet = constraintSet;
 }
 public Vector3D GetStackingDimensions(ConstraintSetAbstract constraintSet)
 {
     if (constraintSet is ConstraintSetPalletTruck constraintSetPalletTruck)
     {
         return(new Vector3D(
                    _length - 2.0 * constraintSetPalletTruck.MinDistanceLoadWall.X
                    , _width - 2.0 * constraintSetPalletTruck.MinDistanceLoadWall.Y
                    , _height - constraintSetPalletTruck.MinDistanceLoadRoof));
     }
     return(InsideDimensions);
 }
Example #7
0
 public Vector3D GetStackingDimensions(ConstraintSetAbstract constraintSet)
 {
     if (!(constraintSet is ConstraintSetPackablePallet constraintSetPackablePallet))
     {
         throw new InvalidConstraintSetException();
     }
     return(new Vector3D(
                _length + 2.0 * constraintSetPackablePallet.Overhang.X
                , _width + 2.0 * constraintSetPackablePallet.Overhang.Y
                , constraintSetPackablePallet.OptMaxHeight.Value - Height));
 }
Example #8
0
        private void RebuildSolutionItemList()
        {
            bool   criterionReached = false;
            double zTop             = _analysis.Offset.Z;
            double weight           = _analysis.ContainerWeight;

            foreach (SolutionItem solItem in _solutionItems)
            {
                weight += _layers[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   += _layers[solItem.LayerIndex].BoxHeight + ((-1 != solItem.InterlayerIndex) ? _interlayers[solItem.InterlayerIndex].Thickness : 0.0);

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);

                if (criterionReached)
                {
                    break;
                }
            }

            // add layers until
            while (!criterionReached)
            {
                SolutionItem solItem = _solutionItems.Last();

                weight += _layers[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   += _layers[solItem.LayerIndex].BoxHeight + ((-1 != solItem.InterlayerIndex) ? _interlayers[solItem.InterlayerIndex].Thickness : 0.0);

                _solutionItems.Add(new SolutionItem(solItem));

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);
            }

            // remove unneeded layer
            while (criterionReached)
            {
                SolutionItem solItem = _solutionItems.Last();

                weight -= _layers[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   -= _layers[solItem.LayerIndex].BoxHeight + ((-1 != solItem.InterlayerIndex) ? _interlayers[solItem.InterlayerIndex].Thickness : 0.0);

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);

                _solutionItems.Remove(solItem);
            }
            // reset bounding box to force recompute
            _bbox.Reset();
        }
Example #9
0
 public AnalysisPackablePallet(
     Packable packable,
     PalletProperties palletProperties,
     ConstraintSetAbstract constraintSet)
     : base(packable.ParentDocument, packable)
 {
     // sanity checks
     if (palletProperties.ParentDocument != ParentDocument)
     {
         throw new Exception("box & pallet do not belong to the same document");
     }
     PalletProperties = palletProperties;
     _constraintSet   = constraintSet;
 }
Example #10
0
        protected AnalysisPackableTruck(Document document, Packable packable, TruckProperties truckProperties,
                                        ConstraintSetAbstract constraintSet)
            : base(document, packable)
        {
            // sanity checks
            if (null != ParentDocument &&
                null != truckProperties.ParentDocument &&
                truckProperties.ParentDocument != ParentDocument)
            {
                throw new Exception("content & truck do not belong to the same document");
            }
            // also add dependancy
            TruckProperties = truckProperties;

            ConstraintSet = constraintSet;
        }
Example #11
0
 protected AnalysisPackablePallet(
     Packable packable,
     PalletProperties palletProperties,
     ConstraintSetAbstract constraintSet,
     bool temporary = false)
     : base(temporary ? null : packable.ParentDocument, packable)
 {
     // sanity checks
     if (null != ParentDocument &&
         (null != packable.ParentDocument) &&
         (palletProperties.ParentDocument != ParentDocument))
     {
         throw new Exception("box & pallet do not belong to the same document");
     }
     PalletProperties = palletProperties;
     ConstraintSet    = constraintSet;
 }
Example #12
0
        public bool FitsIn(IContainer container, ConstraintSetAbstract constraintSet)
        {
            Vector3D vPackable  = OuterDimensions;
            Vector3D vContainer = container.GetStackingDimensions(constraintSet);

            if (constraintSet.AllowOrientation(HalfAxis.HAxis.AXIS_X_N) || constraintSet.AllowOrientation(HalfAxis.HAxis.AXIS_X_P))
            {
                if ((vPackable.X <= vContainer.Z) &&
                    (
                        (vPackable.Y <= vContainer.X && vPackable.Z <= vContainer.Y) ||
                        (vPackable.Z <= vContainer.X && vPackable.Y <= vContainer.Y)
                    ))
                {
                    return(true);
                }
            }
            if (constraintSet.AllowOrientation(HalfAxis.HAxis.AXIS_Y_N) || constraintSet.AllowOrientation(HalfAxis.HAxis.AXIS_Z_P))
            {
                if ((vPackable.Y <= vContainer.Z) &&
                    (
                        (vPackable.X <= vContainer.X && vPackable.Z <= vContainer.Y) ||
                        (vPackable.Z <= vContainer.X && vPackable.X <= vContainer.Y)
                    ))
                {
                    return(true);
                }
            }
            if (constraintSet.AllowOrientation(HalfAxis.HAxis.AXIS_Z_N) || constraintSet.AllowOrientation(HalfAxis.HAxis.AXIS_Z_P))
            {
                if ((vPackable.Z <= vContainer.Z) &&
                    (
                        (vPackable.X <= vContainer.X && vPackable.Y <= vContainer.Y) ||
                        (vPackable.Y <= vContainer.X && vPackable.X <= vContainer.Y)
                    ))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #13
0
        private void InitializeSolutionItemList()
        {
            _solutionItems = new List <SolutionItem>();

            ConstraintSetAbstract constraintSet = Analysis.ConstraintSet;
            double zTop   = Analysis.Offset.Z;
            double weight = Analysis.ContainerWeight;
            int    number = 0;
            bool   allowMultipleLayers = true;

            if (constraintSet is ConstraintSetPalletTruck constraintSetPalletTruck)
            {
                allowMultipleLayers = (constraintSetPalletTruck.OptMaxLayerNumber.Activated &&
                                       constraintSetPalletTruck.OptMaxLayerNumber.Value > 1);
            }

            bool symetryX = false, symetryY = false;

            while (!constraintSet.CritHeightReached(zTop) &&
                   !constraintSet.CritWeightReached(weight) &&
                   !constraintSet.CritNumberReached(number))
            {
                number += _layerTypes[0].Count;
                weight += _layerTypes[0].Count * Analysis.ContentWeight;
                zTop   += _layerTypes[0].LayerHeight;

                if (!constraintSet.CritHeightReached(zTop) && (allowMultipleLayers || _solutionItems.Count < 1))
                {
                    _solutionItems.Add(new SolutionItem(0, -1, symetryX, symetryY));
                }
                else
                {
                    break;
                }
                symetryX = AlternateLayers ? !symetryX : symetryX;
                symetryY = AlternateLayers ? !symetryY : symetryY;
            }
        }
Example #14
0
        public void RebuildSolutionItemList()
        {
            bool   criterionReached = false;
            double zTop             = _analysis.Offset.Z;
            double weight           = _analysis.ContainerWeight;

            List <SolutionItem> solutionItems = new List <SolutionItem>();

            foreach (SolutionItem solItem in _solutionItems)
            {
                weight += _layerTypes[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   += _layerTypes[solItem.LayerIndex].LayerHeight + ((-1 != solItem.InterlayerIndex) ? _analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);

                solutionItems.Add(solItem);

                if (criterionReached)
                {
                    break;
                }
            }

            // add layers until
            while (!criterionReached)
            {
                SolutionItem solItem = null;
                if (solutionItems.Count > 0)
                {
                    solItem = solutionItems.Last();
                }
                else
                {
                    solItem = new SolutionItem(0, -1, false, false);
                }

                if (solItem.LayerIndex >= _layerTypes.Count)
                {
                    throw new Exception(string.Format("Layer index out of range!"));
                }

                weight += _layerTypes[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   += _layerTypes[solItem.LayerIndex].LayerHeight + ((-1 != solItem.InterlayerIndex) ? _analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                solutionItems.Add(new SolutionItem(solItem));

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);
            }

            // remove unneeded layer
            while (criterionReached)
            {
                SolutionItem solItem = null;
                if (solutionItems.Count > 0)
                {
                    solItem = solutionItems.Last();
                }
                else
                {
                    solItem = new SolutionItem(0, -1, false, false);
                }

                if (solItem.LayerIndex >= _layerTypes.Count)
                {
                    throw new Exception(string.Format("Layer index out of range!"));
                }

                weight -= _layerTypes[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   -= _layerTypes[solItem.LayerIndex].LayerHeight + ((-1 != solItem.InterlayerIndex) ? _analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);

                solutionItems.Remove(solItem);
            }
            _solutionItems.Clear();
            _solutionItems = solutionItems;

            // reset bounding box to force recompute
            _bbox.Reset();
        }
Example #15
0
 public Vector3D GetOffset(ConstraintSetAbstract constraintSet) => Vector3D.Zero;
Example #16
0
        public void RebuildSolutionItemList()
        {
            try
            {
                ConstraintSetAbstract constraintSet = Analysis.ConstraintSet;
                double zTop   = Analysis.Offset.Z;
                double weight = Analysis.ContainerWeight;
                int    number = 0;

                List <SolutionItem> solutionItems = new List <SolutionItem>();
                foreach (SolutionItem solItem in _solutionItems)
                {
                    number += _layerTypes[index : solItem.LayerIndex].Count;
                    weight += _layerTypes[index : solItem.LayerIndex].Count * Analysis.ContentWeight;
                    zTop   += _layerTypes[solItem.LayerIndex].LayerHeight + ((-1 != solItem.InterlayerIndex) ? Analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                    solutionItems.Add(solItem);

                    if (constraintSet.OneCriterionReached(zTop, weight, number, solutionItems.Count))
                    {
                        break;
                    }
                }

                // add layers until
                while (!constraintSet.OneCriterionReached(zTop, weight, number, solutionItems.Count))
                {
                    SolutionItem solItem = null;
                    if (solutionItems.Count > 0)
                    {
                        solItem = solutionItems.Last();
                    }
                    else
                    {
                        solItem = new SolutionItem(0, -1, false, false);
                    }

                    if (solItem.LayerIndex >= _layerTypes.Count)
                    {
                        throw new Exception(string.Format("Layer index out of range!"));
                    }

                    number += _layerTypes[solItem.LayerIndex].Count;
                    weight += _layerTypes[solItem.LayerIndex].Count * Analysis.ContentWeight;

                    // using zTopAdded because zTop must not be incremented if SolutionItem object is
                    // not actually added
                    double zTopIfAdded = zTop + _layerTypes[solItem.LayerIndex].LayerHeight
                                         + ((-1 != solItem.InterlayerIndex) ? Analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                    // only checking on height because weight / number can be modified without removing
                    // a layer (while outputing solution as a list of case)
                    if (!constraintSet.CritHeightReached(zTopIfAdded))
                    {
                        solutionItems.Add(new SolutionItem(solItem));
                        zTop = zTopIfAdded;
                    }
                    else
                    {
                        break;
                    }
                }
                // remove unneeded layer
                while (constraintSet.CritHeightReached(zTop) && solutionItems.Count > 0)
                {
                    SolutionItem solItem = solutionItems.Last();

                    if (solItem.LayerIndex >= _layerTypes.Count)
                    {
                        throw new Exception(string.Format("Layer index out of range!"));
                    }
                    number -= _layerTypes[solItem.LayerIndex].Count;
                    weight -= _layerTypes[solItem.LayerIndex].Count * Analysis.ContentWeight;
                    zTop   -= _layerTypes[solItem.LayerIndex].LayerHeight
                              + ((-1 != solItem.InterlayerIndex) ? Analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                    solutionItems.Remove(solItem);
                }
                _solutionItems.Clear();
                _solutionItems = solutionItems;

                // reset bounding box to force recompute
                _bbox.Reset();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Example #17
0
 public LayerComparerCount(ConstraintSetAbstract constraintSet, double offsetZ)
 {
     _offsetZ       = offsetZ;
     _constraintSet = constraintSet;
 }