Ejemplo n.º 1
0
        public void Create(ParameterSet parameterSet)
        {
            var dataBase = parameterSet.GetOption <DataBase <ProductionDomainContext> >();

            dataBase.DbContext.Database.EnsureDeleted();
            dataBase.DbContext.Database.EnsureCreated();

            ResourceInitializer.MasterTableResourceCapability(dataBase.DbContext,
                                                              parameterSet.GetOption <Resource>().Value,
                                                              parameterSet.GetOption <Setup>().Value,
                                                              parameterSet.GetOption <Operator>().Value);

            // Article Unit and Type Definitions
            var units = new MasterTableUnit();

            units.Init(dataBase.DbContext);
            var articleTypes = new MasterTableArticleType();

            articleTypes.Init(dataBase.DbContext);


            // Add your Methods here to extract transition Matrix (Übergangsmatrix)

            // Generating Bom's (Stücklisten)

            // Generate Operations
        }
Ejemplo n.º 2
0
        public static void DbInitialize(MasterDBContext context, ModelSize resourceModelSize, ModelSize setupModelSize, ModelSize operatorsModelSize, int numberOfWorkersForProcessing, bool secondResource, bool distributeSetupsExponentially = false)
        {
            context.Database.EnsureCreated();

            // Look for any Entrys.
            if (context.Articles.Any())
            {
                return;   // DB has been seeded
            }
            var resourceCapabilities = MasterTableResourceCapability(context, resourceModelSize, setupModelSize, operatorsModelSize, numberOfWorkersForProcessing, secondResource);

            // Article Definitions
            var units = new MasterTableUnit();

            units.Init(context);
            var articleTypes = new MasterTableArticleType();

            articleTypes.Init(context);

            // requires Units and Article Types
            var articleTable = new MasterTableArticle(articleTypes, units);
            var articles     = articleTable.Init(context);

            MasterTableStock.Init(context, articles);

            var operations = new MasterTableOperation(articleTable, resourceCapabilities, distributeSetupsExponentially);

            operations.Init(context);

            var boms = new MasterTableBom();

            boms.Init(context, articleTable, operations);

            var businessPartner = new MasterTableBusinessPartner();

            businessPartner.Init(context);

            context.SaveChanges();

            var articleToBusinessPartner = new MasterTableArticleToBusinessPartner();

            articleToBusinessPartner.Init(context, businessPartner, articleTable);

            var updateArticleLotSize = context.Articles
                                       .Include(x => x.ArticleType)
                                       .Include(x => x.ArticleToBusinessPartners)
                                       .ToList();

            // TODO noch gemogelt LotSize != PackSize
            foreach (var article in updateArticleLotSize)
            {
                if (article.ToPurchase)
                {
                    article.LotSize = article.ArticleToBusinessPartners.First().PackSize;
                }
            }
            DbUtils.InsertOrUpdateRange(updateArticleLotSize, context.Articles, context);
            context.SaveChanges();
        }
        // Wie könnte man Testen, ob der Algorithmus dem aus SYMTEP enspricht (keine Fehler enthält)
        public ProductStructure GenerateProductStructure(ProductStructureInput inputParameters,
                                                         MasterTableArticleType articleTypes, MasterTableUnit units, M_Unit[] unitCol, XRandom rng)
        {
            var productStructure = new ProductStructure();
            var availableNodes   = new List <HashSet <long> >();

            GenerateParts(inputParameters, productStructure, availableNodes, articleTypes, units, unitCol, rng);

            GenerateEdges(inputParameters, productStructure, rng, availableNodes);

            DeterminationOfEdgeWeights(inputParameters, productStructure, rng);

            return(productStructure);
        }
        private void GenerateParts(ProductStructureInput inputParameters, ProductStructure productStructure,
                                   List <HashSet <long> > availableNodes, MasterTableArticleType articleTypes, MasterTableUnit units,
                                   M_Unit[] unitCol, XRandom rng)
        {
            bool sampleWorkPlanLength = inputParameters.MeanWorkPlanLength != null &&
                                        inputParameters.VarianceWorkPlanLength != null;
            TruncatedDiscreteNormal truncatedDiscreteNormalDistribution = null;

            if (sampleWorkPlanLength)
            {
                truncatedDiscreteNormalDistribution = new TruncatedDiscreteNormal(1, null,
                                                                                  Normal.WithMeanVariance((double)inputParameters.MeanWorkPlanLength,
                                                                                                          (double)inputParameters.VarianceWorkPlanLength, rng.GetRng()));
            }
            for (var i = 1; i <= inputParameters.DepthOfAssembly; i++)
            {
                productStructure.NodesCounter += GeneratePartsForEachLevel(inputParameters, productStructure, availableNodes,
                                                                           articleTypes, units, unitCol, rng, i, sampleWorkPlanLength, truncatedDiscreteNormalDistribution);
            }
        }
Ejemplo n.º 5
0
        public void Create(ParameterSet parameterSet)
        {
            var dataBase = parameterSet.GetOption <DataBase <ProductionDomainContext> >();

            dataBase.DbContext.Database.EnsureDeleted();
            dataBase.DbContext.Database.EnsureCreated();

            var resourceCapabilities = ResourceInitializer.MasterTableResourceCapability(dataBase.DbContext,
                                                                                         parameterSet.GetOption <Resource>().Value,
                                                                                         parameterSet.GetOption <Setup>().Value,
                                                                                         parameterSet.GetOption <Operator>().Value);

            // Article Unit and Type Definitions
            var units = new MasterTableUnit();

            units.Init(dataBase.DbContext);
            var articleTypes = new MasterTableArticleType();

            articleTypes.Init(dataBase.DbContext);

            var articlesData = new ArticleData(articleTypes, units);
            var articles     = articlesData.Init(dataBase.DbContext);

            MasterTableStock.Init(dataBase.DbContext, articles);

            var operations = new OperationData(articlesData, resourceCapabilities);

            operations.Init(dataBase.DbContext);

            var boms = new BomData();

            boms.Init(dataBase.DbContext, articlesData, operations);


            // Add your Methods here to extract transition Matrix (Übergangsmatrix)

            // Generating Bom's (Stücklisten)

            // GenerateBillOfMaterial Operations
        }
Ejemplo n.º 6
0
        internal ArticleData(MasterTableArticleType articleType, MasterTableUnit unit)
        {
            SCHRANK = new M_Article
            {
                Name           = "Schrank",
                ArticleTypeId  = articleType.PRODUCT.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 20,
                UnitId         = unit.PIECES.Id,
                Price          = 200,
                ToPurchase     = false,
                ToBuild        = true
            };

            REGAL = new M_Article
            {
                Name           = "Regal",
                ArticleTypeId  = articleType.PRODUCT.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 20,
                UnitId         = unit.PIECES.Id,
                Price          = 150,
                ToPurchase     = false,
                ToBuild        = true
            };

            RAHMEN = new M_Article
            {
                Name           = "Rahmen",
                ArticleTypeId  = articleType.ASSEMBLY.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 10,
                UnitId         = unit.PIECES.Id,
                Price          = 80,
                ToPurchase     = false,
                ToBuild        = true
            };

            RAHMEN_MIT_RÜCKWAND = new M_Article
            {
                Name           = "Rahmen mit Rückwand",
                ArticleTypeId  = articleType.ASSEMBLY.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 10,
                UnitId         = unit.PIECES.Id,
                Price          = 100,
                ToPurchase     = false,
                ToBuild        = true
            };

            SEITENWAND = new M_Article
            {
                Name           = "Seitenwand",
                ArticleTypeId  = articleType.ASSEMBLY.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 10,
                UnitId         = unit.PIECES.Id,
                Price          = 30,
                ToPurchase     = false,
                ToBuild        = true
            };

            ABLAGE = new M_Article
            {
                Name           = "Ablage",
                ArticleTypeId  = articleType.ASSEMBLY.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 10,
                UnitId         = unit.PIECES.Id,
                Price          = 10,
                ToPurchase     = false,
                ToBuild        = true
            };

            RÜCKWAND = new M_Article
            {
                Name           = "Rückwand",
                ArticleTypeId  = articleType.ASSEMBLY.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 10,
                UnitId         = unit.PIECES.Id,
                Price          = 25,
                ToPurchase     = false,
                ToBuild        = true
            };

            BODENPLATTE = new M_Article
            {
                Name           = "Bodenplatte",
                ArticleTypeId  = articleType.ASSEMBLY.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 10,
                UnitId         = unit.PIECES.Id,
                Price          = 15,
                ToPurchase     = false,
                ToBuild        = true
            };

            DECKPLATTE = new M_Article
            {
                Name           = "Deckplatte",
                ArticleTypeId  = articleType.ASSEMBLY.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 10,
                UnitId         = unit.PIECES.Id,
                Price          = 10,
                ToPurchase     = false,
                ToBuild        = true
            };

            SCHRANKTÜR = new M_Article
            {
                Name           = "Schranktür",
                ArticleTypeId  = articleType.ASSEMBLY.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 10,
                UnitId         = unit.PIECES.Id,
                Price          = 40,
                ToPurchase     = false,
                ToBuild        = true
            };

            METALLDÜBEL = new M_Article
            {
                Name           = "Metalldübel",
                ArticleTypeId  = articleType.MATERIAL.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 5,
                UnitId         = unit.PIECES.Id,
                Price          = 0.5,
                ToPurchase     = true,
                ToBuild        = false
            };

            HOLZBRETT_KURZ = new M_Article
            {
                Name           = "kurzes Holzbrett",
                ArticleTypeId  = articleType.MATERIAL.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 5,
                UnitId         = unit.PIECES.Id,
                Price          = 8,
                ToPurchase     = true,
                ToBuild        = false
            };

            HOLZBRETT_LANG = new M_Article
            {
                Name           = "langes Holzbrett",
                ArticleTypeId  = articleType.MATERIAL.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 5,
                UnitId         = unit.PIECES.Id,
                Price          = 25,
                ToPurchase     = true,
                ToBuild        = false
            };

            TÜRGRIFF = new M_Article
            {
                Name           = "Türgriff",
                ArticleTypeId  = articleType.MATERIAL.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 5,
                UnitId         = unit.PIECES.Id,
                Price          = 2,
                ToPurchase     = true,
                ToBuild        = false
            };

            SCHARNIERE = new M_Article
            {
                Name           = "Scharniere",
                ArticleTypeId  = articleType.MATERIAL.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 5,
                UnitId         = unit.PIECES.Id,
                Price          = 5,
                ToPurchase     = true,
                ToBuild        = false
            };

            SCHRAUBE = new M_Article
            {
                Name           = "Schraube",
                ArticleTypeId  = articleType.MATERIAL.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 5,
                UnitId         = unit.PIECES.Id,
                Price          = 0.2,
                ToPurchase     = true,
                ToBuild        = false
            };

            NAGEL = new M_Article
            {
                Name           = "Nagel",
                ArticleTypeId  = articleType.MATERIAL.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 5,
                UnitId         = unit.PIECES.Id,
                Price          = 0.1,
                ToPurchase     = true,
                ToBuild        = false
            };

            SPANPLATTE = new M_Article
            {
                Name           = "Spanplatte",
                ArticleTypeId  = articleType.MATERIAL.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 5,
                UnitId         = unit.PIECES.Id,
                Price          = 20,
                ToPurchase     = true,
                ToBuild        = false
            };

            FUß = new M_Article
            {
                Name           = "Fuß",
                ArticleTypeId  = articleType.MATERIAL.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 5,
                UnitId         = unit.PIECES.Id,
                Price          = 2,
                ToPurchase     = true,
                ToBuild        = false
            };

            KLEIDERSTANGE = new M_Article
            {
                Name           = "Kleiderstange",
                ArticleTypeId  = articleType.MATERIAL.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 5,
                UnitId         = unit.PIECES.Id,
                Price          = 5,
                ToPurchase     = true,
                ToBuild        = false
            };

            KLEIDERSTANGENHALTERUNG = new M_Article
            {
                Name           = "Kleiderstangenhalterung",
                ArticleTypeId  = articleType.MATERIAL.Id,
                CreationDate   = DateTime.Parse(s: "2020-07-07"),
                DeliveryPeriod = 5,
                UnitId         = unit.PIECES.Id,
                Price          = 0.5,
                ToPurchase     = true,
                ToBuild        = false
            };
        }
Ejemplo n.º 7
0
        public void StartGeneration(Approach approach, MasterDBContext dbContext, ResultContext resultContext, bool doVerify = false)
        {
            dbContext.Database.EnsureDeleted();
            dbContext.Database.EnsureCreated();

            var rng = new XRandom(approach.Seed);

            var units        = new MasterTableUnit();
            var unitCol      = units.Init(dbContext);
            var articleTypes = new MasterTableArticleType();

            articleTypes.Init(dbContext);

            var productStructureGenerator = new ProductStructureGenerator();
            var productStructure          = productStructureGenerator.GenerateProductStructure(approach.ProductStructureInput,
                                                                                               articleTypes, units, unitCol, rng);

            ArticleInitializer.Init(productStructure.NodesPerLevel, dbContext);

            var articleTable = dbContext.Articles.ToArray();

            MasterTableStock.Init(dbContext, articleTable);

            var transitionMatrixGenerator = new TransitionMatrixGenerator();

            TransitionMatrix = transitionMatrixGenerator.GenerateTransitionMatrix(approach.TransitionMatrixInput,
                                                                                  approach.ProductStructureInput, rng);

            List <ResourceProperty> resourceProperties = approach.TransitionMatrixInput.WorkingStations
                                                         .Select(x => (ResourceProperty)x).ToList();

            var resourceCapabilities = ResourceInitializer.Initialize(dbContext, resourceProperties);

            var operationGenerator = new OperationGenerator();

            operationGenerator.GenerateOperations(productStructure.NodesPerLevel, TransitionMatrix,
                                                  approach.TransitionMatrixInput, resourceCapabilities, rng);
            OperationInitializer.Init(productStructure.NodesPerLevel, dbContext);

            var billOfMaterialGenerator = new BillOfMaterialGenerator();

            billOfMaterialGenerator.GenerateBillOfMaterial(approach.BomInput, productStructure.NodesPerLevel,
                                                           TransitionMatrix, units, rng);
            BillOfMaterialInitializer.Init(productStructure.NodesPerLevel, dbContext);

            var businessPartner = new MasterTableBusinessPartner();

            businessPartner.Init(dbContext);

            var articleToBusinessPartner = new ArticleToBusinessPartnerInitializer();

            articleToBusinessPartner.Init(dbContext, articleTable, businessPartner);


            if (doVerify)
            {
                var productStructureVerifier = new ProductStructureVerifier();
                productStructureVerifier.VerifyComplexityAndReutilizationRation(approach.ProductStructureInput,
                                                                                productStructure);

                if (approach.TransitionMatrixInput.ExtendedTransitionMatrix)
                {
                    var transitionMatrixGeneratorVerifier = new TransitionMatrixGeneratorVerifier();
                    transitionMatrixGeneratorVerifier.VerifyGeneratedData(TransitionMatrix,
                                                                          productStructure.NodesPerLevel, resourceCapabilities);
                }
            }

            //##### TEMP
            var incomingEdgeCount = 0;

            foreach (var level in productStructure.NodesPerLevel)
            {
                foreach (var node in level)
                {
                    incomingEdgeCount += node.Value.IncomingEdges.Count;
                }
            }

            var actualCR = incomingEdgeCount / (1.0 * (productStructure.NodesCounter - productStructure.NodesPerLevel[^ 1].Count));
        private static long GeneratePartsForEachLevel(ProductStructureInput inputParameters,
                                                      ProductStructure productStructure, List <HashSet <long> > availableNodes, MasterTableArticleType articleTypes,
                                                      MasterTableUnit units, M_Unit[] unitCol, XRandom rng, int i, bool sampleWorkPlanLength,
                                                      TruncatedDiscreteNormal truncatedDiscreteNormalDistribution)
        {
            //Problem mit Algorithmus aus SYMTEP: bei ungünstigen Eingabeparametern gibt es auf manchen Fertigungsstufen keine Teile (0 Knoten)
            //-> Es fehlt wohl Nebenbedingung, dass Anzahl an Teilen auf jeden Fertigungsstufe mindestens 1 sein darf
            //-> Entsprechend wurde das hier angepasst
            var nodeCount = Math.Max(1, Convert.ToInt64(Math.Round(
                                                            Math.Pow(inputParameters.ComplexityRatio / inputParameters.ReutilisationRatio, i - 1) *
                                                            inputParameters.EndProductCount)));
            var nodesCurrentLevel = new Dictionary <long, Node>();

            productStructure.NodesPerLevel.Add(nodesCurrentLevel);
            var availableNodesOnThisLevel = new HashSet <long>();

            availableNodes.Add(availableNodesOnThisLevel);

            bool          toPurchase, toBuild;
            M_Unit        unit = null;
            M_ArticleType articleType;

            if (i == 1)
            {
                toPurchase  = false;
                toBuild     = true;
                unit        = units.PIECES;
                articleType = articleTypes.PRODUCT;
            }
            else if (i == inputParameters.DepthOfAssembly)
            {
                toPurchase  = true;
                toBuild     = false;
                articleType = articleTypes.MATERIAL;
            }
            else
            {
                toPurchase  = false;
                toBuild     = true;
                unit        = units.PIECES;
                articleType = articleTypes.ASSEMBLY;
            }

            for (long j = 0; j < nodeCount; j++)
            {
                unit = GeneratePartsForCurrentLevel(inputParameters, unitCol, rng, i, sampleWorkPlanLength,
                                                    truncatedDiscreteNormalDistribution, availableNodesOnThisLevel, j, unit, articleType, toPurchase,
                                                    toBuild, nodesCurrentLevel);
            }

            return(nodeCount);
        }
        public static void DbInitialize(MasterDBContext context)
        {
            context.Database.EnsureCreated();

            // Look for any Entrys.
            if (context.Articles.Any())
            {
                return;   // DB has been seeded
            }
            // Resource Definitions
            var resourceTools = new MasterTableResourceTool();

            resourceTools.Init(context);
            // requires Tools
            var resource = new MasterTableResource();

            resource.Init(context);
            // requires Tools and Resources
            var resourceSkills = new MasterTableResourceSkill();

            resourceSkills.Init(context);
            // requires Tools, Resources, and Skills
            var resourceSetups = new MasterTableResourceSetup(resource, resourceTools, resourceSkills);

            resourceSetups.Init(context);

            // Article Definitions
            var units = new MasterTableUnit();

            units.Init(context);
            var articleTypes = new MasterTableArticleType();

            articleTypes.Init(context);

            // requires Units and Article Types
            var articleTable = new MasterTableArticle(articleTypes, units);
            var articles     = articleTable.Init(context);

            MasterTableStock.Init(context, articles);

            var operations = new MasterTableOperation(articleTable, resourceSkills, resourceTools);

            operations.Init(context);

            var boms = new MasterTableBom();

            boms.Init(context, articleTable, operations);

            var businessPartner = new MasterTableBusinessPartner();

            businessPartner.Init(context);

            var articleToBusinessPartner = new MasterTableArticleToBusinessPartner();

            articleToBusinessPartner.Init(context, businessPartner, articleTable);

            var updateArticleLotSize = context.Articles
                                       .Include(x => x.ArticleType)
                                       .Include(x => x.ArticleToBusinessPartners)
                                       .ToList();

            // TODO noch gemogelt LotSize != PackSize
            foreach (var article in updateArticleLotSize)
            {
                if (article.ToPurchase)
                {
                    article.LotSize = article.ArticleToBusinessPartners.First().PackSize;
                }
            }
            DbUtils.InsertOrUpdateRange(updateArticleLotSize, context.Articles, context);
            context.SaveChanges();
        }