コード例 #1
0
 /// <summary>
 /// Solves the assignment task for given data.
 /// </summary>
 /// <returns>Returns array of matches:
 /// 0 ~ proper match
 /// 1 ~ tasks which did not match any agent
 /// 2 ~ agents that did not match any task
 /// </returns>
 public IEnumerable <Tuple <int, int> >[] GetPerfectAssignment <AgentType, TaskType>(IEnumerable <AgentType> Agents, IEnumerable <TaskType> Tasks, Extensions.DistanceGetter <AgentType, TaskType> getDistance)
 {
     initMatrix(Agents, Tasks, getDistance);
     return(GetPerfectAssignment());
 }
コード例 #2
0
        public void initMatrix <AgentType, TaskType>(IEnumerable <AgentType> Agents, IEnumerable <TaskType> Tasks, Extensions.DistanceGetter <AgentType, TaskType> getDistance)
        {
            //if (Agents.Count() > Dimension || Tasks.Count() > Dimension)
            //    throw new ArgumentException("The matrix has to be squared.");

            ValidAgents = Agents.Count();
            ValidTasks  = Tasks.Count();

            Dimension = 2 * Math.Max(ValidTasks, ValidAgents);

            initMatrix();
            initTags();

            int row = 0, column = 0;

            foreach (var Agent in Agents)
            {
                foreach (var Task in Tasks)
                {
                    matrix[row][column] = getDistance(Agent, Task);
                    column++;
                }
                column = 0;
                row++;
            }
        }