首页 > 解决方案 > ACT-R 块中的变量输入输出

问题描述

给定 Unit1 标准 ACTR 纪录片代码:

(add-dm
(b ISA count-order first 1 second 2)
(c ISA count-order first 2 second 3)
(d ISA count-order first 3 second 4)
(e ISA count-order first 4 second 5)
(firstgoal ISA count-from start 0 end 5)
)
  1. 问题:查看 den firstgoal 块中的 0 和 5。是否可以声明更通用的,例如:

    (firstgoal ISA count-from start *global_start_var* end *global_end_var*)
    

  1. 是否可以在块中输出特定值?说到计数器,我想要一个运行模型的代码,然后评估计数器模型计数到的数字

示例 lisp 代码在 lisp 模型中如何具有适当的值渗透

    ;; load the model
    (load "counter.lisp")

    ;; set the start and end variables
    (setvar *global_start_var* 0)
    (setvar *global_start_end* 9)

    ;; run the model
    (run 9999)

    ;; safe the result of the counter in the (local) variable result using the function get_val
    (result (get_val))

标签: lispcommon-lisptrace

解决方案


要使用 Lisp 变量设置块内容,您可以使用 add-dm-fct 函数,该函数采用块描述列表的列表:

(add-dm-fct (list (list 'firstgoal 'ISA 'count-from 'start *global_start_var* 'end *global_end_var*)))

要从块的槽中获取当前值,您需要使用宏块槽值或函数块槽值-fct。它们都采用两个参数:块的名称和槽的名称,然后返回该块中该槽的值。使用您在那里显示的块,这是:

(chunk-slot-value b first)

将返回 1。


推荐阅读