Exemplo n.º 1
0
        public static CompositionPlan Move(this CompositionPlan compositionPlan,
                                           CompositionPlan gBest, PsoConfig psoConfig, List <TaskCandidateService> taskCandidateServices)
        {
            int columnsToBeMaskedLocally  = (int)(compositionPlan.TaskServices.Count * psoConfig.C1);
            int columnsToBeMaskedGlobally = compositionPlan.TaskServices.Count - columnsToBeMaskedLocally;

            Random r            = new Random();
            int    mod          = DateTime.Now.Millisecond % 2;
            bool   directionLtr = mod == 1;

            compositionPlan.MoveTowardParticle(compositionPlan.PBest, columnsToBeMaskedLocally, directionLtr);

            compositionPlan.MoveTowardParticle(gBest, columnsToBeMaskedGlobally, !directionLtr);

            compositionPlan.UpdatePBest(psoConfig);

            return(compositionPlan);
        }
Exemplo n.º 2
0
        public static CompositionPlan Move(this CompositionPlan compositionPlan,
                                           CompositionPlan gBest, DpsoConfig DpsoConfig, List <TaskCandidateService> taskCandidateServices)
        {
            double mut = (double)1 / DpsoConfig.Tasks.Count;

            Random r = new Random();

            foreach (TaskService taskService in compositionPlan.TaskServices)
            {
                double rand1 = (double)r.Next(0, 100) / 100;

                if (rand1 < mut)
                {
                    List <WebService> webServices = taskCandidateServices
                                                    .First(t => t.Task.Equals(taskService.Task)).WebServices;

                    int randomIndex = r.Next(0, webServices.Count - 1);

                    //if (taskService.WebService != webServices[randomIndex])
                    //{
                    taskService.WebService = webServices[randomIndex];
                    //}
                }
                else
                if (rand1 < DpsoConfig.Omega)
                {
                    break;
                }
                else if (rand1 < DpsoConfig.C1 + DpsoConfig.Omega)
                {
                    taskService.WebService = compositionPlan.PBest.TaskServices
                                             .First(t => t.Task.Equals(taskService.Task)).WebService;
                }
                else
                {
                    taskService.WebService = gBest.TaskServices
                                             .First(t => t.Task.Equals(taskService.Task)).WebService;
                }
            }

            compositionPlan.UpdatePBest(DpsoConfig);

            return(compositionPlan);
        }