public void ProcessAnalysis(CylinderPalletAnalysis analysis) { _cylProperties = analysis.CylinderProperties; _palletProperties = analysis.PalletProperties; _interlayerProperties = analysis.InterlayerProperties; _interlayerPropertiesAntiSlip = analysis.InterlayerPropertiesAntiSlip; _constraintSet = analysis.ConstraintSet; if (!_constraintSet.IsValid) throw new EngineException("Constraint set is invalid!"); analysis.Solutions = GenerateSolutions(); }
public CylinderPalletAnalysis( CylinderProperties cylProperties , PalletProperties palletProperties , InterlayerProperties interlayerProperties , InterlayerProperties interlayerPropertiesAntiSlip , CylinderPalletConstraintSet constraintSet) : base(cylProperties.ParentDocument) { // setting members CylinderProperties = cylProperties; PalletProperties = palletProperties; InterlayerProperties = interlayerProperties; InterlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip; _constraintSet = constraintSet; // has interlayer ? _constraintSet.HasInterlayer = null != interlayerProperties; _constraintSet.HasInterlayerAntiSlip = null != interlayerPropertiesAntiSlip; }
/// <summary> /// Creates a new cylinder/pallet analysis without generating solutions /// </summary> /// <param name="name">Name</param> /// <param name="description">Description</param> /// <param name="cylinder">Cylinder</param> /// <param name="pallet">Pallet</param> /// <param name="interlayer">Interlayer or null</param> /// <param name="constraintSet">Cylinder/pallet analysis constraint set</param> /// <param name="solutions">Solutions</param> /// <returns>Cylinder/pallet analysis</returns> public CylinderPalletAnalysis CreateNewCylinderPalletAnalysis( string name, string description , CylinderProperties cylinder, PalletProperties pallet , InterlayerProperties interlayer, InterlayerProperties interlayerAntiSlip , CylinderPalletConstraintSet constraintSet , List<CylinderPalletSolution> solutions) { CylinderPalletAnalysis analysis = new CylinderPalletAnalysis( cylinder, pallet, interlayer, interlayerAntiSlip, constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _cylinderPalletAnalyses.Add(analysis); // set solutions analysis.Solutions = solutions; // notify listeners NotifyOnNewCylinderPalletAnalysisCreated(analysis); // set solution selected if its unique if (solutions.Count == 1) analysis.SelectSolutionByIndex(0); return analysis; }
/// <summary> /// Creates a new cylinder analysis in this document + compute solutions /// </summary> /// <param name="name">Name</param> /// <param name="description">Description</param> /// <param name="cylinder">Cylinder</param> /// <param name="pallet">Pallet</param> /// <param name="interlayer">Interlayer or null</param> /// <param name="constraintSet">Cylinder/pallet analysis constraint set</param> /// <param name="solver">Solver</param> /// <returns>Cylinder/pallet analysis</returns> public CylinderPalletAnalysis CreateNewCylinderPalletAnalysis( string name, string description , CylinderProperties cylinder, PalletProperties pallet , InterlayerProperties interlayer, InterlayerProperties interlayerPropertiesAntiSlip , CylinderPalletConstraintSet constraintSet , ICylinderAnalysisSolver solver) { CylinderPalletAnalysis analysis = new CylinderPalletAnalysis( cylinder, pallet, interlayer, interlayerPropertiesAntiSlip, constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _cylinderPalletAnalyses.Add(analysis); // compute analysis solver.ProcessAnalysis(analysis); if (analysis.Solutions.Count < 1) { // remove analysis from list if it has no valid solution _cylinderPalletAnalyses.Remove(analysis); return null; } // notify listeners NotifyOnNewCylinderPalletAnalysisCreated(analysis); Modify(); return analysis; }
private CylinderPalletConstraintSet LoadCylinderPalletConstraintSet(XmlElement eltConstraintSet) { CylinderPalletConstraintSet constraints = new CylinderPalletConstraintSet(); // stop criterions if (constraints.UseMaximumPalletHeight = eltConstraintSet.HasAttribute("MaximumHeight")) constraints.MaximumPalletHeight = UnitsManager.ConvertLengthFrom(double.Parse(eltConstraintSet.Attributes["MaximumHeight"].Value), _unitSystem); if (constraints.UseMaximumNumberOfItems = eltConstraintSet.HasAttribute("ManimumNumberOfItems")) constraints.MaximumNumberOfItems = int.Parse(eltConstraintSet.Attributes["ManimumNumberOfItems"].Value); if (constraints.UseMaximumPalletWeight = eltConstraintSet.HasAttribute("MaximumPalletWeight")) constraints.MaximumPalletWeight = UnitsManager.ConvertMassFrom(double.Parse(eltConstraintSet.Attributes["MaximumPalletWeight"].Value), _unitSystem); if (constraints.UseMaximumLoadOnLowerCylinder = eltConstraintSet.HasAttribute("MaximumLoadOnLowerCylinder")) constraints.MaximumLoadOnLowerCylinder = UnitsManager.ConvertMassFrom(double.Parse(eltConstraintSet.Attributes["MaximumLoadOnLowerCylinder"].Value), _unitSystem); // overhang / underhang if (eltConstraintSet.HasAttribute("OverhangX")) constraints.OverhangX = UnitsManager.ConvertLengthFrom(double.Parse(eltConstraintSet.Attributes["OverhangX"].Value), _unitSystem); if (eltConstraintSet.HasAttribute("OverhangY")) constraints.OverhangY = UnitsManager.ConvertLengthFrom(double.Parse(eltConstraintSet.Attributes["OverhangY"].Value), _unitSystem); return constraints; }
private void AppendCylinderPalletConstraintSet(CylinderPalletConstraintSet cs, XmlElement elemPalletAnalysis, XmlDocument xmlDoc) { string ns = xmlDoc.DocumentElement.NamespaceURI; // solution XmlElement elemConstraintSet = xmlDoc.CreateElement("constraintSet", ns); elemPalletAnalysis.AppendChild(elemConstraintSet); AppendElementValue(xmlDoc, elemConstraintSet, "overhangX", UnitsManager.UnitType.UT_LENGTH, cs.OverhangX); AppendElementValue(xmlDoc, elemConstraintSet, "overhangY", UnitsManager.UnitType.UT_LENGTH, cs.OverhangY); // stopCriterion if (cs.UseMaximumPalletHeight) { XmlElement maximumPalletHeightGroup = xmlDoc.CreateElement("maximumPalletHeightGroup", ns); elemConstraintSet.AppendChild(maximumPalletHeightGroup); // max pallet height AppendElementValue(xmlDoc, maximumPalletHeightGroup, "maximumPalletHeight", UnitsManager.UnitType.UT_LENGTH, cs.MaximumPalletHeight); } if (cs.UseMaximumNumberOfItems) { XmlElement maximumNumberOfItemsGroup = xmlDoc.CreateElement("maximumNumberOfItemsGroup", ns); elemConstraintSet.AppendChild(maximumNumberOfItemsGroup); XmlElement maximumNumberOfItems = xmlDoc.CreateElement("maximumNumberOfItems", ns); maximumNumberOfItems.InnerText = string.Format("{0}", cs.MaximumNumberOfItems); maximumNumberOfItemsGroup.AppendChild(maximumNumberOfItems); } if (cs.UseMaximumPalletWeight) { XmlElement maximumPalletWeightGroup = xmlDoc.CreateElement("maximumPalletWeightGroup", ns); elemConstraintSet.AppendChild(maximumPalletWeightGroup); // max pallet weight AppendElementValue(xmlDoc, maximumPalletWeightGroup, "maximumPalletHeight", UnitsManager.UnitType.UT_MASS, cs.MaximumPalletWeight); } if (cs.UseMaximumLoadOnLowerCylinder) { XmlElement maximumWeightOnBoxGroup = xmlDoc.CreateElement("maximumWeightOnCylinderGroup", ns); elemConstraintSet.AppendChild(maximumWeightOnBoxGroup); // admissible load on top AppendElementValue(xmlDoc, maximumWeightOnBoxGroup, "maximumPalletHeight", UnitsManager.UnitType.UT_MASS, cs.MaximumLoadOnLowerCylinder); } }
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); // 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; }
public CylinderPalletAnalysis CreateNewCylinderPalletAnalysisUI() { FormNewAnalysisCylinder form = new FormNewAnalysisCylinder(this); form.Cylinders = Cylinders.ToArray(); form.Pallets = Pallets.ToArray(); form.Interlayers = Interlayers.ToArray(); if (DialogResult.OK == form.ShowDialog()) { // build constraint set CylinderPalletConstraintSet constraintSet = new CylinderPalletConstraintSet(); // interlayer period constraintSet.HasInterlayer = form.HasInterlayer; constraintSet.InterlayerPeriod = form.InterlayerPeriod; constraintSet.HasInterlayerAntiSlip = form.HasInterlayerAntiSlip; // stop criterion constraintSet.UseMaximumPalletHeight = form.UseMaximumPalletHeight; constraintSet.MaximumPalletHeight = form.MaximumPalletHeight; constraintSet.UseMaximumPalletWeight = form.UseMaximumPalletWeight; constraintSet.MaximumPalletWeight = form.MaximumPalletWeight; constraintSet.UseMaximumNumberOfItems = form.UseMaximumNumberOfItems; constraintSet.MaximumNumberOfItems = form.MaximumNumberOfItems; return CreateNewCylinderPalletAnalysis(form.AnalysisName, form.AnalysisDescription , form.SelectedCylinder, form.SelectedPallet , form.SelectedInterlayer, form.SelectedInterlayerAntiSlip , constraintSet , new CylinderSolver()); } return null; }