Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 322251 - Repast Generation - MetaABM translates Context to Agent in model.score
Summary: Repast Generation - MetaABM translates Context to Agent in model.score
Status: CLOSED FIXED
Alias: None
Product: AMP
Classification: Modeling
Component: AMF (show other bugs)
Version: 0.8.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Miles Parker CLA
QA Contact: Miles Parker CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-10 12:06 EDT by befloibent CLA
Modified: 2011-05-31 17:57 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description befloibent CLA 2010-08-10 12:06:44 EDT
I'm just getting started using AMP to generate Repast Simphony models so maybe I'm missing something.  When I add a Context to my MetaABM tree, it gets translated to the model.score as an agent without the xsi:type="score:SContext".  During code generation then, in the Root Context's build method, the added Context is treated like an Agent with a context.add() instead of context.addSubContext(), and a setter for its Root (parent) Context.  Code generation for the added Context correctly extends DefaultContext, but does not have a method for accessing the Root (parent) Context, thus a compilation error in the Root Context code.

Steps to reproduce:

1.)  File->New->Agent Modeling Simphony Project
2.)  File->New->Agent Model (MetaABM)
3.)  Add an Agent and a Context to the Root
4.)  Save to generate model.score and code

Hope this helps.
-Manuel
Comment 1 Miles Parker CLA 2010-08-10 12:46:18 EDT
Hi Manuel,

Thanks for the bug report. To be honest, there hasn't been a ton of interest in Repast generation -- though I spent a lot of time developing it at the beginning it turns out that a lot of people want to simply generate straight to the AMP platform -- so this hasn't been an area that has been kept current as well as it could be. However, if there *are* users who want to see good support and are willing to file bug reports ;) this will most definitely get attention.

On area that is lacking is good multi-scale support. I'll get the Model.score translation working as quickly as possible. One thing that would be extremely helpful is when people see code patterns that don't work -- like you've just described -- they could provide a code snippet that shows what is currently generated and one that shows what would ideally be generated. That makes the fixes that need to happen super-straight-forward.

cheers,

Miles
Comment 2 befloibent CLA 2010-08-10 13:35:47 EDT
Thanks Miles.  I'm also just getting started with Repast, so you might very well have a better idea of what should be getting generated than I, but in the implementation of ContextBuilder for my root context BugTestRootContext, this is being generated:

BugTestSubContext createBugTestSubContexts = null;
for (int i = 0; i < getBugTestSubContextCount(); i++) {
   createBugTestSubContexts = new BugTestSubContext();
   context.add(createBugTestSubContexts);                 //<-Adds like Agent
   createBugTestSubContexts.setBugTestRootContext(this);  //<-Error
}

I believe what should be generated is:

BugTestSubContext createBugTestSubContexts = null;
for (int i = 0; i < getBugTestSubContextCount(); i++) {
   createBugTestSubContexts = new BugTestSubContext();
   context.addSubContext(createBugTestSubContexts);       //<-Add as SubContext
}


In the generated model.score file, I'm seeing:

<agents label="BugTest SubContext" ID="bugTestSubContext" pluralLabel="BugTest SubContexts">

where I believe it should be

<agents xsi:type="score:SContext"label="BugTest SubContext" ID="bugTestSubContext" pluralLabel="BugTest SubContexts">

(Hopefully Bugzilla didn't mangle the angle brackets).

The reason I'm targeting Repast is the understanding (correct or not) that 3D Geography (not just 2.5D) is not implemented with Ascape/Escape.  I'd be happy to learn otherwise.  I'm modeling aspects of bird movement where height is a critical component.

Thanks,
-Manuel
Comment 3 Miles Parker CLA 2010-08-10 13:54:23 EDT
(In reply to comment #2)
> Thanks Miles.  I'm also just getting started with Repast, so you might very
> well have a better idea of what should be getting generated than I, but in the
> implementation of ContextBuilder for my root context BugTestRootContext, this
> is being generated:
> 
> BugTestSubContext createBugTestSubContexts = null;
> for (int i = 0; i < getBugTestSubContextCount(); i++) {
>    createBugTestSubContexts = new BugTestSubContext();
>    context.add(createBugTestSubContexts);                 //<-Adds like Agent
>    createBugTestSubContexts.setBugTestRootContext(this);  //<-Error
> }
> 
> I believe what should be generated is:
> 
> BugTestSubContext createBugTestSubContexts = null;
> for (int i = 0; i < getBugTestSubContextCount(); i++) {
>    createBugTestSubContexts = new BugTestSubContext();
>    context.addSubContext(createBugTestSubContexts);       //<-Add as SubContext
> }

Perfect. I'm not sure that that is all that is needed to get subcontexts to work properly but it should at least be a good start.

> In the generated model.score file, I'm seeing:
> 
> <agents label="BugTest SubContext" ID="bugTestSubContext" pluralLabel="BugTest
> SubContexts">
> 
> where I believe it should be
> 
> <agents xsi:type="score:SContext"label="BugTest SubContext"
> ID="bugTestSubContext" pluralLabel="BugTest SubContexts">

Yes, that sounds exactly right.

> (Hopefully Bugzilla didn't mangle the angle brackets).
> 
> The reason I'm targeting Repast is the understanding (correct or not) that 3D
> Geography (not just 2.5D) is not implemented with Ascape/Escape.  I'd be happy
> to learn otherwise.  I'm modeling aspects of bird movement where height is a
> critical component.

You're correct, it's not yet. Though "it wouldn't be that hard". :) Seriously, what's needed is some pretty straightforward code for the actual 3D geometry (simple distance functions) along with a few changes to the visualization to support 3D locations for shapes. It would also be really nice to have model level support for headings / vectors.

But I agree that unless you want to get into framework issues and contribute to the actual AMP code base that it probably makes sense to start with Repast. Of course, you'll be able to target Escape as well if you chose to do that later when full 3D support is working. (BTW, feel free to open a feature request for that -- I don't think one exists yet but its definitely on my mental todo list.)

That changes are easy, but unfortunately, the only hold up right now is that the Eclipse automated build system is broken -- I've been spending all of my available time for the last few weeks trying to get a better solution up and running. That's close to being finished.
Comment 4 Miles Parker CLA 2010-09-16 15:46:25 EDT
Hi Manuel,

Apologies for taking so long to get this in -- the problem was not the changes at all but getting the build working. :( As the build promotion is still not up you'll need to use the build server update site at:

https://build.eclipse.org/hudson/view/Athena%20CBI/job/cbi-amp-nightly/lastSuccessfulBuild/artifact/amp.p2.repository/

if you want to test it now. Please let me know if the fix works..
Comment 5 Miles Parker CLA 2011-05-31 17:57:34 EDT
I'm going to close this as AMP will not be updated for future versions of Repast unless demand for that functionality exists.