[ACT-R-users] Question regarding add-dm via RPC

db30 at andrew.cmu.edu db30 at andrew.cmu.edu
Fri Sep 11 14:07:18 EDT 2020



--On Friday, September 11, 2020 9:17 AM -0400 Arun Krishna 
<arunbkris at gmail.com> wrote:

>
>
> Hi,
>
> Good day.
>
> I am facing some issues for adding a new chunk via RPC for my ACT-R model.
>
> I recreated the same using the count model in ACT-R\tutorial\unit1 for
> problem description purposes.
>
> I am trying to create a new chunk to the count model.
>
> Through command it works (add-dm (test isa count-order first 1 second 2))
>
> But when I use my java code (given below)
>
> static void addChunk() {
>   JSONArray jsonArray = new JSONArray();
>   jsonArray.put("{\"method\":\"evaluate\",");
>   jsonArray.put("\"params\":");
>
> //jsonArray.put("[\"add-dm\",\"count\",\"new\",\"isa\",\"count-order\",\"firs
> t\",\"5\",\"second\",\"6\"],");
>
> jsonArray.put("[\"define-chunks\",\"count\",\"new4\",\"isa\",\"count-order\",
> \"first\",5,\"second\",6],");
>   jsonArray.put("\"id\":1}");
>   print(jsonArray.getString(0)
>       + jsonArray.getString(1)
>       + jsonArray.getString(2)
>       + jsonArray.getString(3));
> }
>
> I am getting an error in command window
>
> (add-dm (test isa count-order first 1 second 2))
>
>#| Warning: Invalid chunk definition: (TEST ISA COUNT-ORDER FIRST 1 SECOND 2)
>#| names a chunk which already exists. |#
>
> NIL
>
> 1 >
>
> I am able to use other commands successfully using my java code for example
> the goal-focus command as given below.
> static void setGoalFocus() {
>   JSONArray jsonArray = new JSONArray();
>   jsonArray.put("{\"method\":\"evaluate\",");
>   jsonArray.put("\"params\":");
>   jsonArray.put("[\"goal-focus\",\"count\",\"first-goal\"],");
>   jsonArray.put("\"id\":1}");
>   print(jsonArray.getString(0)
>       + jsonArray.getString(1) + jsonArray.getString(2)
>       + jsonArray.getString(3));
> }
>
>
> Could you please tell me what I am  doing wrong in addChunk() function above?
>
> Thanks & Regards,
>
> Arun




The warning you show suggests you have called this twice:

(add-dm (test isa count-order first 1 second 2))

and not an issue with the remote command that you've shown
being sent since that warning is showing the contents of that
chunk description and not the one that you are sending.

As for the command you're sending, the description of a
chunk for add-dm or define-chunks needs to be in a list.
Thus, you'll need to wrap square brackets [...] around the
components of the chunk description in the parameters that
you send.  I'm not a Java programmer, but I think that
would look like this in your function:

 
jsonArray.put("[\"define-chunks\",\"count\",[\"new4\",\"isa\",\"count-order\",\"first\",5,\"second\",6]],");

Hope that helps,
Dan






More information about the ACT-R-users mailing list