예제 #1
0
            public Population(TSP _src, int amount, List <Individual> started_individuals = null)
            {
                if (started_individuals == null)
                {
                    started_individuals = new List <Individual>();
                }

                fixed_amount = amount + started_individuals.Count;
                this._src    = _src;
                individuals  = new List <Individual>(fixed_amount);
                var src_range = Enumerable.Range(1, _src.numberOfVertices - 1);

                for (int i = 0; i < amount; i++)
                {
                    List <int> _tmp_list = _src.Shuffle(new List <int>(src_range));
                    _tmp_list.Add(0);
                    _tmp_list.Insert(0, 0);
                    individuals.Add(new Individual(_src, _tmp_list));
                }
                individuals.AddRange(started_individuals.GetRange(0, started_individuals.Count));
                Sort_invididuals();
            }
예제 #2
0
 public Individual(TSP source, List <int> chromos)
 {
     this._source = source;
     this.chromos = chromos;
     UpdateValue();
 }