Пример #1
0
 public ParcourModelSingle(ParcourModelSingle pm, double firstWeight)
 {
     this.desiredLength = pm.desiredLength;
     this.channelWidth  = pm.channelWidth;
     this.c             = pm.c;
     AddCorridor(pm.Channel);
     Randomize(firstWeight);
 }
Пример #2
0
        private void ProcessList(object o)
        {
            List <ParcourModelSingle> list = o as List <ParcourModelSingle>;
            bool   switcher = true;
            double epsilon  = 0.001;
            double factor   = 0.1f;

            if (regenerate)
            {
                factor = list[0].Weight(c) / 10;
            }
            while (best > epsilon && Math.Abs(factor) * 10 > epsilon)
            {
                System.Console.Out.WriteLine(best + "," + epsilon + " " + factor);
                if (regenerate)
                {
                    switcher = !switcher;
                    factor   = switcher ? factor : -factor;
                }
                list.Sort(comparer);
                ParcourModelSingle first       = list[0];
                double             firstWeight = first.Weight(c);
                if (first.Weight(c) < best)
                {
                    bestModel = first;
                    best      = first.Weight(c);
                    AddBestModel();
                }
                list.Clear();
                for (int j = 0; j < 300; j++)
                {
                    list.Add(new ParcourModelSingle(first, factor));
                }
                epsilon += 0.0001;
                if (regenerate)
                {
                    factor = factor - Math.Sign(factor) * ((Math.Abs(Math.Abs(factor) - epsilon)) / 500);
                }
            }
            finished = true;
        }
Пример #3
0
        internal void RecalcParcour(ParcourSet parcour, Converter c, double channel, double channelLength)
        {
            this.parcour    = parcour;
            this.c          = c;
            comparer        = new ComparerSingle(c);
            this.regenerate = true;
            ParcourModelSingle pm;

            if (parcour.Line.Count > 2)
            {
                pm = new ParcourModelSingle(parcour, c, channel, channelLength, true);
            }
            else
            {
                pm = new ParcourModelSingle(parcour, c, channel, channelLength);
            }
            List <List <ParcourModelSingle> > modelList = new List <List <ParcourModelSingle> >();

            //System.Diagnostics.Process.GetCurrentProcess().
            for (int i = 0; i < 1; i++)
            {
                List <ParcourModelSingle> list = new List <ParcourModelSingle>();
                modelList.Add(list);
                list.Add(pm);
                for (int j = 0; j < 300; j++)
                {
                    list.Add(new ParcourModelSingle(pm, 1));
                }
            }
            best      = double.MaxValue;
            bestModel = null;

            foreach (List <ParcourModelSingle> list in modelList)
            {
                Thread t = new Thread(new ParameterizedThreadStart(ProcessList));
                t.Start(list);
            }
        }
Пример #4
0
 public ParcourModelSingle(ParcourModelSingle pm, double firstWeight)
 {
     this.desiredLength = pm.desiredLength;
     this.channelWidth = pm.channelWidth;
     this.c = pm.c;
     AddCorridor(pm.Channel);
     Randomize(firstWeight);
 }