コード例 #1
0
ファイル: VrpTest.cs プロジェクト: SCY95/VRP-Optimization
        public static void Main(String[] args)
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("En");

            // Instantiate the data problem.
            DataInput    dataInput  = new DataInput();  //Config interface
            DataOutput   dataOutput = new DataOutput(); //Output interface
            VrpProblem   vrpProblem = new VrpProblem();
            ConfigParams cfg        = new ConfigParams();

            //Period(x) => period for x days
            Period period       = new Period(14);
            bool   AssignToDays = true;

            int[] VCMinMax = new int[2];//Vehicle Count
            dataInput.GetVCMinMax(VCMinMax);



            if (AssignToDays == true)
            {
                LocationDB.ResetVisitDays(LocationDB.Locations);

                for (int i = 0; i < period.Days.Count; i++)
                {
                    if (i == 6 || i == 13)
                    {
                        continue;
                    }
                    GetInput(dataInput, cfg, period.Days.ElementAt(i));
                    if (i < 6)
                    {
                        period.Days.ElementAt(i).SetDay(LocationDB.Locations.Where(x => x.VisitDay == 0 && x.Infeasible == false).ToList());
                        period.Days.ElementAt(i).DayNum = i + 1;
                        AssignAndSolveForDay(dataInput, dataOutput, vrpProblem, period.Days.ElementAt(i), cfg, VCMinMax);
                    }
                    if (i > 6)
                    {
                        List <Location> locations = new List <Location>();
                        foreach (var item in period.Days.ElementAt(i - 7).Locations.Where(x => x.VisitPeriod == 7).ToList())
                        {
                            item.Penalty = 1000000;
                            locations.Add(item);
                        }
                        locations.AddRange(LocationDB.Locations.Where(x => x.VisitDay == 0 && x.VisitPeriod == 14 && x.Infeasible == false).ToList());

                        period.Days.ElementAt(i).SetDay(locations);

                        period.Days.ElementAt(i).DayNum = i + 1;

                        AssignAndSolveForDay(dataInput, dataOutput, vrpProblem, period.Days.ElementAt(i), cfg, VCMinMax);
                    }
                }
                period.PrintSummary();
            }
            else
            {
                SetLocationsForDays(period);

                LocationDB.GetLocationDataFromDB();

                for (int i = 0; i < period.Days.Count; i++)
                {
                    if (period.Days.ElementAt(i).Locations.Count != 0)
                    {
                        GetInput(dataInput, cfg, period.Days.ElementAt(i));
                        SolveForAssignedDay(dataInput, dataOutput, vrpProblem, period.Days.ElementAt(i), cfg, VCMinMax);
                    }
                }

                period.PrintSummary();
            }



            Console.ReadLine();
            return;
        }