Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
help with cooperating agents (Read 4738 times)
Steve Scott
Full Member
*
Offline



Posts: 169

help with cooperating agents
Aug 11th, 2014, 6:32pm
 
I'm working on a TBX that will have about 100 agents.  I'm trying to follow Mark B's advice from the Tinderbox Way (p.133) by building a cooperating agent.  

I have a working agent with the following code:

Agent Name: ClassA Resources
Query: $Prototype=="pResource"

I'm trying to get an agent to search within this agent.  I'm looking for notes that are in Unit 1.  I have an Attribute on each of the resources called Unit.


Agent Name:  Resources for Unit 1
Attribute of Agent: Unit=1
Query: (inside(ClassA Resources) & $UnitNum=$Unit1(agent)

Does this seem like it should work or am I missing something?

Thanks,
Steve

Back to top
 
 
  IP Logged
Steve Scott
Full Member
*
Offline



Posts: 169

Re: help with cooperating agents
Reply #1 - Aug 11th, 2014, 6:55pm
 
If it is easier to follow along, I made a simple TBX found here:https://dl.dropboxusercontent.com/u/916107/web_forum/agent%20not%20working.tbx.z...

The first agent is working, but the cooperative agents aren't. . .

thanks,
Steve
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: help with cooperating agents
Reply #2 - Aug 12th, 2014, 3:27am
 
Quote:
Query: (inside(ClassA Resources) & $UnitNum=$Unit1(agent)


I see two errors here (in red above). The first is the unclosed opening parenthesis which isn't needed and likely causes Tinderbox confusion. The second is the $UnitNum test. The latter should be a test of equality '==' and not a value assignment '=', though legacy code support should deal with this particular error.

Looking at your demo file I see corrections in all 4 agents.

1. 'All People'. Do not use semi-colon terminators in query statements. TB should ignore these but it is better not to deliberately confuse the app if you don't need to! If a query has more than one term, join them via 'and' (&) or 'or' (|) joins. Parentheses may be used to influence the order of parsing - the query terms in the most deeply nested parentheses are resolved first.

2. 'Find the females'. This fails due to the unclosed parenthesis at the start of the query (same issue as the sample query in your first post).

3. 'all the females v2'. 2 errors. First, the unclosed parenthesis (as above). Second, the path '/All People' doesn't exist as the later agent is at '/Agents/All People'. Either use the full path inside("/Agents/All People") or just the name inside("All People").

4. 'all the females v3'. 2 errors. First, the unclosed parenthesis (as above). Second, the partial path 'Agents/All People' doesn't exist. Partial paths can't start at root (/) level. Anyway, partial paths are generally avoidable by either using the full path inside("/Agents/All People") or just the name inside("All People").
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Steve Scott
Full Member
*
Offline



Posts: 169

Re: help with cooperating agents
Reply #3 - Aug 12th, 2014, 11:26am
 
Mark,

Thank you so much.  I would have kept on multiply my mistake trying to find the answer.  I now see the original example that I was trying to copy was searching in two agents.  My cooperating agents work and I'm hoping that will prepare me for a faster tbx.  

Steve
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: help with cooperating agents
Reply #4 - Aug 12th, 2014, 11:49am
 
Could you tell us a bit more about your task and proposed design?

100 agents sounds like a lot!
Back to top
 
 
WWW   IP Logged
Steve Scott
Full Member
*
Offline



Posts: 169

Re: help with cooperating agents
Reply #5 - Aug 12th, 2014, 12:24pm
 
Thanks for asking Mark.  If I continue with the current path, there would be 250 agents . . . Last year Mark Anderson helped me with the project and it worked great.  This year, I was trying to branch out on my own to solve a problem which I will explain at the end of the post.

I am using 1 TBX to organize the lesson plans for the two different classes that I teach.  The basic structure of the outline is:

Code:
Course A
Class 1-1
	Due today for Class 1-1 (agent)
	Essential Questions for Class 1-1 (agent)
	Resources for Class 1-1 (agent)
	Agenda for Class 1-1
			 Sequence Item
				- Why are we doing this?  (picked up by Essential Question agent)
				- PDF that goes along with sequence (picked up by Resources for Class 1-1)
			 Sequence Item
			 Sequence Item
	  Homework assigned during Class 1-1
			  Read pages 1-20 due on Class 1-2  (picked up Due agent for class 1-2) 



This is repeated 45x for Course A and 45x for Course B.  I can definitely split Course A and Course B into two different TBX's once I settle on the code and the export.

The problem I was trying to solve:

If I moved a sequence into a different day I had to manually move resources, essential questions, etc into the new day.  

The agents within a class only need to run when I'm making changes to a particular class.  Perhaps I can turn the agents off on classes that have been planned?

Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: help with cooperating agents
Reply #6 - Aug 12th, 2014, 12:52pm
 
So the sequence checking needs to be scoped to a given class? As the agent work only needs to run whilst changing sequence days (if i understand correctly) then an agent could be created that will store the Course (A or B), the Class, the new day and old day (set with the agent off). Then a query looks for 'sequence'-related notes in he course, class and new/old dates. For instance $Course might be 'A' and $Class might be '1-1'. So part of the query might be:

$Class==$Class(agent) & $Course=$Course(agent) & ThingType=="sequence"

The 'thing type 'is actually probably a $Prototype value but I can't see the exact model. Anyway, I hope you get the general idea. Then the action can do whatever to date assignments. One agent, switched off when not used.

Or you could use the above query as one agent, with no action, to find the relevant notes and be able to check they are as expected without worrying about any action occurring. Then use a second agent to look inside() the first agent for it's target notes and carry out actions on those.

Anyway, I hope this offers ideas as to how to reduce hundreds of single task agents to just one or a few.


Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Steve Scott
Full Member
*
Offline



Posts: 169

Re: help with cooperating agents
Reply #7 - Aug 12th, 2014, 1:41pm
 
Thanks for this input.  I'm working through it right now, trying to understand.

Is it possible to create a stamp that toggles all agents in a container on or off?  If so, that would create a patch until my tinderbox understanding catches up.  I only work on 1 class or 1 week at a time.  When I am editing, I can turn the agents on.  When I'm done editing, I could turn the agents off.

Steve
Back to top
 
 
  IP Logged
Steve Scott
Full Member
*
Offline



Posts: 169

Re: help with cooperating agents
Reply #8 - Aug 12th, 2014, 2:25pm
 
I haven't been able to figure out how to turn off all agents in a container, but I have figured out how to turn agents off and on:

Stamp to turn an agent off:  AgentPriority="-1"
Stamp to turn an agent on:  AgentPriority="1"

Is it possible to turn all agents on or off that exist in a container?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: help with cooperating agents
Reply #9 - Aug 12th, 2014, 6:30pm
 
Assuming all agents live in container 'Agents' then agent might do:

Query:   inside("Agents")
Action:   $AgentPriority =  $MyNumber(agent)

Why not use $AgentPriority(agent) for the latter? Well if you set the $AgentPriority in the agent to -1 you turn the agent off! If you make $MyNumber a key attribute in the agent you can type in a number to set the on/off state you want.

Another approach is a stamp. In my starter.tbx used in v5 I had a stamp 'toggle agents' with this code:

if($AgentPriority>-1){$AgentPriority=-1}else{$AgentPriority=;}

You could easily scope this more by using:

if(inside("Agents") & $AgentPriority>-1){$AgentPriority=-1}else{$AgentPriority=;}
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: help with cooperating agents
Reply #10 - Aug 13th, 2014, 12:35pm
 
This should be doable, I think.  Some thoughts:

a) I wouldn't worry yet about switching agents on and off.  Let's wait and see if we need it!

b) Lots of agents are repeatedly asking the question:

Quote:
Does this note concern MY class?


It behooves us to make this question easy for agents to answer.  In particular, you're better off having a dedicated attribute $Class whose value might be "1-1" or "1-2"; this way, the agent knows exactly where to look.  Similarly, it's much faster to compare strings:

     $Class=="1-1"

than to do regular expression searches

     $Text.contains("1-1")

c) Attribute Browser might be a better choice for some of these tasks. For example, select all assignments, categorize them by $Class, and sort by $Class; you'll have a list of assignments for each class.

d) Your agents will also be asking, "is this note an assignment?" or "is this note a resource?"  Often, these are easy questions to answer. If it's not easy, though, make an agent that finds all the assignments, and this let other agents ask for notes

      inside(/helpers/allAssignments)

rather than doing the work over again.
Back to top
 
 
WWW   IP Logged
Pages: 1
Send Topic Print