Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » AMP » simple life abm(error in file when validation succeed)
simple life abm [message #502523] Tue, 08 December 2009 17:13 Go to next message
Alex Smirnoff is currently offline Alex Smirnoff
Messages: 28
Registered: July 2009
Junior Member
I am trying to create simple life game agent model. Attached is an initial model I created (no actions). I see that EMF validation succeed, but when the project builds on model save, it create the java file with compilation error. I tried to repeat the steps from tutorial screen cast. In any case, I think if the model validates it should produce only valid artifacts.

[Updated on: Tue, 08 December 2009 18:09]

Report message to a moderator

Re: simple life abm [message #502524 is a reply to message #502523] Tue, 08 December 2009 17:18 Go to previous messageGo to next message
Alex Smirnoff is currently offline Alex Smirnoff
Messages: 28
Registered: July 2009
Junior Member
Sorry, I can't attach file. Here is the content. One last thing I have tried it on both nightly build and integrations.


<?xml version="1.0" encoding="UTF-8"?>
<metaabm:SContext xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:act="http://metaabm.org/act" xmlns:metaabm="http://metaabm.org/metaabm.org/structure" label="life" ID="life" pluralLabel="lifes">
  <attributes label="SimpleCell Count" ID="simpleCellCount" pluralLabel="SimpleCell Counts" description="The number of simplecells to create." sType="INTEGER"/>
  <rootActivity xsi:type="act:AGroup" label="Root Act Group" ID="rootActGroup" pluralLabel="Root Act Groups">
    <members xsi:type="act:ABuild" label="Build life" ID="buildlife" targets="//@rootActivity/@members[ID='createSimpleCells'] //@rootActivity/@members[ID='buildWorldSapce']" selected="//@rootActivity/@members[ID='buildlife']" agent="/" pluralLabel="Build lifes"/>
    <members xsi:type="act:ACreateAgents" label="Create SimpleCells" ID="createSimpleCells" sources="//@rootActivity/@members[ID='buildlife']" selected="//@rootActivity/@members[ID='buildlife']" agent="//@agents[ID='simpleCell']" agentCount="//@attributes[ID='simpleCellCount']"/>
    <members xsi:type="act:ABuildGrid" label="Build WorldSapce" ID="buildWorldSapce" sources="//@rootActivity/@members[ID='buildlife']" selected="//@rootActivity/@members[ID='buildlife']" pluralLabel="Build WorldSapces" agents="//@agents[ID='simpleCell']" projection="//@projections[ID='lifeWorld']" fillAgent="//@agents[ID='simpleCell']"/>
  </rootActivity>
  <implementation package="simple.life" className="Life" basePath=""/>
  <agents label="SimpleCell" ID="simpleCell" pluralLabel="SimpleCells">
    <rootActivity xsi:type="act:AGroup" label="Root Act Group" ID="rootActGroup" pluralLabel="Root Act Groups"/>
    <implementation className="SimpleCell"/>
  </agents>
  <projections xsi:type="metaabm:SGrid" label="LifeWorld" ID="lifeWorld" pluralLabel="LifeWorlds" dimensionality="2">
    <attributes xsi:type="metaabm:SAttributeArray" label="Dimensions" ID="dimensions" pluralLabel="Dimensionss" description="The size of each dimension." sType="INTEGER" size="2"/>
    <attributes label="Width" ID="width" pluralLabel="Widths" description="The horizontal extent of the space." sType="INTEGER" defaultValue="50"/>
    <attributes label="Height" ID="height" pluralLabel="Heights" description="The vertical extent of the space." sType="INTEGER" defaultValue="50"/>
  </projections>
</metaabm:SContext>

[Updated on: Tue, 08 December 2009 17:22]

Report message to a moderator

Re: simple life abm [message #502553 is a reply to message #502523] Tue, 08 December 2009 19:24 Go to previous messageGo to next message
Miles Parker is currently offline Miles Parker
Messages: 1340
Registered: July 2009
Senior Member
Hi Alex,

Please see below.

Alex Smirnoff wrote on Tue, 08 December 2009 12:13
I am trying to create simple life game agent model. Attached is an initial model I created (no actions). I see that EMF validation succeed, but when the project builds on model save, it create the java file with compilation error.


That's a cool thing to try. I've fixed the problem that you had. You tried to specify the same agent as both the fill agent and a member of "agents", i.e. the contained agent. I simply removed the agent and it compiled fine. I even added in a state and visualization bits. Smile

Quote:
I tried to repeat the steps from tutorial screen cast. In any case, I think if the model validates it should produce only valid artifacts.


In an ideal world, your're right. Smile It is actually quite easy to add new checks like this, so you might want to file a bug report. But there are a number of issues that come into play here.

We need to distinguish between syntactic and semantic validation. Although in this case you end up with a Java artifact that is obviously wrong, viewed from the point of view of the model validation process this is still closer to the case where someone creates a Java program that will compile, but that will produce an error when it is run.

Also, there is the issue where somethings might be reasonable in one target but not in another. For example, you might want to target an API that can only handle 2D spaces but not GIS. Then the model will be invalid for one target but not another.

In this case, I think that we could put in a check for wether the fill agent and agents are not the same, though I'm thinking that it should probably be a warning rather than an error as I'm not quite sure that there isn't a case where this kind of usage would be appropriate.

Incidentally, there is an interesting issue here WRT synchronous updating. With a typical ABM engine you are not going to be able to reproduce Conway's results. This is because Conway's life is a classic CA. In CAs, state transitions are applied to all cells in parallel. IOTW, for a given iteration cells do not take into account any changes that occur within other cells in that same period. In contrast in a typical ABM model cells are updated in a (pseudo) random order that is sequentially.

You can achieve get the same effect by storing the result from the previous calculation into a temporary value and then copying that over to the actual value in another rule.

cheers!

Miles

[Updated on: Tue, 08 December 2009 22:12]

Report message to a moderator

Re: simple life abm [message #502554 is a reply to message #502523] Tue, 08 December 2009 19:25 Go to previous messageGo to next message
Miles Parker is currently offline Miles Parker
Messages: 1340
Registered: July 2009
Senior Member
Attachments don't work for me either Sad. Here's the file in plaintext.

<?xml version="1.0" encoding="UTF-8"?>
<metaabm:SContext xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:act="http://metaabm.org/act" xmlns:function="http://metaabm.org/function" xmlns:metaabm="http://metaabm.org/metaabm.org/structure" label="life" ID="life" pluralLabel="lifes">
<attributes label="SimpleCell Count" ID="simpleCellCount" pluralLabel="SimpleCell Counts" description="The number of simplecells to create." sType="INTEGER"/>
<rootActivity xsi:type="act:AGroup" label="Root Act Group" ID="rootActGroup" pluralLabel="Root Act Groups">
<members xsi:type="act:ABuild" label="Build life" ID="buildlife" targets="//@rootActivity/@members[ID='createSimpleCells'] //@rootActivity/@members[ID='buildWorldSapce']" selected="//@rootActivity/@members[ID='buildlife']" agent="/" pluralLabel="Build lifes"/>
<members xsi:type="act:ACreateAgents" label="Create SimpleCells" ID="createSimpleCells" sources="//@rootActivity/@members[ID='buildlife']" selected="//@rootActivity/@members[ID='buildlife']" agent="//@agents[ID='simpleCell']" agentCount="//@attributes[ID='simpleCellCount']"/>
<members xsi:type="act:ABuildGrid" label="Build WorldSapce" ID="buildWorldSapce" sources="//@rootActivity/@members[ID='buildlife']" selected="//@rootActivity/@members[ID='buildlife']" pluralLabel="Build WorldSapces" projection="//@projections[ID='lifeWorld']" fillAgent="//@agents[ID='simpleCell']"/>
</rootActivity>
<implementation package="simple.life" className="Life" basePath=""/>
<agents label="SimpleCell" ID="simpleCell" pluralLabel="SimpleCells">
<attributes xsi:type="metaabm:SState" label="State" ID="state" pluralLabel="States" sType="SYMBOL" defaultValue="Alive" defaultOption=" //@agents[ID='simpleCell']/@attributes[ID='state']/@options. 0 ">
<options label="Alive" ID="alive" pluralLabel="Alives"/>
<options label="Dead" ID="dead" pluralLabel="Deads"/>
</attributes>
<rootActivity xsi:type="act:AGroup" label="Root Act Group" ID="rootActGroup" pluralLabel="Root Act Groups">
<members xsi:type="act:AInitialize" label="Initialize" ID="initialize" targets=" //@agents[ID='simpleCell']/@rootActivity/@members[ID='initia lizeRandomState_State_'] " selected=" //@agents[ID='simpleCell']/@rootActivity/@members[ID='initia lize'] " agent="//@agents[ID='simpleCell']" space="//@projections[ID='lifeWorld']" pluralLabel="Initializes"/>
<members xsi:type="act:AEvaluate" label="Initialize: Random State(State)" ID="initializeRandomState_State_" sources=" //@agents[ID='simpleCell']/@rootActivity/@members[ID='initia lize'] " targets=" //@agents[ID='simpleCell']/@rootActivity/@members[ID='setSta teToInitializeRandomState_State_'] " selected=" //@agents[ID='simpleCell']/@rootActivity/@members[ID='initia lize'] ">
<inputs selected=" //@agents[ID='simpleCell']/@rootActivity/@members[ID='initia lize'] " value="//@agents[ID='simpleCell']/@attributes[ID='state']"/ >
<function xsi:type="function:FGenericFunction" href="http://metaabm.org/core_library.metaabm#//@library [ID='coreFunctions']/@subs[ID='random']/@functions[ID='rando mState'] "/>
</members>
<members xsi:type="act:ASet" label="Set State To Initialize: Random State(State)" ID="setStateToInitializeRandomState_State_" sources=" //@agents[ID='simpleCell']/@rootActivity/@members[ID='initia lizeRandomState_State_'] " selected=" //@agents[ID='simpleCell']/@rootActivity/@members[ID='initia lize'] " attribute="//@agents[ID='simpleCell']/@attributes[ID='state'] " parameter=" //@agents[ID='simpleCell']/@rootActivity/@members[ID='initia lizeRandomState_State_'] "/>
</rootActivity>
<implementation className="SimpleCell"/>
<styles xsi:type="metaabm:SStyle2D" label="SimpleCell Style 2D" ID="simpleCellStyle2D" pluralLabel="SimpleCell Style 2Ds">
<rootActivity xsi:type="act:AGroup" label="Root Act Group" ID="rootActGroup" pluralLabel="Root Act Groups">
<members xsi:type="act:ARule" label="SimpleCell Rule" ID="simpleCellRule" targets=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRuleStateIdenticalAliveQ uery'] " selected=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRule'] " agent="//@agents[ID='simpleCell']" space="//@projections[ID='lifeWorld']" pluralLabel="SimpleCell Rules"/>
<members xsi:type="act:AQuery" label="SimpleCell Rule: State Identical Alive Query" ID="simpleCellRuleStateIdenticalAliveQuery" sources=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRule'] " targets=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRuleColorWhite'] //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRuleColorBlack'] " selected=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRule'] ">
<inputs selected=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRule'] " value="//@agents[ID='simpleCell']/@attributes[ID='state']"/ >
<inputs selected=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRule'] " value=" //@agents[ID='simpleCell']/@attributes[ID='state']/@options. 0 "/>
<function xsi:type="function:FLogicalOperator" href="http://metaabm.org/core_library.metaabm#//@library [ID='coreFunctions']/@subs[ID='operators']/@subs[ID='logical Operators']/@functions[ID='identical'] "/>
</members>
<members xsi:type="act:AEvaluate" label="SimpleCell Rule: Color White()" ID="simpleCellRuleColorWhite" sources=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRuleStateIdenticalAliveQ uery'] " targets=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRuleShapeRectangle'] " selected=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRule'] ">
<function xsi:type="function:FGenericFunction" href="http://metaabm.org/core_library.metaabm#//@library [ID='coreFunctions']/@subs[ID='graphic']/@functions[ID='colo rWhite'] "/>
</members>
<members xsi:type="act:AEvaluate" label="SimpleCell Rule: Color Black()" ID="simpleCellRuleColorBlack" sources=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRuleStateIdenticalAliveQ uery'] " targets=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRuleShapeRectangle'] " selected=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRule'] ">
<function xsi:type="function:FGenericFunction" href="http://metaabm.org/core_library.metaabm#//@library [ID='coreFunctions']/@subs[ID='graphic']/@functions[ID='colo rBlack'] "/>
</members>
<members xsi:type="act:AEvaluate" label="SimpleCell Rule: Shape Rectangle()" ID="simpleCellRuleShapeRectangle" sources=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRuleColorWhite'] //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRuleColorBlack'] " targets=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRuleGraphicFill'] " selected=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRule'] ">
<function xsi:type="function:FGenericFunction" href="http://metaabm.org/core_library.metaabm#//@library [ID='coreFunctions']/@subs[ID='graphic']/@functions[ID='shap eRectangle'] "/>
</members>
<members xsi:type="act:AEvaluate" label="SimpleCell Rule: Graphic Fill()" ID="simpleCellRuleGraphicFill" sources=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRuleShapeRectangle'] " selected=" //@agents[ID='simpleCell']/@styles[ID='simpleCellStyle2D']/@ rootActivity/@members[ID='simpleCellRule'] ">
<function xsi:type="function:FGenericFunction" href="http://metaabm.org/core_library.metaabm#//@library [ID='coreFunctions']/@subs[ID='graphic']/@functions[ID='grap hicFill'] "/>
</members>
</rootActivity>
<implementation className="SimpleCellStyle2D"/>
</styles>
</agents>
<projections xsi:type="metaabm:SGrid" label="LifeWorld" ID="lifeWorld" pluralLabel="LifeWorlds" dimensionality="2">
<attributes xsi:type="metaabm:SAttributeArray" label="Dimensions" ID="dimensions" pluralLabel="Dimensionss" description="The size of each dimension." sType="INTEGER" size="2"/>
<attributes label="Width" ID="width" pluralLabel="Widths" description="The horizontal extent of the space." sType="INTEGER" defaultValue="50"/>
<attributes label="Height" ID="height" pluralLabel="Heights" description="The vertical extent of the space." sType="INTEGER" defaultValue="50"/>
</projections>
</metaabm:SContext>
Re: simple life abm [message #502585 is a reply to message #502554] Tue, 08 December 2009 22:34 Go to previous messageGo to next message
Alex Smirnoff is currently offline Alex Smirnoff
Messages: 28
Registered: July 2009
Junior Member
Thanks a lot, Miles.

I suspected that the validation of the model is merely syntactic EMF validation. And more deeper semantic validation is needed.

From the other hand, I just started to investigate AMP and I don't know the semantics yet. I picked Cellular Automata Life game to learn programming ABM models. I thought that this might not as simple as it looks.

Thanks for improving the model. You gave me something to think about.

Alex.
Re: simple life abm [message #503103 is a reply to message #502585] Thu, 10 December 2009 16:06 Go to previous message
Miles Parker is currently offline Miles Parker
Messages: 1340
Registered: July 2009
Senior Member
Alex Smirnoff wrote on Tue, 08 December 2009 17:34
Thanks a lot, Miles.

I suspected that the validation of the model is merely syntactic EMF validation. And more deeper semantic validation is needed.


Yes, but to be clear we do have all of the infrastructure in place for this and a reasonably decent set. As you can see from the file below, they are super easy to define, so if you or anyone else have ideas for improvement, please do submit a bug or better patch for it..

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.amp/org .eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen/src/metaabm /tmpl/edit.chk?root=Modeling_Project&view=markup

Quote:
From the other hand, I just started to investigate AMP and I don't know the semantics yet. I picked Cellular Automata Life game to learn programming ABM models. I thought that this might not as simple as it looks.


Yes, sometimes the simplest things are the hardest. Ironically, this is one programming exercise that is trivial for parallel programming but harder for serial. Smile
It is very often the case with ABMs that model features end up being artifacts of the way that rule execution and space is designed.

One of the major -- if not the major -- point of AMF is to allow the user to test and experiment with models under these different conditions by only changing one value in the model. This very use case is one of the things that drove me to take a model-driven approach. So we will support this transparently in the future..

In order to support parallel updating OOTB, we will only need to add a "parallel update" rule or attribute to meta-model and then we could extend the code generator to handle all of the mechanics of this!

thanks,

Miles
Previous Topic:Problems installing and running (Vista Home 64 bit)
Next Topic:Building Agents in the GUI
Goto Forum:
  


Current Time: Wed Oct 22 00:15:54 GMT 2014

Powered by FUDForum. Page generated in 0.02366 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software