Exemplo n.º 1
0
Arquivo: NEH.cs Projeto: ShyPie/PFSP
        public IProblem Run(IProblem problem)
        {
            problem = problem.Copy();
            var    rand      = new Random();
            var    data      = problem.GetData();
            double totalTime = problem.GetSumOfJobs();
            var    sequence  = problem.GetJobSequence();

            problem.ClearJobSequence();
            while (totalTime != 0)
            {
                for (int i = 0; i < sequence.Count; ++i)
                {
                    if (sequence[i] != -1)
                    {
                        var val     = rand.Next(0, Convert.ToInt32(totalTime + 0.5));
                        var curTime = data.Jobs[sequence[i]].GetSumOfTasks();
                        if (val <= curTime)
                        {
                            problem.PushJob(sequence[i]);
                            sequence[i] = -1;
                            totalTime  -= curTime;
                        }
                    }
                }
            }
            return(problem);
        }
Exemplo n.º 2
0
Arquivo: NEH.cs Projeto: ShyPie/PFSP
        public IProblem Run(IProblem problem)
        {
            problem = problem.Copy();
            problem = m_sort.Run(problem);
            problem = m_randomization.Run(problem);
            List <int> sortedSequence = problem.GetJobSequence();

            problem.ClearJobSequence();
            problem.PushJob(sortedSequence[0]);
            for (int i = 1; i < sortedSequence.Count; ++i)
            {
                problem.InsertJob2BestPlace(sortedSequence[i]);
            }

            return(problem);
        }
Exemplo n.º 3
0
Arquivo: BRILS.cs Projeto: ShyPie/PFSP
        public IProblem Run(IProblem problem)
        {
            problem = problem.Copy();
            int temp = -1;

            problem = m_initAlgorithm.Run(problem);
            List <int> bestSolution       = problem.GetJobSequence();
            List <int> baseSolution       = bestSolution;
            double     baseSolutionResult = problem.GetMakespanWithPenalty();
            double     bestSolutionResult = baseSolutionResult;
            double     credit             = 0;

            for (int i = 0; i < m_iterations; ++i)
            {
                Random rand  = new Random();
                int    left  = rand.Next(0, problem.GetJobSequence().Count);
                int    right = rand.Next(0, problem.GetJobSequence().Count);
                if (left > right)
                {
                    temp  = left;
                    left  = right;
                    right = temp;
                }
                problem.Perturbate(left, right);
                baseSolution = problem.GetJobSequence();
                problem.ClearJobSequence();
                for (int j = 0; j < left; ++j)
                {
                    problem.PushJob(baseSolution[j]);
                }
                problem.InsertJob2BestPlace(baseSolution[left]);
                for (int j = left + 1; j < right; ++j)
                {
                    problem.PushJob(baseSolution[j]);
                }
                problem.InsertJob2BestPlace(baseSolution[right]);
                for (int j = right + 1; j < baseSolution.Count; ++j)
                {
                    problem.PushJob(baseSolution[j]);
                }
                double curResult = problem.GetMakespanWithPenalty();
                double delta     = curResult - baseSolutionResult;

                if (delta == 0)
                {
                    continue;
                }

                if (delta < 0)
                {
                    credit             = (-1) * delta;
                    baseSolution       = problem.GetJobSequence();
                    baseSolutionResult = curResult;
                    if (baseSolutionResult < bestSolutionResult)
                    {
                        bestSolution       = baseSolution;
                        bestSolutionResult = baseSolutionResult;
                    }
                }
                else if (delta <= credit)
                {
                    credit            -= delta;
                    baseSolution       = problem.GetJobSequence();
                    baseSolutionResult = curResult;
                }
                else
                {
                    problem.ClearJobSequence();
                    for (int j = 0; j < bestSolution.Count(); ++j)
                    {
                        problem.PushJob(bestSolution[j]);
                    }
                    return(problem);
                }
            }
            problem.ClearJobSequence();
            for (int j = 0; j < bestSolution.Count(); ++j)
            {
                problem.PushJob(bestSolution[j]);
            }
            return(problem);
        }
Exemplo n.º 4
0
Arquivo: NEH.cs Projeto: ShyPie/PFSP
 public IProblem Run(IProblem problem)
 {
     problem = problem.Copy();
     problem.SortBySumOfMoments();
     return(problem);
 }
Exemplo n.º 5
0
Arquivo: NEH.cs Projeto: ShyPie/PFSP
 public IProblem Run(IProblem problem)
 {
     problem = problem.Copy();
     problem.Sort();
     return(problem);
 }
Exemplo n.º 6
0
Arquivo: NEH.cs Projeto: ShyPie/PFSP
 public IProblem Run(IProblem problem)
 {
     return(problem.Copy());
 }