Quantcast

Create events within an agent class

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Create events within an agent class

rodolfobolconte
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create events within an agent class

srcnick
You need to schedule the adding to occur in the future. You can do the scheduling in ContextBuilder. Using Java 8’s lambdas you can do this with:

RunEnvironment.getInstance().getCurrentSchedule().schedule(ScheduleParameters.createOneTime(10), 
        () -> {
          context.add(new Ev1(space, grid));
        });

I think that should work and the context, space and grid should be enclosed by the lambda.

Nick

On Oct 23, 2016, at 7:22 AM, Rodolfo Bolconte Donato <[hidden email]> wrote:

Good Morning,

I need to create events in the repast at random (according to the tick count) and did not find a solution to create from the builder class. I did this method down, but as soon as my agent creates the event, lock the simulation. Sorry for the English, I'm from Brazil and I do not speak fluently. Thank you.

        public void criaEvento()
{
Context context = (Context) ContextUtils.getContext(this);
ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder.createContinuousSpaceFactory(null);
ContinuousSpace <Object> space = spaceFactory.createContinuousSpace("space", context, new RandomCartesianAdder <Object> (), new repast.simphony.space.continuous.WrapAroundBorders(), 30, 30);
GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
Grid <Object> grid = gridFactory.createGrid("grid", context, new GridBuilderParameters <Object> (new WrapAroundBorders(), new SimpleGridAdder <Object> (), true, 30, 30));
double nun = RunEnvironment.getInstance().getCurrentSchedule().getTickCount();
if (nun == 10)
{
context.add(new Ev1(space, grid));
}
}

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create events within an agent class

rodolfobolconte
CONTENTS DELETED
The author has deleted this message.
Loading...