-2

I am very new and beginner user for AnyLogic. How I can combine the statechart and pedestrian library (ped block). From statechart linking to ped block and return to statechart again. I illustrate it here. Thanks in advance.

I try to follow the steps in youtube (agents in process flow), but it is showing this error. I do not understand it.

mivandev
  • 321
  • 2
  • 14
n.a
  • 1
  • 2

1 Answers1

0

There are many nuances in your question, but I will give you one example so you can try it out.

From StateChart to Pedestrian From your image, what you have to add in "action" to create pedestrians when a transition occurs is:

pedSource.inject(n); 

Where "n" is the number of pedestrians you want to add to the system. But since your statechart is in main and your pedestrians are in "Test" you have to do:

test.pedsource.inject(n); //if your agetn Test is unique
test.get(i).inject(n); //if your agent Test is a population, where "i" is the entity in the population that you want to affect

test must be defined in main. If Test is only an agent type, this will not work.

From Pedestrian to Statechart Since your pedestrian is in Test, you can generate a transition in your statechart anywhere in your pedestrian blocks doing for instance

send("transitionMessage",main);

or

main.statechart.fireEvent("message");

But you need to define a statechart entry point (you haven't done that) and your agent test must be defined as a population or as a single agent in main, otherwise the communication will not be possible.

Check out the AnyLogic help documentation, it seems that you will need it a lot. help.anylogic.com

Felipe
  • 8,311
  • 2
  • 15
  • 31
  • Thank you very much.... -entity meant agent right? such as Test is a person/ people....is it true? - I tried already but have some errors maybe i missing some parts. -If i want to have the same agent population from the statechart, is it I need to use pedEnter? but the code is different right? I tried it used your code and also modified it (unfortunately, it is error) Thanks for the help .. – n.a Feb 22 '18 at 15:18
  • pedEnter.take(this); if in the same "Test". If different i should do test.pedEnter.take(this); – n.a Feb 22 '18 at 15:31
  • OK, I already fixed it. Got the flow and code!.. thanks, Felipe... thanks Peter for helping me..... – n.a Feb 23 '18 at 02:47