static void Main(string[] args) { var lines = System.IO.File.ReadAllLines(@"../Data/DataSPIF.csv"); var al = new List<Activity>(); var rl = new List<Resource> (); importCSV (lines, al, rl); for (var i = 1; i <= 1000; i++) { var sd2 = new SchemaData(); sd2.resource = rl.ToList(); sd2.activity = al.ToList(); sd2.allocation = new List<Allocation>(); scheduleResources (50, sd2); var total = 0.0; foreach (var a in sd2.allocation) { total += a.distance; } Console.WriteLine (i.ToString() + ":" + total); } }
static void scheduleResources(int c, SchemaData sd) { foreach (var r in sd.resource) { for (int i = 0; i < c; i++) { var l = new List<Tuple<double, Activity>>(); foreach (var x in sd.activity) { l.Add(new Tuple<double, Activity>(distanceBetweenPointsLatLong(r.lat, r.lon, x.lat, x.lon), x)); } var f = l.OrderBy(x => x.Item1).First(); var all = new Allocation(); all.activityId = f.Item2.id; all.distance = f.Item1; all.resourceId = r.id; sd.allocation.Add(all); sd.activity.Remove(f.Item2); } } }