Code Monkey home page Code Monkey logo

pddl.jl's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pddl.jl's Issues

Compiler returns no solution

Hello there.
I have been using PDDL.jl together with the SymbolicPlanners with great results, but, for some reason, I can't get to use the compiler to execute and solve problems with my domain. So I have been wondering if there is any limitation that might be causing the issue.

I do not get an error while running it, but I get no result despite running it on problems that return me a solution under a second or less. This gist has an example of a problem that returns a solution at around 12 seconds, but that doesn't seem to return anything, as far as I have observed, using the compiler.

Generating all grounded actions for a problem instance

Hello! Is there any way of creating all possible grounded actions for a problem instance? I was able to generate all grounded actions for a state but not all possible actions. It would be really handy for my ASnet implementation in Julia.

Thank you for this great package!

Towers of Hanoi Issue

Hello, I'm trying to solve the towers of hanoi using PDDL is works fine with 3 and 4 disks count. However, when I increase the disks count it fails and generates a nothing plan.

I'm attaching both the problem domain and instance.

Can you help me fix this issue ?

Archive.zip

forall when PDDL failure

domain = @pddl("
(define (domain switchesworld3)
(:requirements :typing :negative-preconditions :conditional-effects)

(:types switch room)

(:predicates
(switch_is_on ?switch - switch)
(at_switch_room ?switch - switch ?room -room) ; The switch is in the room.
)

(:action turn-on-in-a-room
:parameters (?switch - switch ?room - room)
:precondition (and
(at_switch_room ?switch ?room)
(not (switch_is_on ?switch))
)
:effect (forall (?switch1 - switch)
(when (at_switch_room ?switch1 ?room)
(and
(switch_is_on ?switch1)
)
)
)
)
)")

LoadError: MethodError: Cannot convert an object of type Symbol to an object of type Var

Closest candidates are:
convert(::Type{T}, ::T) where T
@ Base Base.jl:64
Var(::Union{UInt64, Symbol})
@ Julog ~/.julia/packages/Julog/pgKEW/src/structs.jl:24
Var(::Any)
@ Julog ~/.julia/packages/Julog/pgKEW/src/structs.jl:24

in expression starting at In[59]:1

Stacktrace:
[1] push!(a::Vector{Var}, item::Symbol)
@ Base ./array.jl:1060
[2] parse_typed_list(expr::Vector{Any}, T::Type, default::Symbol, parse_fn::typeof(identity))
@ PDDL.Parser ~/.julia/packages/PDDL/bALZ3/src/parser/formulas.jl:75
[3] parse_typed_vars (repeats 2 times)
@ ~/.julia/packages/PDDL/bALZ3/src/parser/formulas.jl:88 [inlined]
[4] parse_declaration(expr::Vector{Any})
@ PDDL.Parser ~/.julia/packages/PDDL/bALZ3/src/parser/formulas.jl:50
[5] parse_typed_list(expr::Vector{Any}, T::Type, default::Symbol, parse_fn::typeof(PDDL.Parser.parse_declaration))
@ PDDL.Parser ~/.julia/packages/PDDL/bALZ3/src/parser/formulas.jl:75
[6] parse_typed_declarations
@ ~/.julia/packages/PDDL/bALZ3/src/parser/formulas.jl:104 [inlined]
[7] parse_predicates(expr::Vector{Any})
@ PDDL.Parser ~/.julia/packages/PDDL/bALZ3/src/parser/domain.jl:93
[8] parse_header_field
@ ~/.julia/packages/PDDL/bALZ3/src/parser/parser.jl:74 [inlined]
[9] macro expansion
@ ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:0 [inlined]
[10] _valswitch(::Val{(:requirements, :types, :constants, :predicates, :functions, :domain, :objects, :init, :goal, :metric, :constraints)}, ::Val{2}, ::typeof(PDDL.Parser.parse_header_field), ::PDDL.Parser.var"#72#default_f#4"{Symbol}, ::Val{:domain}, ::Symbol, ::Vector{Any})
@ ValSplit ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:95
[11] parse_header_field(desc::Val{:domain}, fieldname::Symbol, expr::Vector{Any})
@ PDDL.Parser ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:145
[12] parse_description(desc::Symbol, expr::Vector{Any})
@ PDDL.Parser ~/.julia/packages/PDDL/bALZ3/src/parser/descriptions.jl:18
[13] parse_domain(expr::Vector{Any}, domain_type::Type)
@ PDDL.Parser ~/.julia/packages/PDDL/bALZ3/src/parser/domain.jl:10
[14] parse_domain
@ ~/.julia/packages/PDDL/bALZ3/src/parser/domain.jl:6 [inlined]
[15] parse_top_level
@ ~/.julia/packages/PDDL/bALZ3/src/parser/parser.jl:41 [inlined]
[16] macro expansion
@ ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:0 [inlined]
[17] _valswitch
@ ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:95 [inlined]
[18] parse_top_level
@ ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:145 [inlined]
[19] parse_pddl(expr::Vector{Any})
@ PDDL.Parser ~/.julia/packages/PDDL/bALZ3/src/parser/parser.jl:145
[20] parse_pddl(str::String)
@ PDDL.Parser ~/.julia/packages/PDDL/bALZ3/src/parser/parser.jl:151
[21] var"@pddl"(source::LineNumberNode, module::Module, str::AbstractString)
@ PDDL.Parser ~/.julia/packages/PDDL/bALZ3/src/parser/parser.jl:160

By the way, the problem is:

problem = @pddl("
(define (problem switches_problem1)
(:domain switchesworld3)

(:objects a b c - switch living-room kitchen - room)

(:init
(not (switch_is_on a))
(not (switch_is_on b))
(not (switch_is_on c))
(at_switch_room a kitchen)
(at_switch_room b living-room)
(at_switch_room c living-room)
)

(:goal (and (switch_is_on b)))

)
")

A bug in the strips test domain

Hi, I just noticed an issue where "robby" is able to move to the location it is currently at. E.x. if (robbyat rooma), then the action (move rooma rooma) is legal. After executing that action, there is no robbyat fact, and so all actions become illegal.

Error when compiling states

Hi,

I am encountering error when compiling a problem and I would like to know, if this is something trivial to fix or a lack of some feature. Compiler is a bit opaque for me to fix this.

julia> domain = load_domain(domain_pddl)
julia> problem = load_problem(problem_file)
julia> c_domain, c_state = compiled(domain, problem)
ERROR: Unknown datatype: number
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] macro expansion
    @ ~/.julia/packages/PDDL/KzQK5/src/builtins.jl:33 [inlined]
  [3] (::PDDL.var"#224#default_f#112"{Symbol})()
    @ PDDL ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:143
  [4] macro expansion
    @ ./array.jl:0 [inlined]
  [5] _valswitch
    @ ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:95 [inlined]
  [6] datatype_def
    @ ~/.julia/packages/ValSplit/MMCz3/src/ValSplit.jl:145 [inlined]
  [7] generate_field_type(domain::GenericDomain, sig::PDDL.Signature{1})
    @ PDDL ~/.julia/packages/PDDL/KzQK5/src/compiler/state.jl:4
  [8] generate_state_type(domain::GenericDomain, state::GenericState, domain_type::Symbol)
    @ PDDL ~/.julia/packages/PDDL/KzQK5/src/compiler/state.jl:47
  [9] compiled(domain::GenericDomain, state::GenericState)
    @ PDDL ~/.julia/packages/PDDL/KzQK5/src/compiler/compiler.jl:42
 [10] compiled(domain::GenericDomain, problem::GenericProblem)
    @ PDDL ~/.julia/packages/PDDL/KzQK5/src/compiler/compiler.jl:66
 [11] top-level scope
    @ REPL[102]:1
 [12] top-level scope
    @ ~/.julia/packages/CUDA/BbliS/src/initialization.jl:52

The domain and the problem p01.pddl are from https://github.com/AI-Planning/classical-domains/tree/master/classical/agricola-sat18 . I am using latest PDDL 0.2.12.
Thanks for help in advance.

Tomas

Failed at parsing sokoban problems from

Hi,

I am absolute newbie and minimally exposed to planning (but I have good co-workers). I am interesting in representation of planning problems which would be "nice" to machine learning algorithms. I have tried to parse problems from this repository.
https://github.com/binleyyang/Sokoban
while domain description was parsed without an issue, I had troubles with parsing the problem. The first two has failed, I have not tested the others.

Thanks for looking at the problem.

Tomas

`Base.propertynames(::Domain)` is ambiguous

When asking the REPL to suggest the property names of a domain instance, I get the following error:

julia> dom.┌ Error: Error in the keymap
│   exception =
│    MethodError: propertynames(::Domain, ::Bool) is ambiguous. Candidates:
│      propertynames(x, private::Bool) in Base at reflection.jl:1581
│      propertynames(d::Domain, private) in PDDL at C:\Users\wmanning\.julia\packages\PDDL\eCv9B\src\structs.jl:74
│    Possible fix, define
│      propertynames(::Domain, ::Bool)
│    Stacktrace:
│      [1] complete_symbol(sym::String, ffunc::REPL.REPLCompletions.var"#34#37", context_module::Module)
│        @ REPL.REPLCompletions C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPLCompletions.jl:178
│      [2] completions(string::String, pos::Int64, context_module::Module)
│        @ REPL.REPLCompletions C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPLCompletions.jl:774
│      [3] completions
│        @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPLCompletions.jl:638 [inlined]       
│      [4] complete_line(c::REPL.REPLCompletionProvider, s::REPL.LineEdit.PromptState)
│        @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:439
│      [5] complete_line(s::REPL.LineEdit.PromptState, repeats::Int64)
│        @ REPL.LineEdit C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\LineEdit.jl:348
│      [6] complete_line(s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\LineEdit.jl:339
│      [7] edit_tab(s::REPL.LineEdit.MIState, jump_spaces::Bool, delete_trailing::Bool) (repeats 2 times)
│        @ REPL.LineEdit C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\LineEdit.jl:2118
│      [8] (::REPL.LineEdit.var"#109#162")(::REPL.LineEdit.MIState, ::Any, ::Vararg{Any, N} where N)
│        @ REPL.LineEdit C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\LineEdit.jl:2159
│      [9] #invokelatest#2
│        @ .\essentials.jl:708 [inlined]
│     [10] invokelatest
│        @ .\essentials.jl:706 [inlined]
│     [11] (::REPL.LineEdit.var"#22#23"{REPL.LineEdit.var"#109#162", String})(s::Any, p::Any)
│        @ REPL.LineEdit C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\LineEdit.jl:1414
│     [12] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\LineEdit.jl:2534
│     [13] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)    
│        @ REPL.LineEdit C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\LineEdit.jl:2436
│     [14] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
│        @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:1126
│     [15] (::REPL.var"#44#49"{REPL.LineEditREPL, REPL.REPLBackendRef})()
│        @ REPL .\task.jl:411
└ @ REPL.LineEdit C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\LineEdit.jl:2536

Presumably this can be fixed by making the signature's type more explicit: d::Domain, private::Bool=false

Confusion over the `_extras` field of `Domain`

We are experimenting with hierarchical PDDL planning, using an extension that adds "Methods" to the domain alongside actions. I noticed a field in the domain called _extras, which seems to hold parsed data that doesn't fit into the other known fields (actions, requirements, types, constants, etc.). This would be useful

However, when I parse a domain containing methods, I can't find them within the structure. Is this a bug with _extras, or am I misunderstanding it (and do I need to add custom parsing logic to handle methods)?

https://www.uni-ulm.de/fileadmin/website_uni_ulm/iui.inst.090/Publikationen/2020/Hoeller2020HDDL.pdf

Here is an example of the syntax for a method:

(:method my_method
    :parameters (?a - T1)
    :precondition (P1 ?a)
    :task (t_pursue_main_goal)
    :ordered-subtasks (and
        (action_1 ?a b c)
        (action_2 ?a)
    )
)

There are also new fields in the Problem as well, so I guess I have the same question for the Problem struct.

Action precondition `(not (= ?a ?b))` doesn't work

Here's a test that replicates the issue:

julia> using PDDL

julia> test_dom = pddl"(define (domain TM)
          (:requirements :adl :fluents :derived-predicates)
          (:types Location)
          (:predicates
             (player_at ?loc - Location)
           )
           (:action a_move
              :parameters (?from ?to - Location)
              :precondition (and
                  (not (= ?from ?to))
                  (player_at ?from)
               )
               :effect (and
                   (not (player_at ?from))
                   (player_at ?to)
               )
           )
       )"
[printout of domain]
julia> test_prob = pddl"(define (problem P_TM) (:domain TM)
           (:objects
               L1 L2 L3 - Location
           )
           (:init (player_at L1) )
           (:goal (and
               (player_at L3)
           ) )
       )"
[printout of problem]
julia> test_state = PDDL.initstate(test_dom, test_prob)
[printout of state]
julia> PDDL.available(test_dom, test_state)
3-element Vector{Term}:
 a_move(l1, l2)
 a_move(l1, l1)
 a_move(l1, l3)

The action a_move(l1, l1) should be illegal due to the precondition (not (= ?from ?to)), and this can be confirmed with available():

julia> PDDL.available(test_dom, test_state, test_dom.actions[:a_move], [ PDDL.Const(:l1), PDDL.Const(:l2) ])
true

julia> PDDL.available(tdom, test_state, test_dom.actions[:a_move], [ PDDL.Const(:l1), PDDL.Const(:l1) ])
false

Constraints unintuitive?

Thanks a lot for this nice package. I was trying to solve a constrained problem and found it a bit tricky to do so.

  • I could not include :constraints in the domain definition, only in the problem, is this expected?
  • Also the constraints did not appear automatically in the goal. I had to do
StateConstrainedGoal(
    MinStepsGoal(get_goal(problem)), 
    get_constraints(problem).args,
)

The .args part feels like I am using internals?
Am I doing this correctly or is there a better way?

Hierarchical Planning

Hello,

Thank you for creating and maintaining the package!

I was wondering if PDDL.jl supports Hierarchical Task Planning and if there are any developed examples that I can experiment with?

Thank you!

How to get grounded predicates and functions

I'm using SMT to solve the planning task. to do so I need to the groudned predicates and functions to encode them into a SMt formula but there is no clear way on how to obtain such informaion.

I have tried the following steps but it returns the lifted predicate/function:

domain = load_domain(joinpath("domain.pddl"));
task     = load_problem(joinpath("pfile1.pddl"));

grounded_problem = ground(domain, task);

for ele in grounded_problem.source.predicates
    println(ele)
end

I get a Pair{Symbol, Main.PDDL.Signature} which does not contain any grounded predicates.

I hope if you can help me with this.

Trouble running the execute function

Hello, I'm trying to test out your tool, I reckon you'd know how to get past this:

Thanks!

julia> import Pkg; Pkg.add("PDDL")
   Updating registry at `~/.julia/registries/General`
   Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Resolving package versions...
   Updating `~/.julia/environments/v1.4/Project.toml`
  [2c8894f9]   PDDL v0.1.3
   Updating `~/.julia/environments/v1.4/Manifest.toml`
  [2c8894f9]   PDDL v0.1.3

julia> import PDDL

julia> domain = PDDL.load_domain("/home/erwin/go/src/github.com/guilyx/go-pddl/data/domain.pddl")
PDDL.Domain(:flip, Dict{Symbol,Bool}(:typing => 1,Symbol("negative-preconditions") => 0,Symbol("quantified-preconditions") => 0,Symbol("disjunctive-preconditions") => 0,:strips => 1,Symbol("derived-predicates") => 0,Symbol("existential-preconditions") => 0,:equality => 0,Symbol("conditional-effects") => 0,Symbol("universal-preconditions") => 0), Dict(:row => [],:column => [],:object => [:row, :column]), Julog.Const[], Dict{Julog.Const,Symbol}(), Dict{Symbol,Julog.Term}(:white => white(R, C)), Dict(:white => [:row, :column]), Dict{Symbol,Julog.Term}(), Dict{Symbol,Array{Symbol,1}}(), Dict{Symbol,Any}(), Julog.Clause[], Dict{Symbol,PDDL.Action}(:flip_row => PDDL.Action(:flip_row, Julog.Var[R], [:row], true, forall(column(C), and(when(white(R, C), not(white(R, C))), when(not(white(R, C)), white(R, C))))),:flip_column => PDDL.Action(:flip_column, Julog.Var[C], [:column], true, forall(row(R), and(when(white(R, C), not(white(R, C))), when(not(white(R, C)), white(R, C)))))), PDDL.Event[], Dict{Symbol,Any}())

julia> problem = PDDL.load_problem("/home/erwin/go/src/github.com/guilyx/go-pddl/data/problem.pddl")
PDDL.Problem(Symbol("flip-problem"), :flip, Julog.Const[r1, r2, r3, c1, c2, c3], Dict{Julog.Const,Symbol}(r3 => :row,c2 => :column,c3 => :column,r1 => :row,r2 => :row,c1 => :column), Julog.Term[white(r1, c2), white(r2, c1), white(r2, c3), white(r3, c2)], forall(and(row(R), column(C)), white(R, C)), nothing)

julia> state = PDDL.initialize(problem)
PDDL.State(Set(Julog.Term[row(r1), column(c3), row(r3), row(r2), column(c2), column(c1)]), Set(Julog.Term[white(r2, c1), white(r1, c2), white(r3, c2), white(r2, c3)]), Dict{Symbol,Any}())

julia> state = PDDL.execute(pddl"(flip_column c1)", state, domain)
ERROR: LoadError: UndefVarError: @pddl_str not defined
in expression starting at REPL[7]:1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.