public CaseDefinitionViewer(CaseDefinition caseDefinition, BoxProperties boxProperties, CaseOptimConstraintSet caseConstraintSet) { _caseDefinition = caseDefinition; _boxProperties = boxProperties; _caseOptimConstraintSet = caseConstraintSet; _globalOrientation = new Orientation(HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); }
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 CaseOptimConstraintSet caseOptimConstraintSet = new CaseOptimConstraintSet( 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 ); CaseOptimizer caseOptimizer = new CaseOptimizer(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()); } }
public CaseOptimizer( BoxProperties boxProperties , PalletProperties palletProperties , PalletConstraintSet palletContraintSet , CaseOptimConstraintSet caseOptimConstraintSet) { _boxProperties = boxProperties; _palletProperties = palletProperties; _palletConstraintSet = palletContraintSet; _caseOptimConstraintSet = caseOptimConstraintSet; }
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(); }