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:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordRepresents an action to be executed.static classBuilder for BDI cognitive model.static final recordRepresents a belief in the cognitive model.static final recordSnapshot of cognitive state for persistence.static final recordRepresents a goal/desire in the cognitive model.static enumstatic final recordRepresents an intention/plan in the cognitive model.static enum -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBelief(CognitiveModel.Belief belief) Adds a belief to the cognitive model.voidaddGoal(CognitiveModel.Goal goal) Adds a goal/desire to the cognitive model.voidaddIntention(CognitiveModel.Intention intention) Adds an intention/plan to execute.bdi()Returns a builder for BDI cognitive model.voidClears all dynamic beliefs.voidcompleteIntention(String intentionId) Marks an intention as completed.Returns all active intentions.Returns all current beliefs.Returns the current intention being executed.getGoals()Returns all current goals.Returns the type of cognitive model.Returns the highest priority active goal.queryBeliefs(String pattern) Queries beliefs matching a pattern.static CognitiveModelreactive()Returns a simple reactive cognitive model.Performs one reasoning cycle.booleanremoveBelief(String beliefContent) Removes a belief from the cognitive model.booleanremoveGoal(String goalId) Removes a goal from the cognitive model.voidreset()Resets the cognitive model to its initial state.voidRestores the cognitive state from a snapshot.snapshot()Returns a snapshot of the current cognitive state.
-
Method Details
-
getModelType
String getModelType()Returns the type of cognitive model.- Returns:
- model type (e.g., "BDI", "Reactive", "Hybrid")
-
addBelief
Adds a belief to the cognitive model.- Parameters:
belief- the belief to add
-
removeBelief
Removes a belief from the cognitive model.- Parameters:
beliefContent- the content of the belief to remove- Returns:
- true if the belief was removed
-
getBeliefs
List<CognitiveModel.Belief> getBeliefs()Returns all current beliefs.- Returns:
- list of beliefs
-
queryBeliefs
Queries beliefs matching a pattern.- Parameters:
pattern- the pattern to match- Returns:
- matching beliefs
-
clearBeliefs
void clearBeliefs()Clears all dynamic beliefs. -
addGoal
Adds a goal/desire to the cognitive model.- Parameters:
goal- the goal to add
-
removeGoal
Removes a goal from the cognitive model.- Parameters:
goalId- the ID of the goal to remove- Returns:
- true if the goal was removed
-
getGoals
List<CognitiveModel.Goal> getGoals()Returns all current goals.- Returns:
- list of goals
-
getTopGoal
Optional<CognitiveModel.Goal> getTopGoal()Returns the highest priority active goal.- Returns:
- optional containing the top goal, or empty if none
-
addIntention
Adds an intention/plan to execute.- Parameters:
intention- the intention to add
-
completeIntention
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:
- Belief revision based on new perceptions
- Goal deliberation to select/update goals
- Intention selection to choose plans
- 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
CognitiveModel.CognitiveState snapshot()Returns a snapshot of the current cognitive state.- Returns:
- state snapshot
-
restore
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
Returns a simple reactive cognitive model.- Returns:
- reactive model
-