Class AgentsTasks

java.lang.Object
topics.backtracking.agents.AgentsTasks

public class AgentsTasks extends Object

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

    Constructors
    Constructor
    Description
    AgentsTasks(int[][] costs)
    Constructs the assignment engine performing a defensive copy of the cost matrix.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the optimal cost calculated by the solve() method.
    int[]
    Triggers the backtracking exploration to find the optimal assignment.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.