예제 #1
0
        private void CreateModel(IEnumerable <Product> productenumerable, ulong simulationTime)
        {
            var products = productenumerable.ToList();

            sims.Clear();
            //simprogress.Value = 0;

            var involvedproductsjobs = products.Select(t => t.Nodes).Distinct();

            for (int i = 0; i < _nrOfIterations; i++)
            {
                var machines = new List <DESMachine>();
                var sim      = new SimulationModel()
                {
                    ClosingTime = simulationTime
                };
                var enumerable = involvedproductsjobs as ObservableCollection <Pair <ModelNode, Job> >[] ?? involvedproductsjobs.ToArray();

                foreach (var involvedproductsjob in enumerable)
                {
                    foreach (var pair in involvedproductsjob)
                    {
                        var machine = machines.FirstOrDefault(t => t.Name == pair.Key.ResourceModel.ProcessName);
                        if (machine == null)
                        {
                            DESMachine parent = CreateParentMachines(pair.Key, machines, sim);
                            machine = new DESMachine(sim, pair.Key, parent);
                            machines.Add(machine);
                        }
                    }
                }
                sim.AddMachines(machines);

                foreach (var product in products)
                {
                    sim.AddProduct(product.ProductName,
                                   product.Nodes.Select(
                                       t =>
                                       new Pair <DESMachine, Job>(
                                           machines.FirstOrDefault(p => p.Name == t.Key.ResourceModel.ProcessName), t.Value))
                                   .ToList());
                }


                sim.PropertyChanged += sim_PropertyChanged;

                sims.Add(sim);
            }
        }
예제 #2
0
        public DESMachine(SimulationModel sim, ModelNode involvednode, DESMachine parentNode) : base(sim)
        {
            Name = involvednode.ResourceModel.ProcessName;
            if (involvednode.ResourceModel.HasBreakdown)
            {
                breakdown = involvednode.ResourceModel.MTBF.Distribution.DESRandom;
                repair    = involvednode.ResourceModel.MTTR.Distribution.DESRandom;
                GetBreakdown(sim).Activate(sim);
            }
            _machine  = DESResource.Create(involvednode.ResourceModel.Capacity);
            parentDES = parentNode;
            DESMachine p = parentNode;

            while (p != null)
            {
                parents.Add(p);
                p = p.parentDES;
            }
            Machine.AllowOwnMany = false;
            currentstatus.Add("Idle", 0);
        }
예제 #3
0
        private static DESMachine CreateParentMachines(ModelNode node, List <DESMachine> machines, SimulationModel sim)
        {
            DESMachine DESNode = null;

            if (node.ParentNode != null)
            {
                DESMachine parent = CreateParentMachines(node.ParentNode, machines, sim);
                DESNode = machines.FirstOrDefault(t => t.Name == node.ParentNode.ResourceModel.ProcessName);
                if (DESNode == null)
                {
                    DESNode = new DESMachine(sim, node.ParentNode, parent);
                    machines.Add(DESNode);
                }
            }
            return(DESNode);
        }