task

package
v0.0.0-...-b76af60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConditionSetToIntSlice

func ConditionSetToIntSlice(cs ConditionSet) []int

func EffectsToIntSlice

func EffectsToIntSlice(cs []Effect) []int

Types

type Action

type Action struct {
	ID            int
	PDDLAction    *pddl.Action
	Args          []*pddl.Object
	Owner         int
	Cost          int
	Preconditions []Condition
	Effects       []Effect
	Marked        bool // TODO: needed?
	Private       bool
	// contains filtered or unexported fields
}

Action represents a grounded PDDL action

func (*Action) AdjustedCost

func (o *Action) AdjustedCost(t CostType) int

AdjustedCost returns the action cost depending on the costType used.

func (*Action) DependsOn

func (o *Action) DependsOn(n *Action) bool

DependsOn determines if action o's preconditions and action n's effects have common variables.

func (*Action) IsPrivate

func (o *Action) IsPrivate() bool

func (*Action) IsPublic

func (o *Action) IsPublic() bool

func (*Action) Name

func (o *Action) Name() string

Name returns the name of the actions underlying (pddl) action

func (*Action) Pre

func (o *Action) Pre() []Condition

Pre returns the actions precondition (without prevail conditions)

func (*Action) Prev

func (o *Action) Prev() []Condition

Pre returns the actions prevail conditions

func (*Action) Projection

func (o *Action) Projection(vars []*Variable) *Action

Projection returns the action projection keeping only variables from vars

func (*Action) String

func (o *Action) String() string

String returns a string representation of the action

type ActionList

type ActionList []*Action

ActionList is an array of action objects, that supports some filtering methods and implements sort.Interface

func (ActionList) Copy

func (ls ActionList) Copy() ActionList

Copy creates a copy of an ActionList

func (ActionList) Len

func (ls ActionList) Len() int

ActionList implements sort.Interface

func (ActionList) Less

func (ls ActionList) Less(i, j int) bool

Less returns true iff action at index i comes in lexicographic order before action at index j. TODO: fix slow down due to recomputation of o.String() method

func (ActionList) Projection

func (ls ActionList) Projection(vars []*Variable) ActionList

Projection returns an ActionList containing all actions projections

func (ActionList) Satisfacted

func (ls ActionList) Satisfacted(cs []*Condition) (app, unapp ActionList)

Satisfacted returns two ActionLists. The first contains all actions of which all preconditions exist in the condition set cs, the second contains those actions where this is not the case.

func (ActionList) String

func (ls ActionList) String() string

String returns a string representation of an ActionList

func (ActionList) Swap

func (ls ActionList) Swap(i, j int)

func (ActionList) WithCondition

func (ls ActionList) WithCondition(c Condition) (res ActionList, rest ActionList)

WithCondition returns all actions in ActionList that contain condition c in their precondition and those who don't as two separate lists.

type ActionMap

type ActionMap map[int]ActionList

ActionMap contains each agents list of actions (keys are agentIDs)

func (ActionMap) Actions

func (aom ActionMap) Actions() ActionList

func (ActionMap) Len

func (aom ActionMap) Len() int

type Condition

type Condition VariableValuePair

Condition is a (variable,value) pair used in action preconditions

type ConditionSet

type ConditionSet []Condition

ConditionSet is a list of Conditions with set-like behaviour

func CreateConditionSet

func CreateConditionSet(a []int) ConditionSet

func (ConditionSet) Add

func (cs ConditionSet) Add(c Condition) (ConditionSet, bool)

Add adds a condition to ConditionSet cs if it is not already contained in cs and returns the resulting set

func (ConditionSet) Consistent

func (cs ConditionSet) Consistent() bool

Consistent returns true iff no two conditions refer to the same variable

func (ConditionSet) Equals

func (cs ConditionSet) Equals(other ConditionSet) bool

Equal returns true iff two conditionsets are structurally equal

func (ConditionSet) Except

func (cs ConditionSet) Except(vs ...int) ConditionSet

func (ConditionSet) Intersection

func (cs ConditionSet) Intersection(other ConditionSet) ConditionSet

Intersection returns the intersection of two ConditionSets

func (ConditionSet) Ints

func (cs ConditionSet) Ints() []int

func (ConditionSet) Ints32

func (cs ConditionSet) Ints32() []int32

func (ConditionSet) IsSorted

func (cs ConditionSet) IsSorted() bool

func (ConditionSet) Len

func (q ConditionSet) Len() int

Implement sort.Interface

func (ConditionSet) Less

func (q ConditionSet) Less(i, j int) bool

func (ConditionSet) PrivateConditions

func (cs ConditionSet) PrivateConditions(t *Task) ConditionSet

TODO: these methods are obsolete due to Project-method above

func (ConditionSet) Projection

func (cs ConditionSet) Projection(vars []*Variable) ConditionSet

Projection returns the ConditionSet that only contains variables from vars

func (ConditionSet) PublicConditions

func (cs ConditionSet) PublicConditions(t *Task) ConditionSet

func (ConditionSet) SubsetOf

func (cs ConditionSet) SubsetOf(other ConditionSet) bool

SubsetOf checks whether all conditions of a ConditionSet are contained in another ConditionSet TODO: rename Subsumes (referring to partial state subsumption in sas+) Complexity: O(n), where n = max{len(other), len(cs)}

func (ConditionSet) Swap

func (q ConditionSet) Swap(i, j int)

type CostType

type CostType byte // TODO: rename to ActionCostType

CostType specifies actions cost type (e.g. Normal vs Unit)

const (
	// NormalCost is the actions cost from its PDDL definition
	NormalCost CostType = iota
	// UnitCost is one for all actions
	UnitCost
	// Regular action cost, but if an action costs less than one it gets cost 1
	NormalMinOne
)

type Effect

type Effect VariableValuePair

Effect is a (variable,value) pair used in action effects TODO: when conditional effects are implemented, Effect should become an interface and the concrete types should be named atomicEffect and conditionalEffect, both implementing the Effect interface

func CreateEffects

func CreateEffects(a []int) []Effect

type MutexGroup

type MutexGroup []*VariableValuePair

MutexGroup is a list of Variable-Value Pairs

func (MutexGroup) String

func (mg MutexGroup) String() string

type Task

type Task struct {
	AgentID     int
	Vars        []*Variable
	Init        state.State
	Goal        ConditionSet
	Actions     ActionMap
	ActionsByID map[int]*Action
	MutexGroups []MutexGroup // [Variable.ID]MutexGroup
	// contains filtered or unexported fields
}

Task contains all the information of a planning task.

func NewTaskFromFile

func NewTaskFromFile(f string) (*Task, error)

NewTaskFromFile reads a problem file and returns the corresponding planning Task if the file format (e.g. .json) is supported

func NewTaskFromJSON

func NewTaskFromJSON(data []byte) *Task

NewTaskFromJSON converts a byte-slice of the supported json format into the corresponding planning Task representation

func (*Task) AddAction

func (t *Task) AddAction(agentID int, o *Action)

func (*Task) GetAction

func (t *Task) GetAction(actionID int) *Action

func (*Task) GetActions

func (t *Task) GetActions() ActionList

func (*Task) GetPrivateVarIDs

func (t *Task) GetPrivateVarIDs() []int

GetPrivateVarIDs returns the list of IDs of private variables

func (*Task) GetVarIDsF

func (t *Task) GetVarIDsF(p func(*Variable) bool) []int

GetVarIDsF returns the list of IDs of variables for which p returns true

func (*Task) GetVarsF

func (t *Task) GetVarsF(p func(*Variable) bool) []*Variable

GetVarsF returns the list of variables for which p returns true

func (*Task) PrintState

func (t *Task) PrintState(s VariableAssignment)

PrintState prints state s

func (*Task) PrivateVars

func (t *Task) PrivateVars() []*Variable

PrivateVars returns the list of variables that are private

func (*Task) PublicVars

func (t *Task) PublicVars() []*Variable

PublicVars returns the list of variables that are public

func (*Task) SetAgentActions

func (t *Task) SetAgentActions(agentID int, os ActionList)

func (*Task) ShallowCopy

func (t *Task) ShallowCopy() *Task

func (*Task) String

func (t *Task) String() string

func (*Task) VariableRanges

func (t *Task) VariableRanges() []int

VariableRanges returns the domainSize/range of each variable in a vector. Index corresponds to variable.ID

func (*Task) Variables

func (t *Task) Variables() []*Variable

type Variable

type Variable struct {
	ID        int
	Name      string
	DomRange  int32
	FactName  []string
	IsPrivate bool
}

Variable represents a multi-valued state variable of a planning task

type VariableAssignment

type VariableAssignment []int

VariableAssignment is a value assignment over all variables. The index corresponds to the variable ID, the value is the assigned value.

type VariableValuePair

type VariableValuePair struct {
	Variable int
	Value    int
}

VariableValuePair contains a variable ID (int) and an intended value (byte)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL