Package com.tnsai.planning
Interface Consideration
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A consideration that contributes to an action's utility score.
Considerations are building blocks for utility-based action selection. Each consideration evaluates a specific aspect of the current state and returns a score that influences action selection.
Usage
// Built-in considerations
Consideration costConsideration = Consideration.cost();
Consideration valueConsideration = Consideration.value();
// Custom consideration
Consideration urgencyConsideration = (action, state) -> {
Integer priority = (Integer) state.get("taskPriority");
return priority != null ? priority / 10.0f : 0.5f;
};
Response Curves
Considerations typically return normalized scores [0, 1] that can be shaped using response curves:
- Linear: f(x) = x
- Quadratic: f(x) = x²
- Inverse: f(x) = 1 - x
- Sigmoid: f(x) = 1 / (1 + e^(-k*(x-0.5)))
- Author:
- TnsAI Team
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Considerationcombine(Consideration... considerations) Combines multiple considerations with equal weights.static Considerationcost()Creates a cost consideration (lower cost = higher score).static Considerationcost(float weight) Creates a weighted cost consideration.floatevaluate(PlanningAction action, Map<String, Object> state) Evaluates this consideration for the given action and state.default StringgetName()Gets a descriptive name for this consideration.default floatGets the weight of this consideration.static ConsiderationCreates a tag-based consideration.static ConsiderationCreates a precondition satisfaction consideration.static Considerationutility()Creates a utility consideration (value - cost).static Considerationutility(float weight) Creates a weighted utility consideration.static Considerationvalue()Creates a value consideration (higher value = higher score).static Considerationvalue(float weight) Creates a weighted value consideration.
-
Method Details
-
evaluate
Evaluates this consideration for the given action and state.- Parameters:
action- the action being evaluatedstate- current world state- Returns:
- score contribution (typically 0.0 to 1.0, but can be unbounded)
-
getWeight
default float getWeight()Gets the weight of this consideration.Default weight is 1.0.
- Returns:
- weight multiplier
-
getName
Gets a descriptive name for this consideration.- Returns:
- consideration name
-
cost
Creates a cost consideration (lower cost = higher score).- Returns:
- cost consideration
-
cost
Creates a weighted cost consideration.- Parameters:
weight- consideration weight- Returns:
- cost consideration
-
value
Creates a value consideration (higher value = higher score).- Returns:
- value consideration
-
value
Creates a weighted value consideration.- Parameters:
weight- consideration weight- Returns:
- value consideration
-
utility
Creates a utility consideration (value - cost).- Returns:
- utility consideration
-
utility
Creates a weighted utility consideration.- Parameters:
weight- consideration weight- Returns:
- utility consideration
-
preconditionSatisfied
Creates a precondition satisfaction consideration.Returns 1.0 if precondition is satisfied, 0.0 otherwise.
- Returns:
- precondition consideration
-
hasTag
Creates a tag-based consideration.Returns 1.0 if action has the specified tag, 0.0 otherwise.
- Parameters:
tag- required tag- Returns:
- tag consideration
-
combine
Combines multiple considerations with equal weights.- Parameters:
considerations- considerations to combine- Returns:
- combined consideration
-