//Constructor for blank tour public Tour() { for (int i = 0; i < TourManager.NumberOfCities(); i++) { tour.Add(null); } }
// Creates random tour public void GenerateIndividual(double fuel) { for (int cityIndex = 0; cityIndex < TourManager.NumberOfCities(); cityIndex++) { SetCity(cityIndex, TourManager.GetCity(cityIndex)); } SetMaxFuel(fuel); }
//Constructor for blank tour public Tour() { for (int i = 0; i < TourManager.NumberOfCities(); i++) { tour.Add(null); } this.trucksLoad = new double[TourManager.trucksLoad.Count()]; for (int index = 0; index < TourManager.trucksLoad.Count(); index++) { this.trucksLoad[index] = TourManager.trucksLoad[index]; } }
// Creates random tour public void GenerateIndividual(double fuel, Random random) { for (int cityIndex = 0; cityIndex < TourManager.NumberOfCities(); cityIndex++) { Boolean choosed = false; AlgCity algCity = new AlgCity(TourManager.GetCity(cityIndex)); algCity.Truck = random.Next(1, 4); while (!choosed) { algCity.Truck = random.Next(1, 4); if (this.trucksLoad[algCity.Truck] >= algCity.Weight) { if (this.tour[0] != null) { this.trucksLoad[algCity.Truck] -= algCity.Weight; } SetCity(cityIndex, algCity); choosed = true; } } } SetMaxFuel(fuel); }