代码之家  ›  专栏  ›  技术社区  ›  Alper Aydın

为什么pddl发现解决方案不完整

  •  1
  • Alper Aydın  · 技术社区  · 7 年前

    下面是用pddl编写的河流穿越问题的一小部分。我试图在两个不同的工具(editor.planning.domains和stripsfiddle.herokuapp.com)中找到解决方案,但它们都给出了相同的结果。

    ;domain;
    (define (domain RiverCrossing)
    (:requirements :strips :typing)
    (:types 
        Farmer Fox - passengers
    )
    
    (:predicates 
         (onLeftBank ?p - passengers)
         (onRightBank ?p - passengers)
    )
    
    (:action crossRiverLR
        :parameters (?f - Farmer)
        :precondition (  and (onLeftBank ?f))
        :effect(  and (onRightBank ?f)  )
    )
    (:action crossRiverRL
        :parameters (?f - Farmer)
        :precondition (  and (onRightBank ?f))
        :effect(  and (onLeftBank ?f)  )
    )
    (:action crossRiverLRf
        :parameters ( ?fx - Fox ?f - Farmer)
        :precondition (  and (onLeftBank ?f) (onLeftBank ?fx) )
        :effect(  and (onRightBank ?fx) (onRightBank ?f) )
    )
    (:action crossRiverRLf
        :parameters (?f - Farmer ?fx - Fox)
        :precondition (  and (onRightBank ?f) (onRightBank ?fx) )
        :effect(  and (onLeftBank ?f) (onLeftBank ?fx)  )
    )
    
    )
    

    问题

    (define (problem RCP)
    (:domain RiverCrossing)
    (:objects
        farmer - Farmer
        fox - Fox
        )
    
    (:init
        (onRightBank farmer) (onLeftBank fox)
    )
    
    (:goal 
      (and
        (onLeftBank farmer) (onRightBank fox)
      )
    )
    )
    

    两个编译器都给出了相同的结果;Farmer不去左岸:

    Solution found in 2 steps!
    1. crossRiverRL farmer
    
    2. crossRiverLRf fox farmer
    

    有谁能帮我找出我遗漏的地方吗? 提前谢谢你,

    1 回复  |  直到 7 年前
        1
  •  1
  •   Alper Aydın    7 年前

    我发现问题并不是在设置下一个情况(OnRightBank)后否定前一个情况(OnLeftBank)。 下面是我应用于所有效果的样本校正;

    (:action crossRiverLR
        :parameters (?f - Farmer)
        :precondition (  and (onLeftBank ?f))
        :effect(  and (onRightBank ?f) 
                      (not (onLefttBank ?f)) ; **** adding this solved the problem. ****
         )
    )
    
    推荐文章