soartech / jsoar

Pure Java implementation of the Soar cognitive architecture.
http://soartech.github.com/jsoar/
BSD 3-Clause "New" or "Revised" License
53 stars 19 forks source link

Clearing the input-link of agent. #111

Closed harit7 closed 4 years ago

harit7 commented 6 years ago

There are ways to clear wme's from output-link. But I am not able to find a way to clear the input-link. There is an update() method. But it requires the knowledge of input structure in jsoar. Is there a better and cleaner way to do this.

marinier commented 6 years ago

Yes, you need to maintain knowledge of the structures you are creating on the input-link. Essentially, store the structures you are creating on the input-link in your java code and remove them when you want them to go away. To remove an InputWme, you would call it’s remove() method.

Bob

From: Harit Vishwakarma [mailto:notifications@github.com] Sent: Tuesday, November 7, 2017 2:26 AM To: soartech/jsoar jsoar@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [soartech/jsoar] Clearing the input-link of agent. (#111)

There are ways to clear wme's from output-link. But I am not able to find a way to clear the input-link. There is an update() method. But it requires the knowledge of input structure in jsoar. Is there a better and cleaner way to do this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/soartech/jsoar/issues/111, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAgp3Oc36Cu36Ei6Ct0aZ5eM0F-w5NkAks5s0AYNgaJpZM4QUXOl.

harit7 commented 6 years ago

Thanks for the reply. I am building the input using InputBuilder. I can get the wmes by agent.getInputOutput().getInputLink().getWmes(), but these are Wme objects, they don't have a remove method and Converting them to InputWme gives ClassCastException. How can I get InputWme Objects ?

marinier commented 6 years ago

The example here:

https://github.com/soartech/jsoar/wiki/JSoarInput#input-builder

shows that you can get an InputWme by name (builder.getWme(“name”)) and then you can call remove on it. That said, the input builder won’t know that the wme has been removed, so if you try to access it again via the builder, there could be problems. Probably the best practice here is to build entire structures, and then remove the entire structure at once (i.e., by removing it’s root). If you need to do more complex manipulations, you may be better off using a different input method.

Bob

From: Harit Vishwakarma [mailto:notifications@github.com] Sent: Wednesday, November 8, 2017 4:58 AM To: soartech/jsoar jsoar@noreply.github.com Cc: Bob Marinier bob.marinier@soartech.com; Comment comment@noreply.github.com Subject: Re: [soartech/jsoar] Clearing the input-link of agent. (#111)

Thanks for the reply. I am building the input using InputBuilder. I can get the wmes by agent.getInputOutput().getInputLink().getWmes(), but these are Wme objects, they don't have a remove method and Converting them to InputWme gives ClassCastException. How can I get InputWme Objects ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/soartech/jsoar/issues/111#issuecomment-342767922, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAgp3Mb9YGeQ6GGFnzPgJz73xLsybFDbks5s0Xs9gaJpZM4QUXOl.

harit7 commented 6 years ago

Thanks for the help. I am able to remove wme elements which are not repeated, for example If we have the following on the input link then I can remove ^city using the remove method. But Somehow ^person are not getting removed? What am I missing? I2 ^person abc ^person def ^person jkl ^city somecity

Also could you please explain how and when the inputWme gets removed exactly. Since This is happening in the java code(jsoar), hence one can do it at any time, in the worst case the soar agent might be reading the input at that time.

marinier commented 6 years ago

I’m not sure about multi-valued attributes like person. My guess is that you have to use a different input method to work with wmes like that.

Any changes made using a ThreadedAgent (which the builder method requires) are cached until the next input phase, so there’s no danger of making changes at the wrong time.

From: Harit Vishwakarma [mailto:notifications@github.com] Sent: Friday, November 10, 2017 5:03 AM To: soartech/jsoar jsoar@noreply.github.com Cc: Bob Marinier bob.marinier@soartech.com; Comment comment@noreply.github.com Subject: Re: [soartech/jsoar] Clearing the input-link of agent. (#111)

Thanks for the help. I am able to remove wme elements which are not repeated, for example If we have the following on the input link then I can remove ^city using the remove method. But Somehow ^person are not getting removed? What am I missing? I2 ^person abc ^person def ^person jkl ^city somecity

Also could you please explain how and when the inputWme gets removed exactly. Since This is happening in the java code(jsoar), hence one can do it at any time, in the worst case the soar agent might be reading the input at that time.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/soartech/jsoar/issues/111#issuecomment-343430715, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAgp3FV9uvu9kKInNTnI-_Vv-um1mwRhks5s1B9igaJpZM4QUXOl.