Package com.tnsai.spi

Interface CognitiveModel


public interface CognitiveModel
Abstraction for agent cognitive architectures.

This interface provides a unified API for different cognitive models including BDI (Belief-Desire-Intention), reactive agents, and hybrid models. Implementations can use rule-based reasoning, planning, or learning-based approaches.

Supported Models

  • BDI Model: Belief-Desire-Intention architecture for goal-oriented behavior
  • Reactive Model: Stimulus-response behavior without explicit goals
  • Hybrid Model: Combines reactive and deliberative components

Usage


 CognitiveModel model = CognitiveModel.bdi()
     .withBelief("User prefers concise answers")
     .withGoal("Help the user effectively")
     .build();

 // Add runtime belief
 model.addBelief(Belief.of("User is a developer"));

 // Query intentions
 List<Intention> intentions = model.getActiveIntentions();
 
See Also:
  • Method Details

    • getModelType

      String getModelType()
      Returns the type of cognitive model.
      Returns:
      model type (e.g., "BDI", "Reactive", "Hybrid")
    • addBelief

      void addBelief(CognitiveModel.Belief belief)
      Adds a belief to the cognitive model.
      Parameters:
      belief - the belief to add
    • removeBelief

      boolean removeBelief(String beliefContent)
      Removes a belief from the cognitive model.
      Parameters:
      beliefContent - the content of the belief to remove
      Returns:
      true if the belief was removed
    • getBeliefs

      Returns all current beliefs.
      Returns:
      list of beliefs
    • queryBeliefs

      List<CognitiveModel.Belief> queryBeliefs(String pattern)
      Queries beliefs matching a pattern.
      Parameters:
      pattern - the pattern to match
      Returns:
      matching beliefs
    • clearBeliefs

      void clearBeliefs()
      Clears all dynamic beliefs.
    • addGoal

      void addGoal(CognitiveModel.Goal goal)
      Adds a goal/desire to the cognitive model.
      Parameters:
      goal - the goal to add
    • removeGoal

      boolean removeGoal(String goalId)
      Removes a goal from the cognitive model.
      Parameters:
      goalId - the ID of the goal to remove
      Returns:
      true if the goal was removed
    • getGoals

      Returns all current goals.
      Returns:
      list of goals
    • getTopGoal

      Returns the highest priority active goal.
      Returns:
      optional containing the top goal, or empty if none
    • addIntention

      void addIntention(CognitiveModel.Intention intention)
      Adds an intention/plan to execute.
      Parameters:
      intention - the intention to add
    • completeIntention

      void completeIntention(String intentionId)
      Marks an intention as completed.
      Parameters:
      intentionId - the ID of the completed intention
    • getActiveIntentions

      List<CognitiveModel.Intention> getActiveIntentions()
      Returns all active intentions.
      Returns:
      list of intentions
    • getCurrentIntention

      Optional<CognitiveModel.Intention> getCurrentIntention()
      Returns the current intention being executed.
      Returns:
      optional containing current intention, or empty if none
    • reason

      Performs one reasoning cycle.

      In BDI models, this typically involves:

      1. Belief revision based on new perceptions
      2. Goal deliberation to select/update goals
      3. Intention selection to choose plans
      4. Plan execution
      Parameters:
      context - current context/perceptions
      Returns:
      action to execute, or empty if no action needed
    • reset

      void reset()
      Resets the cognitive model to its initial state.
    • snapshot

      Returns a snapshot of the current cognitive state.
      Returns:
      state snapshot
    • restore

      void restore(CognitiveModel.CognitiveState state)
      Restores the cognitive state from a snapshot.
      Parameters:
      state - the state to restore
    • bdi

      Returns a builder for BDI cognitive model.
      Returns:
      BDI model builder
    • reactive

      static CognitiveModel reactive()
      Returns a simple reactive cognitive model.
      Returns:
      reactive model