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); }
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++; }
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); } }
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); }
public void Add(Expert expert) { _experts.Add(expert); }