Beispiel #1
0
        void SetData()
        {
            for (int k = 0; k < MaxJob; k++)
            {
                GeneticTask task = GetTaskProcess(k);
                for (int j = 0; j < MaxProcesses; j++)
                {
                    var process = task.GetProcess(j);

                    for (int i = 0; i < MaxMachines; i++)
                    {
                        if (process == GeneticTask.GeneticProcess.Empty)
                        {
                            // vals[k, j, i] = 0;
                        }
                        else if (process.Machine.Tipo == ResourcesNeeded[i].maquina.Tipo)
                        {
                            // vals[k, j, i] = process.Duration;
                        }
                        else
                        {
                            // vals[k, j, i] = 50000000;
                        }

                        //getBoxControl(boxPanel, k + 1, j + 1, i + 1).Text =  time == 50000 ? "X" : time.ToString();
                    }
                }
            }
        }
Beispiel #2
0
        float[,,] getDatas()
        {
            float[,,] vals = new float[MaxJob, MaxProcesses, MaxMachines];
            for (int k = 0; k < MaxJob; k++)
            {
                GeneticTask task = GetTaskProcess(k);
                for (int j = 0; j < MaxProcesses; j++)
                {
                    var process = task.GetProcess(j);

                    for (int i = 0; i < MaxMachines; i++)
                    {
                        if (process == GeneticTask.GeneticProcess.Empty)
                        {
                            vals[k, j, i] = 0;
                        }
                        else if (process.Machine.Tipo == ResourcesNeeded[i].maquina.Tipo)
                        {
                            vals[k, j, i] = process.Duration;
                        }
                        else
                        {
                            vals[k, j, i] = 500000;
                        }
                    }
                }
            }
            return(vals);
        }
Beispiel #3
0
        public void CreateProject()
        {
            this.context = new MEDIRM.Modelos.MEDIRMContext();

            ResourcesNeeded = new List <GeneticResource>();
            var todasEncomendas = context.Encomendas.Where(x => x.Estado.ToLower() != "terminado");
            var Moldes          = context.Maquinas.Select(x => x.Molde).ToArray();
            List <GeneticResource> resources = new List <GeneticResource>();

            foreach (var encomenda in todasEncomendas)
            {
                var artigo = encomenda.Artigo1;

                //todosArtigosdAsEncomendas.AddRange(context.Artigoes.Where(x => x. == encomenda.Artigo));

                Maquina maquina1C, maquina2C, maquina3C, maquina4C, maquina5C = null;
                var     task                = new GeneticTask(encomenda);
                var     maquina1            = ResourceFromMaquina(artigo.Maquina1, out maquina1C);
                var     maquina2            = ResourceFromMaquina(artigo.Maquina2, out maquina2C);
                var     maquina3            = ResourceFromMaquina(artigo.Maquina3, out maquina3C);
                var     maquina4            = ResourceFromMaquina(artigo.Maquina4, out maquina4C);
                var     maquina5            = ResourceFromMaquina(artigo.Maquina5, out maquina5C);
                int     currentProcessCount = 0;
                if (maquina1 != null)
                {
                    currentProcessCount++;
                    task.Processes.Add(new GeneticTask.GeneticProcess(encomenda, maquina1, maquina1C));
                }
                else
                {
                    task.Processes.Add(GeneticTask.GeneticProcess.Empty);
                }
                if (maquina2 != null)
                {
                    currentProcessCount++;
                    task.Processes.Add(new GeneticTask.GeneticProcess(encomenda, maquina2, maquina2C));
                }
                else
                {
                    task.Processes.Add(GeneticTask.GeneticProcess.Empty);
                }
                if (maquina3 != null)
                {
                    currentProcessCount++;
                    task.Processes.Add(new GeneticTask.GeneticProcess(encomenda, maquina3, maquina3C));
                }
                else
                {
                    task.Processes.Add(GeneticTask.GeneticProcess.Empty);
                }
                if (maquina4 != null)
                {
                    currentProcessCount++;
                    task.Processes.Add(new GeneticTask.GeneticProcess(encomenda, maquina4, maquina4C));
                }
                else
                {
                    task.Processes.Add(GeneticTask.GeneticProcess.Empty);
                }
                if (maquina5 != null)
                {
                    currentProcessCount++;
                    task.Processes.Add(new GeneticTask.GeneticProcess(encomenda, maquina5, maquina5C));
                }
                else
                {
                    task.Processes.Add(GeneticTask.GeneticProcess.Empty);
                }

                if (currentProcessCount > MaxProcessCount)
                {
                    MaxProcessCount = currentProcessCount;
                }
                Tasks.Add(task);
            }



            this.context = new MEDIRM.Modelos.MEDIRMContext();
        }