Record Class GoalDecomposition

java.lang.Object
java.lang.Record
com.tnsai.coordination.planning.GoalDecomposition
Record Components:
parentGoal - the original goal that was decomposed
subGoals - the decomposed sub-goals with agent assignments

public record GoalDecomposition(String parentGoal, List<SubGoal> subGoals) extends Record
Result of decomposing a goal across a group of agents.

Contains the list of sub-goals with their assignments and provides utilities for execution ordering and phase grouping.

  • Constructor Details

    • GoalDecomposition

      public GoalDecomposition(String parentGoal, List<SubGoal> subGoals)
      Creates an instance of a GoalDecomposition record class.
      Parameters:
      parentGoal - the value for the parentGoal record component
      subGoals - the value for the subGoals record component
  • Method Details

    • executionOrder

      public List<SubGoal> executionOrder()
      Returns sub-goals ordered by phase (execution order). Sub-goals in the same phase can run in parallel.
    • byPhase

      public Map<Integer,List<SubGoal>> byPhase()
      Groups sub-goals by phase for batch execution.
      Returns:
      map from phase number to sub-goals in that phase
    • forAgent

      public List<SubGoal> forAgent(String agentId)
      Returns sub-goals assigned to a specific agent.
      Parameters:
      agentId - the agent ID
      Returns:
      sub-goals assigned to this agent
    • phaseCount

      public int phaseCount()
      Returns the total number of phases.
    • isEmpty

      public boolean isEmpty()
      Returns true if the decomposition is empty (no sub-goals).
    • size

      public int size()
      Returns the number of sub-goals.
    • empty

      public static GoalDecomposition empty(String goalName)
      Returns an empty decomposition for the given goal.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • parentGoal

      public String parentGoal()
      Returns the value of the parentGoal record component.
      Returns:
      the value of the parentGoal record component
    • subGoals

      public List<SubGoal> subGoals()
      Returns the value of the subGoals record component.
      Returns:
      the value of the subGoals record component