Ejemplo n.º 1
0
        private void HeuristicScheduling()
        {
            MPCLSPSet dataset = ((MPCLSPSolution)_problem.Solution).Dataset;

            dataset.Periods.ForEach(period =>
            {
                Schedule schedule = null;
                MPCLSPPlant plant = null;
                int capacity      = 0;
                period.BestPP.ForEach(bpp =>
                {
                    if (schedule == null)
                    {
                        schedule         = new Schedule();
                        schedule.Dataset = dataset;
                        schedule.Period  = period.UID;
                        if (plant == null)
                        {
                            plant = dataset.Plants.Find(p => p.UID == bpp.Item1);
                            schedule.Plants.Add(plant.UID);
                            capacity = period.Capacity[plant.UID];
                        }
                    }

                    int pdp = period.ProductDemandInPeriod(bpp.Item2);
                    if (capacity > pdp)
                    {
                        plant.InstalledProducts.Add(bpp.Item2);
                        schedule.ProductionQuantity.Add(bpp.Item2, pdp);
                        capacity -= pdp;
                    }
                    else
                    {
                        plant.FullField    = true;
                        plant.LeftCapacity = capacity;
                        plant = dataset.Plants.Find(new_plant => new_plant.UID == plant.BestNeighborPlant());
                        schedule.Plants.Add(plant.UID);
                        plant.InstalledProducts.Add(bpp.Item2);
                        capacity = period.Capacity[plant.UID];
                    }
                });
                ((MPCLSPSolution)_problem.Solution).Schedules.Add(period.UID, schedule);
            });
        }