Class AgentsTasks

java.lang.Object
topics.greedy.AgentsTasks

public class AgentsTasks extends Object
GREEDY ALGORITHM PROBLEM: THE PROBLEM OF ASSIGNING N TASK TO AGENTS This program can solve the problem using two greedy algorithms and test operation. It has not an optimal solution in some cases
Author:
vicegd
  • Constructor Summary

    Constructors
    Constructor
    Description
    AgentsTasks(int[][] c)
    Constructor for AgentsTasks objects
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    getCost1(int[] sol)
    Gets the solution for Greedy1
    int
    getCost2(int[] sol)
    Gets the solution for Greedy2
    void
    greedy1(int[] sol)
    We assign each agent to the less expensive task This method has a quadratic complexity O(n^2)
    void
    greedy2(int[] sol)
    We assign each task to the agent for which the it is less expensive This method has a quadratic complexity O(n^2)

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AgentsTasks

      public AgentsTasks(int[][] c)
      Constructor for AgentsTasks objects
      Parameters:
      c - Matrix of costs
  • Method Details

    • greedy1

      public void greedy1(int[] sol)
      We assign each agent to the less expensive task This method has a quadratic complexity O(n^2)
      Parameters:
      sol - To save the solution
    • greedy2

      public void greedy2(int[] sol)
      We assign each task to the agent for which the it is less expensive This method has a quadratic complexity O(n^2)
      Parameters:
      sol - To save the solution
    • getCost1

      public int getCost1(int[] sol)
      Gets the solution for Greedy1
      Parameters:
      sol - Array with the solution
      Returns:
      The total cost with Greedy1
    • getCost2

      public int getCost2(int[] sol)
      Gets the solution for Greedy2
      Parameters:
      sol - Array with the solution
      Returns:
      The total cost with Greedy2