metametascape
Welcome, Guest
Please Login or Register.
Lost Password?
Code gen not always based on defined rule order (1 viewing)
_GEN_GOTOBOTTOM Post Reply

TOPIC: Code gen not always based on defined rule order

#87
ecasotti (User)
Expert Boarder
Posts: 38
graphgraph
Code gen not always based on defined rule order 2008/01/23 15:47 Karma: 0  
I have created rules where the code that is generated does
not generate in the order that I define in the rule. I
have had several cases, and they tend to rear their ugly
heads when a Set is involved. Although I honestly do not
know if they are limited to these circumstances. I will
include my metaabm file.

Right now note that the code being generated cannot compile.
I have to manually fix a few things (isAvailable() for one)
and another I will mention in another thread.

1. Look at the Person Act "Ask Neighbor About Food Center Location".
Notice the Set and If happen before neighbor is even defined.

2. I also notice that the build rule for the model does not
follow the order that I would like. I want my grid to be
created first, and have this at the top of my list of things
to do when building the model. I have to manually modify
the file to build the grid first. I build the grid first
to place stationary agents such as buildings first, before
mobile agents such a people randomly become initialized
to a location where a stationary agent belongs. I definite
BuildGrid first, but the agents are created first, regardless
of the fact I specify the grid to be built first.

3. I also remember an example off the top of my head, although
I don't have an example here. If I perform an evaluation
and then do a Set as a child of the evaluation to an attribute
on the agent, that is fine. However, if AFTER the evaluation
(as a sibling of the evaluation) I try to query the attribute
I set, the generated code will place the set AFTER the query.
Not sure if that makes sense, let me know if I need to send
an example.



ev
File Attachment:
File name: Intersection.metaabm
File size:47391 bytes
  The administrator has disabled public write access.
#89
ecasotti (User)
Expert Boarder
Posts: 38
graphgraph
Re:Code gen not always based on defined rule order 2008/01/23 16:27 Karma: 0  
Also, if you look at the Food Center Initialize, the created method
winds up being generated before the random terrain even though it is
defined afterward.
  The administrator has disabled public write access.
#99
miles (Admin)
Admin
Posts: 59
graphgraph
Re:Code gen not always based on defined rule order 2008/01/30 03:01 Karma: 1  
My long-winded response got lost..argh. So forgive a little brevity..

ecasotti wrote:
1. Look at the Person Act "Ask Neighbor About Food Center Location".
Notice the Set and If happen before neighbor is even defined.


There is a generation bug here, stemming form an unexpected usage. You have a dangling Any and "Include Self" Acts. Getting rid of those the code compiles as expected. We should consider disallowing this usage in future and some of this expansion code will be revisited soon.

2. I also notice that the build rule for the model does not
follow the order that I would like.


You cannot assume any particular build order, see below. Instead best practice is to treat Rules and Initialize as being independent of each other even though Rules for example will/can be expanded in a particular order, this is not assumed for all domains. In this case, you should have the terrain (this isn't part of build grid anyway) agents place buildings and have the people agents check to see if they are in a "proposed building" location.

on the agent, that is fine. However, if AFTER the evaluation
(as a sibling of the evaluation) I try to query the attribute
I set, the generated code will place the set AFTER the query.
Not sure if that makes sense, let me know if I need to send
an example.


As above, the key point is that Sibling nodes do not occur *after* one another -- they are parallel operations so you cannot use the result of one as input into another. In the new checks system we will prevent attempting to do such a thing. As we are so used to imperative programming and textual languages it is easy to make the assumption that something tat occurs below something else occurs afterward, but that is not the case. Think of Acts as a graph structure *not* as some kind of visual representation of Java code - a soon to be released tools should help make the flow much clearer.

Also, it probably isn't desirable to have any use of a Set occur after that Set. In fact, I have considered enforcing that Sets and similar Acts are terminal Nodes. If you need to use a set value, note that you can simply use the value that you set it with instead. Alternatively you can create a Watcher for changes in that value.
  The administrator has disabled public write access.
#243
pp1234 (Visitor)
Expert Boarder
Posts: 30
graphgraph
Cabal Gold 2011/11/01 08:35 Karma: 0  
WOW Gold in the science and technology of lead the life today, all kinds of crisis lurking in the us side (body principle and mental illness, the employment pressure, housing tension, financial crisis and an ageing population and resources shortage). sell Cabal Online Alz we have to have the kind of survival in warcraft spirit and combat effectiveness of high quality, come on! Only forward, Cabal Gold there is hope!!
  The administrator has disabled public write access.
_GEN_GOTOTOP Post Reply
© Copyright 2007 Best of Joomla, Powered by FireBoardget the latest posts directly to your desktop