Class AgentsTasks
java.lang.Object
topics.backtracking.agents.AgentsTasks
Agent-Task Assignment
Evaluates an N x N matrix of deployment costs to assign N tasks to N unique agents.
Unlike Greedy approaches, this Backtracking algorithm systematically explores
every single valid permutation of assignments to guarantee the absolute
global minimum cost.
Complexity
- Time Complexity: O(N!) - Explores all factorial permutations (Pure Force).
- Space Complexity: O(N) - Bounded by the recursion call stack depth.
- Author:
- vicegd
-
Constructor Summary
ConstructorsConstructorDescriptionAgentsTasks(int[][] costs) Constructs the assignment engine performing a defensive copy of the cost matrix. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the optimal cost calculated by the solve() method.int[]solve()Triggers the backtracking exploration to find the optimal assignment.
-
Constructor Details
-
AgentsTasks
public AgentsTasks(int[][] costs) Constructs the assignment engine performing a defensive copy of the cost matrix.- Parameters:
costs- Square matrix of dimensions N x N mapping assignment costs.
-
-
Method Details
-
solve
public int[] solve()Triggers the backtracking exploration to find the optimal assignment.- Returns:
- Array where index is the Agent and value is the assigned Task.
-
getOptimalCost
public int getOptimalCost()Returns the optimal cost calculated by the solve() method.
-