Class AgentsTasks
java.lang.Object
topics.greedy.AgentsTasks
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 -
Method Summary
Modifier and TypeMethodDescriptionintgetCost1(int[] sol) Gets the solution for Greedy1intgetCost2(int[] sol) Gets the solution for Greedy2voidgreedy1(int[] sol) We assign each agent to the less expensive task This method has a quadratic complexity O(n^2)voidgreedy2(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)
-
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
-