internal void RecalcParcour(ParcourSet parcour, Converter c, double channel) { this.parcour = parcour; this.c = c; this.regenerate = true; ParcourModel pm = new ParcourModel(parcour, c, EndLineDist, channel, true); List <List <ParcourModel> > modelList = new List <List <ParcourModel> >(); //System.Diagnostics.Process.GetCurrentProcess(). for (int i = 0; i < 1; i++) { List <ParcourModel> list = new List <ParcourModel>(); modelList.Add(list); list.Add(pm); for (int j = 0; j < 300; j++) { list.Add(new ParcourModel(pm, 1)); } } best = double.MaxValue; bestModel = null; foreach (List <ParcourModel> list in modelList) { Thread t = new Thread(new ParameterizedThreadStart(ProcessList)); t.Start(list); } }
public ParcourModel(ParcourModel pm, double firstWeight) { this.desiredLengthFactor = pm.desiredLengthFactor; this.channel = pm.channel; this.c = pm.c; foreach (ParcourChannel pc in pm.Channels) { AddCorridor(pc); } Randomize(firstWeight); }
private void ProcessList(object o) { List <ParcourModel> list = o as List <ParcourModel>; bool switcher = true; double epsilon = 0.01; double factor = 1f; if (regenerate) { factor = list[0].Weight() / 10; } while (best > epsilon && Math.Abs(factor) * 10 > epsilon) { if (regenerate) { switcher = !switcher; factor = switcher ? factor : -factor; } list.Sort(comparer); ParcourModel first = list[0]; double firstWeight = first.Weight(); if (first.Weight() < best) { bestModel = first; best = first.Weight(); AddBestModel(); } list.Clear(); //list.Add(first); for (int j = 0; j < 300; j++) { list.Add(new ParcourModel(first, factor)); } epsilon += 0.01; if (regenerate) { factor = factor - Math.Sign(factor) * ((Math.Abs(Math.Abs(factor) - epsilon)) / 500); } } finished = true; }
public ParcourChannel(Vector Start, Vector End, LineType type, List <Line> lines, Converter c) { this.Start = Start; this.End = End; List <Line> pointLine = lines.Where(p => p.Type == (int)LineType.Point).ToList(); int i = 0; if (type == LineType.START_B) { i = 9; } else if (type == LineType.START_C) { i = 18; } else if (type == LineType.START_D) { i = 27; } List <Line> corridorPoints = new List <Line>(); for (int j = 0; j < 9; j++) { corridorPoints.Add(pointLine[i + j]); } foreach (Line l in corridorPoints) { Vector v = ParcourModel.getVector(c, l.A); if (isEdited(l)) { ImmutablePoints.Add(v); } LinearCombinations.Add(v); } LinearCombinations.Add(End); }