模式 #1 字段 #2 存在约束冲突,这使得该模式

发布于 2025-01-12 02:42:26 字数 707 浏览 0 评论 0原文

我想


(defrule practica-superada1
    (or
        (and
            (oav ?alumno p1 apto)
            (oav ?alumno p2 apto)
        )
        (and
            (oav ?alumno p1|p2 apto)
            (oav ?alumno trabajo ok)
        )

    )
    =>
    (assert (oav ?alumno practica superada))
)

这样制定这个规则:


(defrule practica-superada1
    (or
        (oav ?alumno p1&p2 apto)
        (and
            (oav ?alumno p1|p2 apto)
            (oav ?alumno trabajo ok)
        )

    )
    =>
    (assert (oav ?alumno practica superada))
)

第一种方式可以。但第二个却不是。我收到错误:

Pattern #1 field #2 有约束冲突,导致该模式

有人可以解释一下此错误的原因吗?

I would like to make this rule


(defrule practica-superada1
    (or
        (and
            (oav ?alumno p1 apto)
            (oav ?alumno p2 apto)
        )
        (and
            (oav ?alumno p1|p2 apto)
            (oav ?alumno trabajo ok)
        )

    )
    =>
    (assert (oav ?alumno practica superada))
)

as this way:


(defrule practica-superada1
    (or
        (oav ?alumno p1&p2 apto)
        (and
            (oav ?alumno p1|p2 apto)
            (oav ?alumno trabajo ok)
        )

    )
    =>
    (assert (oav ?alumno practica superada))
)

The first way it's OK. But the second it's not. I receive the error:

Pattern #1 field #2 has constraint conflicts which make the pattern

Could someone explain me the cause of this error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花之痕靓丽 2025-01-19 02:42:26

仅当事实中该位置的值同时为 p1 和 p2 时,字段约束 p1&p2 才会匹配。那不可能发生。您无法用单个模式替换每个需要匹配单独事实的两个模式。

鉴于它处理两种不同的情况,您的原始规则采用您可以编写的最简单的形式。您可以将事实条件元素减少到仅两个,但随后您必须包含一个复杂的测试条件元素:

(defrule practica-superada1
   (oav ?alumno ?v1 apto)
   (oav ?alumno ?v2 ?v3)
   (test (or (and (eq ?v1 p1)
                  (eq ?v2 p2)
                  (eq ?v3 apto))
             (and (or (eq ?v1 p1) (eq ?v1 p2))
                  (eq ?v2 trabajo)
                  (eq ?v3 ok))))
    =>
    (assert (oav ?alumno practica superada))) 

The field constraint p1&p2 will only be matched if the value for that position in the fact is both p1 and p2. That can't happen. You can't replace two patterns that each need to match a separate fact with a single pattern.

Your original rule is in the simplest form you can write it, given that it's handling two different cases. You could reduce the fact conditional elements to just two, but then you'd have to include a complicated test conditional element:

(defrule practica-superada1
   (oav ?alumno ?v1 apto)
   (oav ?alumno ?v2 ?v3)
   (test (or (and (eq ?v1 p1)
                  (eq ?v2 p2)
                  (eq ?v3 apto))
             (and (or (eq ?v1 p1) (eq ?v1 p2))
                  (eq ?v2 trabajo)
                  (eq ?v3 ok))))
    =>
    (assert (oav ?alumno practica superada))) 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文