Ejemplo n.º 1
0
        public List<ISolutionPosSpeed> InitializeStart()
        {
            List<ISolutionPosSpeed> t = new List<ISolutionPosSpeed>();
            for (int i = 0; i < this.numberOfPopulation; i++)
            {
                ISolutionPosSpeed te = new SolutionPosSpeed(this.workToDos.Length, this.workerMens.Length, null);
                t.Add(te);             
            }

            foreach (var item in t)
            {
                //var ran = random.Next(t.Count);
                var localOptimum = new SolutionPosSpeed(this.workToDos.Length, this.workerMens.Length, null);
                item.LocalOptimum = localOptimum;
            }
            return t;
        }
Ejemplo n.º 2
0
        public List<ISolutionPosSpeed> Evaluation(List<ISolutionPosSpeed> population, ref ISolutionPosSpeed globalOptimum)
        {
            List<ISolutionPosSpeed> newPop = new List<ISolutionPosSpeed>(); 
            foreach (var item in population)
            {
                var temp = item;
                int fitnesItem = this.Fitness(temp);

                //TODO Megkérdezni, hogy erre miért van szükség, felesleg munka csupán!!!
                if (fitnesItem < this.Fitness(temp.LocalOptimum))
                {

                    temp.LocalOptimum = new SolutionPosSpeed(
                        new PositionPS((temp.Position as PositionPS).GetPosition(), this.workerMens.Length),
                        new Velocy(this.workerMens.Length, (temp.Speed as Velocy).GetVelocy())
                        );
                    Console.WriteLine("Fitnessz kisebb, mint a lokális optimumé, Round" + this.maxIterations);
                }

                if (fitnesItem < this.Fitness(globalOptimum))
                {
                    Console.WriteLine("Fitnessz kisebb, mint a GLOBÁLIS optimumé, Round: " + this.maxIterations);
                    globalOptimum = new SolutionPosSpeed(
                        new PositionPS((temp.Position as PositionPS).GetPosition(), this.workerMens.Length),
                        new Velocy(this.workerMens.Length, (temp.Speed as Velocy).GetVelocy())
                        );

                }

                newPop.Add(new SolutionPosSpeed(
    new PositionPS((temp.Position as PositionPS).GetPosition(), this.workerMens.Length),
    new Velocy(this.workerMens.Length, (temp.Speed as Velocy).GetVelocy()))
                { LocalOptimum = temp.LocalOptimum });
            }
            return newPop;
        }
Ejemplo n.º 3
0
 public SolutionPosSpeed(int numberOfJobs, int numberOfWorkers, SolutionPosSpeed localOptimum)
 {
     Position     = new PositionPS(numberOfJobs, numberOfWorkers);
     Speed        = new Velocy(numberOfJobs, numberOfWorkers);
     LocalOptimum = localOptimum;
 }