public void GroupMyBoxes() { for (int i = 0; i < CarryingNow.Count; i++) { for (int j = i + 1; j < CarryingNow.Count; j++) { if ((CarryingNow[i].adress == CarryingNow[j].adress) && (CarryingNow[j].volume + CarryingNow[i].volume <= 1000)) { CarryingNow[i] = CarryingNow[j] + CarryingNow[i]; CarryingNow.Remove(CarryingNow[j]); j--; } } } }
/*(public void SchedulePrint(int [,] DistanceMatrix, List <int> way, string filename) * { * StreamWriter output = new StreamWriter(filename, false); * List<Box> NewCarry = new List<Box>(); * for(int i = 0; i < CarryingNow.Capacity; i++) * { * int adr = way[i + 1]; * int index = 0; * for(int j = 0; j < CarryingNow.Capacity; j++) * { * if(CarryingNow[j].adress == adr) * { * index = j; * break; * } * } * NewCarry.Add(CarryingNow[index]); * } * for(int i = 0; i < way.Capacity - 3; i++) * { * mytime.AddMinutes(15 + Math.Round(DistanceMatrix[way[i], way[i + 1]] / speed)); * output.WriteLine("{0, 25} | {1, 25} | {2}:{3}", NewCarry[i].number, Adresses[NewCarry[i].adress].adress, mytime.Hour, mytime.Minute); * } * * mytime.AddMinutes(15 + Math.Round(DistanceMatrix[way.Capacity - 3, way.Capacity - 2] / speed)); * output.WriteLine("{0, 50} | {1}:{2}", "Warehouse", mytime.Hour, mytime.Minute); * output.Close(); * }*/ private List <Box> FillBack() { double volume = 0; for (int i = 0; i < CarryingNow.Count; i++)//random shuffle { Box temp = CarryingNow[i]; CarryingNow.RemoveAt(i); CarryingNow.Insert(Program.random.Next(CarryingNow.Count), temp); } List <Box> package = new List <Box>(); for (int i = CarryingNow.Count - 1; i >= 0; i--) { if (volume + CarryingNow[i].volume <= capacity && package.Count <= 18) { volume += CarryingNow[i].volume; package.Add(CarryingNow[i]); } } return(package); }
public void LoadOutToFile(string filename) { using (StreamWriter writer = new StreamWriter(filename + ".csv")) { using (CsvWriter csvWriter = new CsvWriter(writer, System.Globalization.CultureInfo.CurrentCulture)) { List <FileLine> output = new List <FileLine>(); foreach (Box box in CarryingNow) { string adr = box.adress.adress; FileLine line = new FileLine(); line.Destination = adr; line.Packages = box.number; line.Approach = "Warehouse"; output.Add(line); } csvWriter.Configuration.Delimiter = ";"; csvWriter.WriteRecords(output); } } CarryingNow.Clear(); volumecarrying = 0; }
public Box TakeBox(Box item) { CarryingNow.Remove(item); return(item); }
public void AddBox(Box b) { CarryingNow.Add(b); volumecarrying += b.volume; }