예제 #1
0
        private PalletConstraintSet BuildPalletConstraintSet()
        {
            // build pallet constraint set
            CasePalletConstraintSet palletConstraintSet = new CasePalletConstraintSet();

            palletConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, !ForceVerticalBoxOrientation);
            palletConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, !ForceVerticalBoxOrientation);
            palletConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, !ForceVerticalBoxOrientation);
            palletConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, !ForceVerticalBoxOrientation);
            palletConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, !ForceVerticalBoxOrientation);
            palletConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

            // use all existing patterns
            palletConstraintSet.AllowedPatternString = "Column,Diagonale,Interlocked,Trilock,Spirale";

            // allow aligned and alternate layers
            palletConstraintSet.AllowAlignedLayers   = true;
            palletConstraintSet.AllowAlternateLayers = true;

            // set maximum pallet height
            palletConstraintSet.MaximumHeight    = (double)nudPalletHeight.Value;
            palletConstraintSet.UseMaximumHeight = true;

            // do not use other constraints
            palletConstraintSet.UseMaximumPalletWeight  = false;
            palletConstraintSet.UseMaximumNumberOfCases = false;
            palletConstraintSet.UseMaximumWeightOnBox   = false;

            // overhang
            palletConstraintSet.OverhangX = OverhangX;
            palletConstraintSet.OverhangY = OverhangY;

            return(palletConstraintSet);
        }
예제 #2
0
        static void Main(string[] args)
        {
            // define box properties
            BoxProperties boxProperties = new BoxProperties(null, 120.0, 100.0, 70.0);
            // define pallet properties
            PalletProperties palletProperties = new PalletProperties(null, "Block", 1200, 1000, 150);
            // define pallet constraintSet
            CasePalletConstraintSet constraintSet = new CasePalletConstraintSet();

            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

            constraintSet.SetAllowedPattern("Column");
            constraintSet.SetAllowedPattern("Diagonale");
            constraintSet.SetAllowedPattern("Interlocked");
            constraintSet.SetAllowedPattern("Trilock");
            constraintSet.SetAllowedPattern("Spirale");

            constraintSet.AllowAlignedLayers   = true;
            constraintSet.AllowAlternateLayers = true;

            constraintSet.MaximumHeight          = 2000;
            constraintSet.MaximumNumberOfItems   = 2000;
            constraintSet.UseMaximumHeight       = true;
            constraintSet.UseMaximumPalletWeight = false;
            constraintSet.UseMaximumWeightOnBox  = false;
            Console.WriteLine("=== Constraint set ===");
            Console.WriteLine(constraintSet.ToString());

            // define case optim constraintSet
            ParamSetPackOptim caseOptimConstraintSet = new ParamSetPackOptim(
                new int[3] {
                2, 2, 4
            }
                , 4.0, 0.01
                , new Vector3D(30.0, 30.0, 70.0)
                , new Vector3D(500.0, 500.0, 500.0)
                , false
                );

            PackOptimizer caseOptimizer = new PackOptimizer(boxProperties, palletProperties, constraintSet, caseOptimConstraintSet);

            // get all valid case definitions
            foreach (CaseDefinition caseDefinition in caseOptimizer.CaseDefinitions(48))
            {
                Console.WriteLine(caseDefinition.ToString() + caseDefinition.OuterDimensions(boxProperties, caseOptimConstraintSet));
            }
            // build list of solutions
            List <CaseOptimSolution> caseOptimSolutions = caseOptimizer.CaseOptimSolutions(48);

            foreach (CaseOptimSolution caseOptimSolution in caseOptimSolutions)
            {
                Console.WriteLine(caseOptimSolution.ToString());
            }
        }
예제 #3
0
        /// <summary>
        /// Edit specified pallet analysis
        /// </summary>
        /// <param name="analysis"></param>
        public void EditCasePalletAnalysis(CasePalletAnalysis analysis)
        {
            // do we need to recompute analysis
            bool recomputeRequired = false;

            if (analysis.IsBoxAnalysis)
            {
                FormNewAnalysisLegacy form = new FormNewAnalysisLegacy(this, analysis);
                form.Cases         = Cases.ToArray();
                form.Pallets       = Pallets.ToArray();
                form.Interlayers   = Interlayers.ToArray();
                form.PalletCorners = ListByType(typeof(PalletCornerProperties)).ToArray();
                form.PalletCaps    = ListByType(typeof(PalletCapProperties)).ToArray();
                form.PalletFilms   = ListByType(typeof(PalletFilmProperties)).ToArray();

                if (recomputeRequired = (DialogResult.OK == form.ShowDialog()))
                {
                    // analysis name / description
                    analysis.Name        = form.AnalysisName;
                    analysis.Description = form.AnalysisDescription;
                    // box / palet / interlayer
                    analysis.BProperties                  = form.SelectedBox;
                    analysis.PalletProperties             = form.SelectedPallet;
                    analysis.InterlayerProperties         = form.SelectedInterlayer;
                    analysis.InterlayerPropertiesAntiSlip = form.SelectedInterlayerAntiSlip;
                    // build constraint set
                    CasePalletConstraintSet constraintSet = analysis.ConstraintSet as CasePalletConstraintSet;
                    // overhang / underhang
                    constraintSet.OverhangX = form.OverhangX;
                    constraintSet.OverhangY = form.OverhangY;
                    // allowed axes
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, form.AllowVerticalX);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, form.AllowVerticalX);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, form.AllowVerticalY);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, form.AllowVerticalY);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, form.AllowVerticalZ);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, form.AllowVerticalZ);
                    // allowed dir change
                    constraintSet.AllowTwoLayerOrientations       = form.AllowTwoLayerOrientations;
                    constraintSet.AllowLastLayerOrientationChange = form.AllowLastLayerOrientationChange;
                    // allowed patterns
                    constraintSet.ClearAllowedPatterns();
                    foreach (string s in form.AllowedPatterns)
                    {
                        constraintSet.SetAllowedPattern(s);
                    }
                    // allow alternate layer
                    constraintSet.AllowAlternateLayers = form.AllowAlternateLayers;
                    constraintSet.AllowAlignedLayers   = form.AllowAlignedLayers;
                    // interlayers
                    constraintSet.HasInterlayer         = form.HasInterlayers;
                    constraintSet.InterlayerPeriod      = form.InterlayerPeriod;
                    constraintSet.HasInterlayerAntiSlip = form.HasInterlayerAntiSlip;
                    // pallet corner
                    analysis.PalletCornerProperties = form.SelectedPalletCorners;
                    // pallet cap
                    analysis.PalletCapProperties = form.SelectedPalletCap;
                    // pallet film
                    analysis.PalletFilmProperties = form.SelectedPalletFilm;
                    // stop criterion
                    constraintSet.UseMaximumHeight        = form.UseMaximumPalletHeight;
                    constraintSet.UseMaximumNumberOfCases = form.UseMaximumNumberOfBoxes;
                    constraintSet.UseMaximumPalletWeight  = form.UseMaximumPalletWeight;
                    constraintSet.UseMaximumWeightOnBox   = form.UseMaximumLoadOnBox;
                    constraintSet.MaximumHeight           = form.MaximumPalletHeight;
                    constraintSet.MaximumNumberOfItems    = form.MaximumNumberOfBoxes;
                    constraintSet.MaximumPalletWeight     = form.MaximumPalletWeight;
                    constraintSet.MaximumWeightOnBox      = form.MaximumLoadOnBox;
                    // number of solution kept
                    constraintSet.UseNumberOfSolutionsKept = Properties.Settings.Default.KeepBestSolutions;
                    if (constraintSet.UseNumberOfSolutionsKept)
                    {
                        constraintSet.NumberOfSolutionsKept = Properties.Settings.Default.NoSolutionsToKeep;
                    }
                    // pallet film turns
                    constraintSet.PalletFilmTurns = form.PalletFilmTurns;
                }
            }
            else if (analysis.IsBundleAnalysis)
            {
                FormNewAnalysisBundle form = new FormNewAnalysisBundle(this, analysis);
                form.Boxes   = Bundles.ToArray();
                form.Pallets = Pallets.ToArray();

                if (recomputeRequired = (DialogResult.OK == form.ShowDialog()))
                {
                    // analysis name / description
                    analysis.Name        = form.ItemName;
                    analysis.Description = form.ItemDescription;
                    // analysis bundle / pallet
                    analysis.BProperties      = form.SelectedBundle;
                    analysis.PalletProperties = form.SelectedPallet;
                    // build constraintSet
                    BundlePalletConstraintSet constraintSet = analysis.ConstraintSet as BundlePalletConstraintSet;
                    // overhang / underhang
                    constraintSet.OverhangX = form.OverhangX;
                    constraintSet.OverhangY = form.OverhangY;
                    // allowed patterns
                    constraintSet.ClearAllowedPatterns();
                    foreach (string s in form.AllowedPatterns)
                    {
                        constraintSet.SetAllowedPattern(s);
                    }
                    // allow aligned / alternate layer
                    constraintSet.AllowAlternateLayers = form.AllowAlternateLayers;
                    constraintSet.AllowAlignedLayers   = form.AllowAlignedLayers;
                    // stop criterions
                    constraintSet.UseMaximumHeight        = form.UseMaximumPalletHeight;
                    constraintSet.UseMaximumNumberOfCases = form.UseMaximumNumberOfBoxes;
                    constraintSet.UseMaximumPalletWeight  = form.UseMaximumPalletWeight;
                    constraintSet.MaximumHeight           = form.MaximumPalletHeight;
                    constraintSet.MaximumNumberOfItems    = form.MaximumNumberOfBoxes;
                    constraintSet.MaximumPalletWeight     = form.MaximumPalletWeight;
                }
            }
            if (recomputeRequired)
            {
                analysis.OnEndUpdate(null);
            }
        }
예제 #4
0
        /// <summary>
        /// Creates a new palet analysis
        /// </summary>
        /// <returns>created palet analysis</returns>
        public CasePalletAnalysis CreateNewCasePalletAnalysisUI()
        {
            if (!CanCreateCasePalletAnalysis)
            {
                return(null);
            }

            FormNewAnalysis form = new FormNewAnalysis(this);

            form.Cases         = Cases.ToArray();
            form.Pallets       = Pallets.ToArray();
            form.Interlayers   = Interlayers.ToArray();
            form.PalletCorners = ListByType(typeof(PalletCornerProperties)).ToArray();
            form.PalletCaps    = ListByType(typeof(PalletCapProperties)).ToArray();
            form.PalletFilms   = ListByType(typeof(PalletFilmProperties)).ToArray();

            if (DialogResult.OK == form.ShowDialog())
            {
                // build constraint set
                CasePalletConstraintSet constraintSet = new CasePalletConstraintSet();
                // overhang / underhang
                constraintSet.OverhangX = form.OverhangX;
                constraintSet.OverhangY = form.OverhangY;
                // allowed axes
                constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, form.AllowVerticalX);
                constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, form.AllowVerticalX);
                constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, form.AllowVerticalY);
                constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, form.AllowVerticalY);
                constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, form.AllowVerticalZ);
                constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, form.AllowVerticalZ);
                // allowed patterns
                constraintSet.ClearAllowedPatterns();
                foreach (string s in form.AllowedPatterns)
                {
                    constraintSet.SetAllowedPattern(s);
                }
                // allow alternate layer
                constraintSet.AllowAlternateLayers = form.AllowAlternateLayers;
                constraintSet.AllowAlignedLayers   = form.AllowAlignedLayers;
                // interlayers
                constraintSet.HasInterlayer         = form.HasInterlayers;
                constraintSet.InterlayerPeriod      = form.InterlayerPeriod;
                constraintSet.HasInterlayerAntiSlip = form.HasInterlayerAntiSlip;
                // stop criterion
                constraintSet.UseMaximumHeight        = form.UseMaximumPalletHeight;
                constraintSet.UseMaximumNumberOfCases = form.UseMaximumNumberOfBoxes;
                constraintSet.UseMaximumPalletWeight  = form.UseMaximumPalletWeight;
                constraintSet.UseMaximumWeightOnBox   = form.UseMaximumLoadOnBox;
                constraintSet.MaximumHeight           = form.MaximumPalletHeight;
                constraintSet.MaximumNumberOfItems    = form.MaximumNumberOfBoxes;
                constraintSet.MaximumPalletWeight     = form.MaximumPalletWeight;
                constraintSet.MaximumWeightOnBox      = form.MaximumLoadOnBox;
                // number of solution kept
                constraintSet.UseNumberOfSolutionsKept = Properties.Settings.Default.KeepBestSolutions;
                if (constraintSet.UseNumberOfSolutionsKept)
                {
                    constraintSet.NumberOfSolutionsKept = Properties.Settings.Default.NoSolutionsToKeep;
                }
                // number of pallet film turns
                constraintSet.PalletFilmTurns = form.PalletFilmTurns;

                return(CreateNewCasePalletAnalysis(
                           form.AnalysisName, form.AnalysisDescription,
                           form.SelectedBox, form.SelectedPallet,
                           form.SelectedInterlayer, form.SelectedInterlayerAntiSlip,
                           form.SelectedPalletCorners, form.SelectedPalletCap, form.SelectedPalletFilm,
                           constraintSet,
                           new CasePalletSolver()));
            }
            return(null);
        }
예제 #5
0
        private CasePalletAnalysis LoadPalletAnalysis(Document doc, string sid)
        {
            CasePalletAnalysis analysis = null;

            palletAnalysis xmlAnalysis = _root.data.analyses.palletAnalysis.Find(delegate(palletAnalysis pa) { return(pa.id == sid); });

            if (null == xmlAnalysis)
            {
                throw new XmlFileProcessorException(string.Format("Failed to load analysis with Id = {0}", xmlAnalysis.id));
            }

            BoxProperties    caseProperties   = LoadCaseById(doc, _root.data.items.library_cases, xmlAnalysis.caseId);
            BundleProperties bundleProperties = LoadBundleById(doc, _root.data.items.library_bundles, xmlAnalysis.bundleId);

            BProperties         bProperties;
            PalletConstraintSet constraintSet;

            if (null != caseProperties)
            {
                CasePalletConstraintSet caseConstraintSet = new CasePalletConstraintSet();
                // interlayer
                caseConstraintSet.HasInterlayer         = xmlAnalysis.interlayerPeriodSpecified;
                caseConstraintSet.HasInterlayerAntiSlip = false;

                // allowed ortho axes
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

                // interlayer period
                caseConstraintSet.InterlayerPeriod = xmlAnalysis.interlayerPeriodSpecified ? (int)xmlAnalysis.interlayerPeriod : 1;

                bProperties   = caseProperties;
                constraintSet = caseConstraintSet;
            }
            else if (null != bundleProperties)
            {
                BundlePalletConstraintSet bundleConstraintSet = new BundlePalletConstraintSet();

                bProperties   = bundleProperties;
                constraintSet = bundleConstraintSet;
            }
            else
            {
                throw new XmlFileProcessorException(string.Format("Failed to load analysis with Id = {0}", xmlAnalysis.id));
            }

            // generic constraintSet properties
            // allow aligned / alternate layers
            constraintSet.AllowAlignedLayers   = false;
            constraintSet.AllowAlternateLayers = false;
            foreach (layerArrangement layerArr in xmlAnalysis.allowedLayerArrangements)
            {
                if (layerArr == layerArrangement.ALIGNED)
                {
                    constraintSet.AllowAlignedLayers = true;
                }
                if (layerArr == layerArrangement.ROTATED180 | layerArr == layerArrangement.ROTATED90)
                {
                    constraintSet.AllowAlternateLayers = true;
                }
            }
            // allowed patterns
            foreach (patternName pName in xmlAnalysis.allowedLayerPatterns)
            {
                switch (pName)
                {
                case patternName.COLUMN: constraintSet.SetAllowedPattern("Column"); break;

                case patternName.DIAGONAL: constraintSet.SetAllowedPattern("Diagonal"); break;

                case patternName.INTERLOCK: constraintSet.SetAllowedPattern("Interlock"); break;

                case patternName.TRILOCK: constraintSet.SetAllowedPattern("Trilock"); break;

                case patternName.SPIRAL: constraintSet.SetAllowedPattern("Spiral"); break;

                case patternName.ENLARGED_SPIRAL: constraintSet.SetAllowedPattern("Enlarged spiral"); break;

                default: break;
                }
            }
            // overhang
            constraintSet.OverhangX = xmlAnalysis.overhang[0];
            constraintSet.OverhangY = xmlAnalysis.overhang[1];

            // stop criterions
            // max height
            if (xmlAnalysis.stackingStopCriterions.stopMaxHeight.maxHeightSpecified)
            {
                constraintSet.UseMaximumHeight = true;
                constraintSet.MaximumHeight    = xmlAnalysis.stackingStopCriterions.stopMaxHeight.maxHeight;
            }
            else
            {
                constraintSet.UseMaximumHeight = false;
            }
            // max weight
            if (xmlAnalysis.stackingStopCriterions.stopMaxWeight.maxWeightSpecified)
            {
                constraintSet.UseMaximumPalletWeight = true;
                constraintSet.MaximumPalletWeight    = xmlAnalysis.stackingStopCriterions.stopMaxWeight.maxWeight;
            }
            else
            {
                constraintSet.UseMaximumPalletWeight = false;
            }
            // max number of box/bundle
            if (xmlAnalysis.stackingStopCriterions.stopMaxNumber.maxNumberSpecified)
            {
                constraintSet.UseMaximumNumberOfCases = true;
                constraintSet.MaximumNumberOfItems    = (int)xmlAnalysis.stackingStopCriterions.stopMaxNumber.maxNumber;
            }
            else
            {
                constraintSet.UseMaximumNumberOfCases = false;
            }
            // max weight on case
            if (xmlAnalysis.stackingStopCriterions.stopMaxWeightOnCase.maxWeightOnCaseSpecified)
            {
                constraintSet.UseMaximumWeightOnBox = true;
                constraintSet.MaximumWeightOnBox    = xmlAnalysis.stackingStopCriterions.stopMaxWeightOnCase.maxWeightOnCase;
            }
            else
            {
                constraintSet.UseMaximumWeightOnBox = false;
            }

            if (null != doc)
            {
                analysis = doc.CreateNewCasePalletAnalysis(xmlAnalysis.name, xmlAnalysis.description
                                                           , bProperties
                                                           , LoadPalletById(doc, _root.data.items.library_pallets, xmlAnalysis.palletId)
                                                           , LoadInterlayerById(doc, _root.data.items.library_interlayers, xmlAnalysis.interlayerId)
                                                           , LoadInterlayerById(doc, _root.data.items.library_interlayers, xmlAnalysis.interlayerAntiSlipId)
                                                           , null
                                                           , null
                                                           , null
                                                           , constraintSet
                                                           , new treeDiM.StackBuilder.Engine.CasePalletSolver());
            }
            else
            {
                // instantiate pallet analysis
                analysis = new CasePalletAnalysis(
                    bProperties
                    , LoadPalletById(null, _root.data.items.library_pallets, xmlAnalysis.palletId)
                    , LoadInterlayerById(null, _root.data.items.library_interlayers, xmlAnalysis.interlayerId)
                    , null
                    , null
                    , null
                    , null
                    , constraintSet);
                // name
                analysis.Name = xmlAnalysis.name;
                // description
                analysis.Description = xmlAnalysis.description;
            }
            return(analysis);
        }
예제 #6
0
        public bool onFileNew(ref string fileName)
        {
            // INTEX data are in cms
            UnitsManager.CurrentUnitSystem = UnitsManager.UnitSystem.UNIT_METRIC2;

            string dbPath = Properties.Settings.Default.DatabasePathINTEX;

            if (string.IsNullOrWhiteSpace(dbPath) || !File.Exists(dbPath))
            {
                OpenFileDialog fd = new OpenFileDialog();
                fd.DefaultExt       = "xls";
                fd.AddExtension     = false;
                fd.Filter           = "Microsoft Excel File (*.xls)|*.xls|All files (*.*)|*.*";
                fd.FilterIndex      = 0;
                fd.RestoreDirectory = true;
                fd.CheckFileExists  = true;
                if (DialogResult.OK != fd.ShowDialog())
                {
                    return(false);
                }

                dbPath = fd.FileName;
                Properties.Settings.Default.DatabasePathINTEX = dbPath;
                Properties.Settings.Default.Save();
            }
            // load INTEX excel file
            List <DataItemINTEX>   listItems   = null;
            List <DataPalletINTEX> listPallets = null;
            List <DataCaseINTEX>   listCases   = null;

            try
            {
                // Set cursor as hourglass
                Cursor.Current = Cursors.WaitCursor;
                // load excel file
                if (!ExcelDataReader.ExcelDataReader.LoadIntexFile(dbPath, ref listItems, ref listPallets, ref listCases))
                {
                    Cursor.Current = Cursors.Default;
                    string message = string.Empty;
                    if (null == listItems || listItems.Count < 1)
                    {
                        message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "article", "Articles");
                    }
                    else if (null == listPallets || listPallets.Count < 1)
                    {
                        message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "palette", "Palettes");
                    }
                    else
                    {
                        message = string.Format(Properties.Resources.ID_ERROR_INVALIDFILE, dbPath);
                    }
                    if (!string.IsNullOrEmpty(message))
                    {
                        MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    ex.Message
                    , Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                _log.Error(ex.Message);
            }
            finally
            { Cursor.Current = Cursors.Default; }
            // do we have a valid list
            if (null == listItems || 0 == listItems.Count)
            {
                return(false);
            }
            // proceed : buid project file
            try
            {
                FormNewINTEX form = new FormNewINTEX();
                form._listItems   = listItems;
                form._listPallets = listPallets;
                form._listCases   = listCases;
                if (DialogResult.OK != form.ShowDialog())
                {
                    return(false);
                }
                // create document
                DataItemINTEX item     = form._currentItem;
                Document      document = new Document(item._ref, item._description, "INTEX", DateTime.Now, null);
                // create box properties
                Color[] colorsCase = new Color[6];
                for (int i = 0; i < 6; ++i)
                {
                    colorsCase[i] = Color.Chocolate;
                }
                BoxProperties itemProperties = null;
                if (!form.UseIntermediatePacking)
                {
                    itemProperties = document.CreateNewCase(
                        item._ref
                        , string.Format("{0};EAN14 : {1};UPC : {2};PCB : {3}", item._description, item._gencode, item._UPC, item._PCB)
                        , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._length - 0.6, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._width - 0.6, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._height - 0.6, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , colorsCase);
                }
                else
                {
                    itemProperties = document.CreateNewBox(
                        item._ref
                        , string.Format("{0};EAN14 : {1};UPC : {2};PCB : {3}", item._description, item._gencode, item._UPC, item._PCB)
                        , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , colorsCase);
                }
                itemProperties.ShowTape  = true;
                itemProperties.TapeColor = Color.Beige;
                itemProperties.TapeWidth = 5.0;
                InsertPictogram(ref itemProperties);

                BoxProperties currentCase = null;
                if (form.UseIntermediatePacking)
                {
                    // create cases
                    foreach (DataCaseINTEX dataCase in listCases)
                    {
                        double lengthInt = dataCase._lengthInt > 0 ? dataCase._lengthInt : dataCase._lengthExt - 2 * form.DefaultCaseThickness;
                        double widthInt  = dataCase._widthInt > 0 ? dataCase._widthInt : dataCase._widthExt - 2 * form.DefaultCaseThickness;
                        double heightInt = dataCase._heightInt > 0 ? dataCase._heightInt : dataCase._heightExt - 2 * form.DefaultCaseThickness;

                        BoxProperties intercaseProperties = document.CreateNewCase(
                            dataCase._ref
                            , string.Format("{0:0.0}*{1:0.0}*{2:0.0}", dataCase._lengthExt, dataCase._widthExt, dataCase._heightExt)
                            , UnitsManager.ConvertLengthFrom(dataCase._lengthExt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(dataCase._widthExt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(dataCase._heightExt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(lengthInt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(widthInt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(heightInt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertMassFrom(dataCase._weight, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , colorsCase);
                        intercaseProperties.ShowTape  = true;
                        intercaseProperties.TapeColor = Color.Beige;
                        intercaseProperties.TapeWidth = 5.0;

                        if (string.Equals(form._currentCase._ref, intercaseProperties.Name))
                        {
                            currentCase = intercaseProperties;
                        }
                    }
                }

                if (form.UseIntermediatePacking)
                {
                    // Case constraint set
                    BoxCaseConstraintSet boxCaseConstraintSet = new BoxCaseConstraintSet();
                    boxCaseConstraintSet.SetAllowedOrthoAxisAll();
                    if (boxCaseConstraintSet.IsValid)
                    {
                        // create case analysis
                        BoxCaseAnalysis analysis = document.CreateNewBoxCaseAnalysis(
                            string.Format(Properties.Resources.ID_PACKING, item._ref)
                            , item._description
                            , itemProperties
                            , currentCase
                            , boxCaseConstraintSet
                            , new BoxCaseSolver());
                    }
                }

                // create pallets
                PalletProperties currentPallet = null;
                foreach (DataPalletINTEX pallet in listPallets)
                {
                    PalletProperties palletProperties = document.CreateNewPallet(
                        pallet._type, pallet._type, "EUR"
                        , UnitsManager.ConvertLengthFrom(pallet._length, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(pallet._width, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(pallet._height, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertMassFrom(pallet._weight, UnitsManager.UnitSystem.UNIT_METRIC2));
                    if (string.Equals(form._currentPallet._type, pallet._type))
                    {
                        currentPallet = palletProperties;
                    }
                }

                // *** pallet analysis ***
                // constraint set
                CasePalletConstraintSet constraintSet = new CasePalletConstraintSet();
                constraintSet.UseMaximumHeight = true;
                constraintSet.MaximumHeight    = UnitsManager.ConvertLengthFrom(form.PalletHeight, UnitsManager.UnitSystem.UNIT_METRIC2);
                constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);
                constraintSet.AllowAlignedLayers   = true;
                constraintSet.AllowAlternateLayers = true;
                constraintSet.SetAllowedPattern("Column");
                constraintSet.SetAllowedPattern("Diagonale");
                constraintSet.SetAllowedPattern("Interlocked");
                constraintSet.SetAllowedPattern("Trilock");
                constraintSet.SetAllowedPattern("Spirale");
                constraintSet.SetAllowedPattern("Enlarged spirale");
                if (constraintSet.IsValid)
                {
                    // create analysis
                    CasePalletSolver   solver         = new CasePalletSolver();
                    CasePalletAnalysis palletAnalysis = document.CreateNewCasePalletAnalysis(
                        item._ref, item.ToString()
                        , form.UseIntermediatePacking ? currentCase : itemProperties
                        , currentPallet,
                        null, null,
                        null, null, null,
                        constraintSet, solver);
                }
                // save document
                fileName = form.FilePath;
                document.Write(form.FilePath);
                // return true to let application open
                return(File.Exists(fileName));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
예제 #7
0
        private static void RunBoxTest(bool useSingleColor, Document doc, PalletProperties palletProperties)
        {
            // define box properties
            var boxProperties = new BoxProperties(doc, 162, 210, 250);

            //boxProperties.Name = "Box1";
            boxProperties.SetWeight(3.0);
            if (!useSingleColor)
            {
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_N, Color.Red);
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_P, Color.Red);
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_N, Color.Green);
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_P, Color.Green);
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_N, Color.Blue);
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_P, Color.Blue);
            }
            else
            {
                boxProperties.SetColor(Color.Chocolate);
            }

            Console.WriteLine(boxProperties.ToString());


            InterlayerProperties interlayerProperties = null;

            // define constraints
            var constraintSet = new CasePalletConstraintSet();

            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

            constraintSet.SetAllowedPattern("Trilock");

            constraintSet.AllowAlignedLayers   = true;
            constraintSet.AllowAlternateLayers = false;

            constraintSet.MaximumPalletWeight             = 2000;
            constraintSet.MaximumNumberOfItems            = 2000;
            constraintSet.MaximumHeight                   = 2000.0;
            constraintSet.UseMaximumHeight                = true;
            constraintSet.UseMaximumPalletWeight          = true;
            constraintSet.UseMaximumWeightOnBox           = false;
            constraintSet.AllowLastLayerOrientationChange = true;
            Console.WriteLine("=== Constraint set ===");
            Console.WriteLine(constraintSet.ToString());

            // initialize analysis
            var analysis = new CasePalletAnalysis(
                boxProperties, palletProperties, interlayerProperties,
                null, null, null, null,
                constraintSet);

            // initialize solver
            var solver = new CasePalletSolver();

            solver.ProcessAnalysis(analysis);

            Console.WriteLine("=== Solutions ===");
            int solIndex = 0;

            foreach (CasePalletSolution sol in analysis.Solutions)
            {
                // instantiate graphics
                Graphics3DImage graphics = new Graphics3DImage(new Size(1000, 1000));
                graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                graphics.Target         = Vector3D.Zero;
                graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                // instantiate solution viewer
                CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol);
                sv.Draw(graphics);
                graphics.Flush();
                // save
                string fileName = string.Format("Pallet_{0}.bmp", solIndex++);
                string filePath = Path.Combine(Path.GetTempPath(), fileName);
                Console.WriteLine("Saving file " + filePath + "...");
                graphics.SaveAs(filePath);
            }
        }
예제 #8
0
        private void FillGrid()
        {
            try
            {
                // fill grid solution
                gridSolutions.Rows.Clear();

                // border
                DevAge.Drawing.BorderLine      border     = new DevAge.Drawing.BorderLine(Color.DarkBlue, 1);
                DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

                // views
                CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White);
                viewNormal.Border = cellBorder;
                CheckboxBackColorAlternate viewNormalCheck = new CheckboxBackColorAlternate(Color.LightBlue, Color.White);
                viewNormalCheck.Border = cellBorder;

                // column header view
                SourceGrid.Cells.Views.ColumnHeader        viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
                DevAge.Drawing.VisualElements.ColumnHeader backHeader       = new DevAge.Drawing.VisualElements.ColumnHeader();
                backHeader.BackColor                   = Color.LightGray;
                backHeader.Border                      = DevAge.Drawing.RectangleBorder.NoBorder;
                viewColumnHeader.Background            = backHeader;
                viewColumnHeader.ForeColor             = Color.White;
                viewColumnHeader.Font                  = new Font("Arial", 8, FontStyle.Regular);
                viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None;

                // create the grid
                gridSolutions.BorderStyle = BorderStyle.FixedSingle;

                gridSolutions.ColumnsCount = 12;
                gridSolutions.FixedRows    = 1;
                gridSolutions.Rows.Insert(0);

                // header
                SourceGrid.Cells.ColumnHeader columnHeader;
                // 0
                columnHeader = new SourceGrid.Cells.ColumnHeader("#");
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View   = viewColumnHeader;
                gridSolutions[0, 0] = columnHeader;
                // 1
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_A1);
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View   = viewColumnHeader;
                gridSolutions[0, 1] = columnHeader;
                // 2
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_A2);
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View   = viewColumnHeader;
                gridSolutions[0, 2] = columnHeader;
                // 3
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_A3);
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View   = viewColumnHeader;
                gridSolutions[0, 3] = columnHeader;
                // 4
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LENGTH);
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View   = viewColumnHeader;
                gridSolutions[0, 4] = columnHeader;
                // 5
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_WIDTH);
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View   = viewColumnHeader;
                gridSolutions[0, 5] = columnHeader;
                // 6
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_HEIGHT);
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View   = viewColumnHeader;
                gridSolutions[0, 6] = columnHeader;
                // 7
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_AREA);
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View   = viewColumnHeader;
                gridSolutions[0, 7] = columnHeader;
                // 8
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASESLAYER);
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View   = viewColumnHeader;
                gridSolutions[0, 8] = columnHeader;
                // 9
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERS);
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View   = viewColumnHeader;
                gridSolutions[0, 9] = columnHeader;
                // 10
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASESPALLET);
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View    = viewColumnHeader;
                gridSolutions[0, 10] = columnHeader;
                // 11
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY);
                columnHeader.AutomaticSortEnabled = false;
                columnHeader.View    = viewColumnHeader;
                gridSolutions[0, 11] = columnHeader;

                // column width
                gridSolutions.Columns[0].Width  = 30;
                gridSolutions.Columns[1].Width  = 30;
                gridSolutions.Columns[2].Width  = 30;
                gridSolutions.Columns[3].Width  = 30;
                gridSolutions.Columns[4].Width  = 50;
                gridSolutions.Columns[5].Width  = 50;
                gridSolutions.Columns[6].Width  = 50;
                gridSolutions.Columns[7].Width  = 50;
                gridSolutions.Columns[8].Width  = 80;
                gridSolutions.Columns[9].Width  = 50;
                gridSolutions.Columns[10].Width = 80;
                gridSolutions.Columns[11].Width = 100;

                // get BoxProperties
                BoxProperties          boxProperties          = SelectedBox;
                PalletProperties       palletProperties       = SelectedPallet;
                CaseOptimConstraintSet caseOptimConstraintSet = BuildCaseOptimConstraintSet();
                PalletConstraintSet    palletConstraintSet    = new CasePalletConstraintSet();
                palletConstraintSet.MaximumHeight = (double)nudPalletHeight.Value;
                // data
                int iIndex = 0;
                foreach (CaseOptimSolution sol in _solutions)
                {
                    // insert new row
                    gridSolutions.Rows.Insert(++iIndex);
                    // # (index)
                    gridSolutions[iIndex, 0] = new SourceGrid.Cells.Cell(string.Format("{0}", iIndex));
                    // A1
                    gridSolutions[iIndex, 1] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.CaseDefinition.Arrangement._iLength));
                    // A2
                    gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.CaseDefinition.Arrangement._iWidth));
                    // A3
                    gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.CaseDefinition.Arrangement._iHeight));
                    // Case inner dimensions
                    Vector3D innerDim = sol.CaseDefinition.InnerDimensions(boxProperties);
                    // LENGTH
                    gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(string.Format("{0:0.#}", innerDim.X));
                    // WIDTH
                    gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(string.Format("{0:0.#}", innerDim.Y));
                    // HEIGHT
                    gridSolutions[iIndex, 6] = new SourceGrid.Cells.Cell(string.Format("{0:0.#}", innerDim.Z));
                    // AREA
                    gridSolutions[iIndex, 7] = new SourceGrid.Cells.Cell(string.Format("{0:0.00}", sol.CaseDefinition.Area(boxProperties, caseOptimConstraintSet) * 1.0E-06));
                    // CASES PER LAYER
                    gridSolutions[iIndex, 8] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.PalletSolution[0].BoxCount));
                    // LAYERS
                    gridSolutions[iIndex, 9] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.PalletSolution.Count));
                    // CASES PER PALLET
                    gridSolutions[iIndex, 10] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.CaseCount));
                    // EFFICIENCY
                    double efficiency = sol.CaseCount * sol.CaseDefinition.InnerVolume(boxProperties) /
                                        ((palletProperties.Length - palletConstraintSet.OverhangX)
                                         * (palletProperties.Width - palletConstraintSet.OverhangY)
                                         * (palletConstraintSet.MaximumHeight - palletProperties.Height)
                                        );
                    gridSolutions[iIndex, 11] = new SourceGrid.Cells.Cell(string.Format("{0:0.00}", efficiency));
                }
                // select first solution
                if (_solutions.Count > 0)
                {
                    gridSolutions.Selection.EnableMultiSelection = false;
                    gridSolutions.Selection.SelectRow(1, true);
                }
            }
            catch (Exception ex)
            { _log.Error(ex.ToString()); }

            graphCtrlBoxesLayout.Invalidate();
            graphCtrlPalletLayout.Invalidate();
            UpdateToolbarButtons();
        }
예제 #9
0
        private void FillGrid()
        {
            try
            {
                // fill grid solution
                gridSolutions.Rows.Clear();

                // border
                DevAge.Drawing.BorderLine      border     = new DevAge.Drawing.BorderLine(Color.DarkBlue, 1);
                DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

                // views
                CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White)
                {
                    Border = cellBorder
                };
                CheckboxBackColorAlternate viewNormalCheck = new CheckboxBackColorAlternate(Color.LightBlue, Color.White)
                {
                    Border = cellBorder
                };

                // column header view
                SourceGrid.Cells.Views.ColumnHeader        viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
                DevAge.Drawing.VisualElements.ColumnHeader backHeader       = new DevAge.Drawing.VisualElements.ColumnHeader()
                {
                    BackColor = Color.LightGray,
                    Border    = DevAge.Drawing.RectangleBorder.NoBorder
                };
                viewColumnHeader.Background            = backHeader;
                viewColumnHeader.ForeColor             = Color.White;
                viewColumnHeader.Font                  = new Font("Arial", 8, FontStyle.Regular);
                viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None;

                // create the grid
                gridSolutions.BorderStyle = BorderStyle.FixedSingle;

                gridSolutions.ColumnsCount = 12;
                gridSolutions.FixedRows    = 1;
                gridSolutions.Rows.Insert(0);

                // header
                SourceGrid.Cells.ColumnHeader columnHeader;
                // 0
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_A1)
                {
                    AutomaticSortEnabled = true,
                    View = viewColumnHeader
                };
                gridSolutions[0, 0] = columnHeader;
                // 1
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_A2)
                {
                    AutomaticSortEnabled = true,
                    View = viewColumnHeader
                };
                gridSolutions[0, 1] = columnHeader;
                // 2
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_A3)
                {
                    AutomaticSortEnabled = true,
                    View = viewColumnHeader
                };
                gridSolutions[0, 2] = columnHeader;
                // 3
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LENGTH)
                {
                    AutomaticSortEnabled = true,
                    View = viewColumnHeader
                };
                gridSolutions[0, 3] = columnHeader;
                // 4
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_WIDTH)
                {
                    AutomaticSortEnabled = true,
                    View = viewColumnHeader
                };
                gridSolutions[0, 4] = columnHeader;
                // 5
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_HEIGHT)
                {
                    AutomaticSortEnabled = true,
                    View = viewColumnHeader
                };
                gridSolutions[0, 5] = columnHeader;
                // 6
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_AREA + "/" + Resources.ID_WEIGHT_WU)
                {
                    AutomaticSortEnabled = false,
                    View = viewColumnHeader
                };
                gridSolutions[0, 6] = columnHeader;
                // 7
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASESLAYER)
                {
                    AutomaticSortEnabled = true,
                    View = viewColumnHeader
                };
                gridSolutions[0, 7] = columnHeader;
                // 8
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERS)
                {
                    AutomaticSortEnabled = false,
                    View = viewColumnHeader
                };
                gridSolutions[0, 8] = columnHeader;
                // 9
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASESPALLET)
                {
                    AutomaticSortEnabled = true,
                    View = viewColumnHeader
                };
                gridSolutions[0, 9] = columnHeader;
                // 10
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY)
                {
                    AutomaticSortEnabled = true,
                    View = viewColumnHeader
                };
                gridSolutions[0, 10] = columnHeader;
                // 11
                columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_MAXIMUMSPACE)
                {
                    AutomaticSortEnabled = true,
                    View = viewColumnHeader
                };
                gridSolutions[0, 11] = columnHeader;

                // column width
                gridSolutions.Columns[0].Width  = 30;
                gridSolutions.Columns[1].Width  = 30;
                gridSolutions.Columns[2].Width  = 30;
                gridSolutions.Columns[3].Width  = 50;
                gridSolutions.Columns[4].Width  = 50;
                gridSolutions.Columns[5].Width  = 50;
                gridSolutions.Columns[6].Width  = 80;
                gridSolutions.Columns[7].Width  = 80;
                gridSolutions.Columns[8].Width  = 50;
                gridSolutions.Columns[9].Width  = 80;
                gridSolutions.Columns[10].Width = 100;
                gridSolutions.Columns[11].Width = 80;

                // get BoxProperties
                BoxProperties       boxProperties          = SelectedBox;
                PalletProperties    palletProperties       = SelectedPallet;
                ParamSetPackOptim   caseOptimConstraintSet = BuildCaseOptimConstraintSet();
                PalletConstraintSet palletConstraintSet    = new CasePalletConstraintSet()
                {
                    MaximumHeight = MaximumPalletHeight
                };
                // data
                int iIndex = 0;
                foreach (CaseOptimSolution sol in _solutions)
                {
                    // insert new row
                    gridSolutions.Rows.Insert(++iIndex);
                    gridSolutions.Rows[iIndex].Tag = sol;
                    // A1
                    gridSolutions[iIndex, 0] = new SourceGrid.Cells.Cell(sol.CaseDefinition.Arrangement.Length);
                    // A2
                    gridSolutions[iIndex, 1] = new SourceGrid.Cells.Cell(sol.CaseDefinition.Arrangement.Width);
                    // A3
                    gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(sol.CaseDefinition.Arrangement.Height);
                    // Case outer dimensions
                    Vector3D innerDim            = sol.CaseDefinition.InnerDimensions(boxProperties);
                    Vector3D outerDim            = sol.CaseDefinition.OuterDimensions(boxProperties, caseOptimConstraintSet);
                    bool     showOuterDimensions = true;
                    // LENGTH
                    gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(showOuterDimensions ? Math.Round(outerDim.X, 1) : Math.Round(innerDim.X, 1));
                    // WIDTH
                    gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(showOuterDimensions ? Math.Round(outerDim.Y, 1) : Math.Round(innerDim.Y, 1));
                    // HEIGHT
                    gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(showOuterDimensions ? Math.Round(outerDim.Z, 1) : Math.Round(innerDim.Z, 1));
                    // AREA
                    gridSolutions[iIndex, 6] = new SourceGrid.Cells.Cell(string.Format("{0:0.00} / {1:0.000}"
                                                                                       , sol.CaseDefinition.Area(boxProperties, caseOptimConstraintSet)
                                                                                       , sol.CaseDefinition.EmptyWeight(boxProperties, caseOptimConstraintSet)
                                                                                       ));
                    // CASES PER LAYER
                    gridSolutions[iIndex, 7] = new SourceGrid.Cells.Cell(sol.PalletSolution[0].BoxCount);
                    // LAYERS
                    gridSolutions[iIndex, 8] = new SourceGrid.Cells.Cell(sol.PalletSolution.Count);
                    // CASES PER PALLET
                    gridSolutions[iIndex, 9] = new SourceGrid.Cells.Cell(sol.CaseCount);
                    // EFFICIENCY
                    double efficiency = 100.0 * sol.CaseCount * sol.CaseDefinition.InnerVolume(boxProperties) /
                                        ((palletProperties.Length - palletConstraintSet.OverhangX)
                                         * (palletProperties.Width - palletConstraintSet.OverhangY)
                                         * (palletConstraintSet.MaximumHeight - palletProperties.Height)
                                        );
                    gridSolutions[iIndex, 10] = new SourceGrid.Cells.Cell(Math.Round(efficiency, 1));
                    // MAXIMUM SPACE
                    gridSolutions[iIndex, 11] = new SourceGrid.Cells.Cell(Math.Round(sol.PalletSolution.MaximumSpace, 1));
                }
                // select first solution
                if (_solutions.Count > 0)
                {
                    gridSolutions.Selection.EnableMultiSelection = false;
                    gridSolutions.Selection.SelectRow(1, true);
                }
            }
            catch (Exception ex)
            { _log.Error(ex.ToString()); }

            graphCtrlBoxesLayout.Invalidate();
            graphCtrlPallet.Invalidate();

            UpdateButtonAddSolutionStatus();
        }
예제 #10
0
        static int Main(string[] args)
        {
            ILog log = LogManager.GetLogger(typeof(Program));

            XmlConfigurator.Configure();

            try
            {
                bool useSingleColor = false;
                // instantiate document
                Document doc = new Document("Test", "Test", "fga", DateTime.Now, null);

                // define pallet properties
                PalletProperties palletProperties = new PalletProperties(doc, "EUR2", 1200, 1000, 150);
                Console.WriteLine("=== Pallet properties ===");
                Console.WriteLine(palletProperties.ToString());

                bool testCylinder = false;
                if (!testCylinder)
                {
                    // define box properties
                    BoxProperties boxProperties = new BoxProperties(doc, 162, 210, 250);
                    boxProperties.Name   = "Box1";
                    boxProperties.Weight = 3.0;
                    if (!useSingleColor)
                    {
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_N, Color.Red);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_P, Color.Red);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_N, Color.Green);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_P, Color.Green);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_N, Color.Blue);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_P, Color.Blue);
                    }
                    else
                    {
                        boxProperties.SetColor(Color.Chocolate);
                    }

                    Console.WriteLine(boxProperties.ToString());


                    InterlayerProperties interlayerProperties = null;

                    // define constraints
                    CasePalletConstraintSet constraintSet = new CasePalletConstraintSet();
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

                    constraintSet.SetAllowedPattern("Trilock");

                    constraintSet.AllowAlignedLayers   = true;
                    constraintSet.AllowAlternateLayers = false;

                    constraintSet.MaximumPalletWeight             = 2000;
                    constraintSet.MaximumNumberOfItems            = 2000;
                    constraintSet.MaximumHeight                   = 2000.0;
                    constraintSet.UseMaximumHeight                = true;
                    constraintSet.UseMaximumPalletWeight          = true;
                    constraintSet.UseMaximumWeightOnBox           = false;
                    constraintSet.AllowLastLayerOrientationChange = true;
                    Console.WriteLine("=== Constraint set ===");
                    Console.WriteLine(constraintSet.ToString());

                    // initialize analysis
                    CasePalletAnalysis analysis = new CasePalletAnalysis(
                        boxProperties, palletProperties, interlayerProperties,
                        null, null, null, null,
                        constraintSet);

                    // initialize solver
                    CasePalletSolver solver = new CasePalletSolver();
                    solver.ProcessAnalysis(analysis);

                    Console.WriteLine("=== Solutions ===");
                    int solIndex = 0;
                    foreach (CasePalletSolution sol in analysis.Solutions)
                    {
                        // instantiate graphics
                        Graphics3DImage graphics = new Graphics3DImage(new Size(1000, 1000));
                        graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                        graphics.Target         = Vector3D.Zero;
                        graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                        // instantiate solution viewer
                        CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol);
                        sv.Draw(graphics);
                        graphics.Flush();
                        // save
                        string fileName = string.Format("Pallet_{0}.bmp", solIndex++);
                        string filePath = Path.Combine(Path.GetTempPath(), fileName);
                        Console.WriteLine("Saving file " + filePath + "...");
                        graphics.SaveAs(filePath);
                    }
                }
                else
                {
                    // cylinder
                    Console.WriteLine("=== Cylinder properties ===");
                    CylinderProperties cylProperties = new CylinderProperties(doc, "Cylinder", "Default cylinder",
                                                                              90, 45.0, 100, 1.5, Color.Gray, Color.SkyBlue, Color.SkyBlue);
                    Console.WriteLine(cylProperties.ToString());
                    // constraint set
                    Console.WriteLine("=== Constraint set ===");
                    CylinderPalletConstraintSet constraintSet = new CylinderPalletConstraintSet();
                    constraintSet.UseMaximumPalletHeight  = true;
                    constraintSet.MaximumPalletHeight     = 1200.0;
                    constraintSet.UseMaximumPalletWeight  = true;
                    constraintSet.MaximumPalletWeight     = 2000;
                    constraintSet.UseMaximumNumberOfItems = true;
                    constraintSet.MaximumNumberOfItems    = 2000;
                    Console.WriteLine(constraintSet.ToString());
                    // cylinder analysis
                    CylinderPalletAnalysis analysis = new CylinderPalletAnalysis(cylProperties, palletProperties, null, null, constraintSet);
                    // initialize solver
                    CylinderSolver solver = new CylinderSolver();
                    solver.ProcessAnalysis(analysis);
                    Console.WriteLine("=== Solutions ===");
                    int solIndex = 0;
                    foreach (CylinderPalletSolution sol in analysis.Solutions)
                    {
                        // instantiate graphics
                        Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512));
                        graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                        graphics.Target         = Vector3D.Zero;
                        graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                        // instantiate solution viewer
                        CylinderPalletSolutionViewer sv = new CylinderPalletSolutionViewer(sol);
                        sv.Draw(graphics);
                        string fileName = string.Format("Pallet_{0}.jpg", solIndex++);
                        string filePath = Path.Combine(Path.GetTempPath(), fileName);
                        Console.WriteLine("Saving file " + filePath + "...");
                        graphics.SaveAs(filePath);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(0);
        }