Esempio n. 1
0
        public bool SolveForFeature(int feature)
        {
            List <Expert> viableExperts = _problem.listExperts
                                          .FindAll(e => e.HasFeature(feature) == true)
                                          .OrderByDescending(e => e.Fitness)
                                          .ToList();

            while (viableExperts.Count > 0)
            {
                Project project = _stackOfProjectsByLeastDifficulty
                                  .ToList()
                                  .Find(p => p.HasFeature(feature));

                if (project == null)
                {
                    // No more matches.
                    return(false);
                }

                while (project.HasFeature(feature) && viableExperts.Count > 0)
                {
                    Expert expert = viableExperts.Last();
                    viableExperts.RemoveAt(viableExperts.Count - 1);
                    Assign(expert, project, feature);
                }
            }

            return(true);
        }
Esempio n. 2
0
 public void Assign(Expert expert, Project project, int feature)
 {
     _problem.listExperts.Remove(expert);
     project.Features[feature]--;
     if (project.IsCompleted)
     {
         _problem.listProjects.Remove(project);
     }
     _solution.Add(project, expert);
     _solution.Sum++;
 }
Esempio n. 3
0
        public void Add(Project project, Expert expert = null)
        {
            ProjectSolution projSol = _projectSolutions.Find(s => s.Project.Index == project.Index);

            if (projSol == null)
            {
                projSol = new ProjectSolution(project);
                _projectSolutions.Add(projSol);
            }
            if (expert != null)
            {
                projSol.Add(expert);
            }
        }
Esempio n. 4
0
        public bool SolveForProject(Project project)
        {
            for (int feature = 0; feature < project.Features.Count(); feature++)
            {
                if (project.Features[feature] > 0)
                {
                    List <Expert> viableExperts = _problem.listExperts
                                                  .FindAll(e => e.HasFeature(feature) == true)
                                                  .OrderByDescending(e => e.Fitness)
                                                  .ToList();
                    while (project.Features[feature] > 0 & viableExperts.Count > 0)
                    {
                        Expert expert = viableExperts.Last();
                        viableExperts.RemoveAt(viableExperts.Count - 1);
                        Assign(expert, project, feature);
                    }
                }
            }

            return(true);
        }
Esempio n. 5
0
 public void Add(Expert expert)
 {
     _experts.Add(expert);
 }