Esempio n. 1
0
        /// <summary>
        /// Creates a new case analysis
        /// </summary>
        /// <returns>created case analysis</returns>
        public BoxCasePalletAnalysis CreateNewBoxCasePalletOptimizationUI()
        {
            FormNewCaseAnalysis form = new FormNewCaseAnalysis(this);
            form.Boxes = Boxes.ToArray();
            if (DialogResult.OK == form.ShowDialog())
            {
                BoxCasePalletConstraintSet constraintSet = new BoxCasePalletConstraintSet();
                // aligned / alternate layers
                constraintSet.AllowAlignedLayers = form.AllowAlignedLayers;
                constraintSet.AllowAlternateLayers = form.AllowAlternateLayers;
                // patterns
                foreach (string patternName in form.AllowedPatterns)
                    constraintSet.SetAllowedPattern(patternName);
                // 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);
                // use maximum case weight
                constraintSet.UseMaximumCaseWeight = form.UseMaximumCaseWeight;
                constraintSet.MaximumCaseWeight = form.MaximumCaseWeight;
                // use maximum number of boxes
                constraintSet.UseMaximumNumberOfItems = form.UseMaximumNumberOfItems;
                constraintSet.MaximumNumberOfItems = form.MaximumNumberOfItems;
                // minimum number of items
                constraintSet.MinimumNumberOfItems = form.MinimumNumberOfItems;
                constraintSet.UseMinimumNumberOfItems = form.UseMinimumNumberOfItems;
                // number of solutions kept
                constraintSet.NumberOfSolutionsKept = form.NumberOfSolutionsKept;

                if (!constraintSet.IsValid)
                {
                    MessageBox.Show(string.Format(Properties.Resources.ID_CASEANALYSIS_INVALIDCONSTRAINTSET));
                    return null; // invalid constraint set -> exit
                }

                 return CreateNewBoxCasePalletOptimization(
                    form.CaseAnalysisName
                    , form.CaseAnalysisDescription
                    , form.SelectedBox
                    , constraintSet
                    , form.PalletSolutionList
                    , new BoxCasePalletSolver());
            }
            return null;
        }