Documentation
¶
Overview ¶
Package graphplan implements the Graphplan algorithm for solving STRIPS planning problems. It constructs a Planning Graph and uses backward-chaining search with memoization to find shortest parallel plans.
Index ¶
- Variables
- type Action
- type Domain
- type Graph
- func (g *Graph) ActLevelSize(level int) int
- func (g *Graph) ActionsAreMutex(level int, actA, actB *Action) bool
- func (g *Graph) Extend()
- func (g *Graph) GoalsReachable(goals []Proposition, level int) bool
- func (g *Graph) HasProp(level int, prop Proposition) bool
- func (g *Graph) Leveled() bool
- func (g *Graph) NumPropLevels() int
- func (g *Graph) PropLevelSize(level int) int
- func (g *Graph) PropsAreMutex(level int, prop, other Proposition) bool
- func (g *Graph) Search(goals []Proposition) ([]PlanStep, bool)
- type Literal
- type Object
- type Operator
- type Parameter
- type PlanStep
- type Predicate
- type Problem
- type Proposition
- type Solver
- type SolverConfig
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoValidPlan indicates no valid plan exists for // the given problem. ErrNoValidPlan = errors.New("no valid plan exists") // ErrMaxLevelsExceeded indicates the solver hit the // configured level cap without finding a plan. ErrMaxLevelsExceeded = errors.New( "max levels exceeded", ) )
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct {
Operator string
Args []string
Preconditions []Proposition
AddEffects []Proposition
DeleteEffects []Proposition
}
Action is a grounded operator with all parameters bound to concrete objects.
func GroundActions ¶
GroundActions instantiates all operators with all type-compatible object bindings. It handles :equality constraints (neq) by filtering at grounding time.
type Domain ¶
type Domain struct {
Name string
Types []Type
Predicates []Predicate
Operators []Operator
Constants []Object
}
Domain holds the complete STRIPS domain definition.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is a directed, leveled planning graph alternating between proposition levels and action levels as described by Blum & Furst (1997).
func NewGraph ¶
NewGraph creates a planning graph with proposition level 0 containing the initial state. Negative propositions are seeded via the closed-world assumption for predicates used in negative preconditions.
func (*Graph) ActLevelSize ¶
ActLevelSize returns the number of actions at the given level.
func (*Graph) ActionsAreMutex ¶
ActionsAreMutex returns true if two actions are mutually exclusive at the given action level.
func (*Graph) Extend ¶
func (g *Graph) Extend()
Extend adds one action level and one proposition level to the graph.
func (*Graph) GoalsReachable ¶
func (g *Graph) GoalsReachable( goals []Proposition, level int, ) bool
GoalsReachable returns true if all goals exist at the given proposition level and no pair is mutex.
func (*Graph) HasProp ¶
func (g *Graph) HasProp( level int, prop Proposition, ) bool
HasProp returns true if proposition prop exists at the given proposition level.
func (*Graph) Leveled ¶
Leveled returns true if the last two proposition levels are identical (same props and same mutexes).
func (*Graph) NumPropLevels ¶
NumPropLevels returns the number of proposition levels.
func (*Graph) PropLevelSize ¶
PropLevelSize returns the number of propositions at the given level.
func (*Graph) PropsAreMutex ¶
func (g *Graph) PropsAreMutex( level int, prop, other Proposition, ) bool
PropsAreMutex returns true if two propositions are mutually exclusive at the given proposition level.
type Literal ¶
type Literal struct {
Predicate string
Args []string // variable names like "?r", "?p"
Negated bool
}
Literal is an ungrounded predicate reference used in operator preconditions and effects.
type Operator ¶
type Operator struct {
Name string
Parameters []Parameter
Preconditions []Literal
AddEffects []Literal
DeleteEffects []Literal
}
Operator defines an operator template with typed parameters, preconditions, and effects.
type PlanStep ¶
PlanStep is one time step in the output plan, containing a set of non-interfering parallel actions.
type Problem ¶
type Problem struct {
Name string
Domain *Domain
Objects []Object
InitialState []Proposition
Goals []Proposition
}
Problem defines a planning problem: a domain, objects, initial state, and goal propositions.
type Proposition ¶
Proposition is a grounded predicate — fully instantiated with concrete objects. When Negated is true, it represents the absence of the fact (closed-world assumption).
func GroundPredicates ¶ added in v0.2.0
func GroundPredicates( domain *Domain, objects []Object, predicateNames map[string]bool, ) []Proposition
GroundPredicates enumerates all type-compatible ground instances of the given predicates. It reuses buildTypeIndex and enumerateBindings to generate all valid argument combinations for each predicate.
func (Proposition) BaseKey ¶ added in v0.2.0
func (p Proposition) BaseKey() string
BaseKey returns the key without negation, useful for interference checks between positive and negative propositions.
func (Proposition) Key ¶
func (p Proposition) Key() string
Key returns a unique string key for map lookups. Negated propositions are prefixed with "NOT-".
func (Proposition) Negate ¶ added in v0.2.0
func (p Proposition) Negate() Proposition
Negate returns a copy with Negated flipped.
func (Proposition) String ¶
func (p Proposition) String() string
String returns the human-readable representation.
type Solver ¶
type Solver struct {
SolverConfig
}
Solver runs the Graphplan extend/search loop to find shortest parallel plans for STRIPS problems.
func NewSolver ¶
func NewSolver( cfg *SolverConfig, ) (*Solver, error)
NewSolver creates a solver. A nil config uses defaults.
type SolverConfig ¶
type SolverConfig struct {
// MaxLevels caps graph expansion. Nil means no limit.
MaxLevels *int `json:"max_levels,omitempty" yaml:"max_levels"`
}
SolverConfig controls solver behavior.
func (*SolverConfig) Validate ¶
func (c *SolverConfig) Validate() error
Validate checks that config values are semantically valid.