public void ProcessAnalysis(BoxCasePalletAnalysis analysis)
 {
     _boxProperties = analysis.BoxProperties;
     _interlayerProperties = analysis.InterlayerProperties;
     _palletSolutionList = analysis.PalletSolutionsList;
     _constraintSet = analysis.ConstraintSet;
     analysis.Solutions = GenerateSolutions();
 }
 public BoxCasePalletAnalysis(BoxProperties boxProperties, List<PalletSolutionDesc> palletSolutionList, BoxCasePalletConstraintSet constraintSet)
     : base(boxProperties.ParentDocument)
 {
     if (!constraintSet.IsValid)
         throw new Exception("Using invalid case constraintset -> Can not instantiate case analysis!");
     _boxProperties = boxProperties;
     boxProperties.AddDependancy(this);
     _palletSolutionsList = palletSolutionList;
     _constraintSet = constraintSet;
 }
 public BoxCasePalletAnalysis(BoxProperties boxProperties, List <PalletSolutionDesc> palletSolutionList, BoxCasePalletConstraintSet constraintSet)
     : base(boxProperties.ParentDocument)
 {
     if (!constraintSet.IsValid)
     {
         throw new Exception("Using invalid case constraintset -> Can not instantiate case analysis!");
     }
     _boxProperties = boxProperties;
     boxProperties.AddDependancy(this);
     _palletSolutionsList = palletSolutionList;
     _constraintSet       = constraintSet;
 }
Пример #4
0
 public BoxCasePalletAnalysis CreateNewBoxCasePalletOptimization(
     string name, string description
     , BoxProperties bProperties
     , BoxCasePalletConstraintSet constraintSet
     , List<PalletSolutionDesc> palletSolutionList
     , IBoxCasePalletAnalysisSolver solver)
 {
     BoxCasePalletAnalysis analysis = new BoxCasePalletAnalysis(bProperties, palletSolutionList, constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _boxCasePalletOptimizations.Add(analysis);
     // compute analysis
     if (null != solver)
     {
         solver.ProcessAnalysis(analysis);
         if (analysis.Solutions.Count < 1)
         {	// remove analysis from list if it has no valid solution
             _boxCasePalletOptimizations.Remove(analysis);
             _log.InfoFormat("Failed to find any solution {0}", analysis.Name);
             return null;
         }
     }
     // notify listeners
     NotifyOnNewCaseAnalysisCreated(analysis);
     Modify();
     return analysis;
 }
Пример #5
0
 private BoxCasePalletConstraintSet LoadCaseConstraintSet(XmlElement eltConstraintSet)
 {
     BoxCasePalletConstraintSet constraints = new BoxCasePalletConstraintSet();
     // align layers allowed
     if (eltConstraintSet.HasAttribute("AlignedLayersAllowed"))
         constraints.AllowAlignedLayers = string.Equals(eltConstraintSet.Attributes["AlignedLayersAllowed"].Value, "true", StringComparison.CurrentCultureIgnoreCase);
     // alternate layers allowed
     if (eltConstraintSet.HasAttribute("AlternateLayersAllowed"))
         constraints.AllowAlternateLayers = string.Equals(eltConstraintSet.Attributes["AlternateLayersAllowed"].Value, "true", StringComparison.CurrentCultureIgnoreCase);
     // allowed orthogonal axes
     if (eltConstraintSet.HasAttribute("AllowedBoxPositions"))
         constraints.AllowOrthoAxisString = eltConstraintSet.Attributes["AllowedBoxPositions"].Value;
     // allowed patterns
     if (eltConstraintSet.HasAttribute("AllowedPatterns"))
         constraints.AllowedPatternString = eltConstraintSet.Attributes["AllowedPatterns"].Value;
     // stop criterions
     if (constraints.UseMaximumNumberOfItems = eltConstraintSet.HasAttribute("ManimumNumberOfItems"))
         constraints.MaximumNumberOfItems = int.Parse(eltConstraintSet.Attributes["ManimumNumberOfItems"].Value);
     // maximum case weight
     if (constraints.UseMaximumCaseWeight = eltConstraintSet.HasAttribute("MaximumCaseWeight"))
         constraints.MaximumCaseWeight = UnitsManager.ConvertMassFrom(double.Parse(eltConstraintSet.Attributes["MaximumCaseWeight"].Value), _unitSystem);
     // number of solutions to keep
     if (constraints.UseNumberOfSolutionsKept = eltConstraintSet.HasAttribute("NumberOfSolutions"))
         constraints.NumberOfSolutionsKept = int.Parse(eltConstraintSet.Attributes["NumberOfSolutions"].Value);
     // minimum number of items
     if (constraints.UseMinimumNumberOfItems = eltConstraintSet.HasAttribute("MinimumNumberOfItems"))
         constraints.MinimumNumberOfItems = int.Parse(eltConstraintSet.Attributes["MinimumNumberOfItems"].Value);
     // sanity check
     if (!constraints.IsValid)
         throw new Exception("Invalid constraint set");
     return constraints;
 }
Пример #6
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;
        }