MengeCrowdSim / Menge

The source code for the Menge crowd simulation framework
Apache License 2.0
138 stars 64 forks source link

Different groups start at different time #109

Open xiangyuanhang opened 5 years ago

xiangyuanhang commented 5 years ago

Hi, I wonder if it's possible to start different groups of agent at different time? For example, group1 starts immediately after clicking the space, group2 starts 5 seconds after clicking the space. Thanks

MengeCrowdSim commented 5 years ago

The easiest way to do that is to start the second group in a "waiting" state that has a 5-second timer transition out of it and into a "walking" state.

On Sat, Feb 2, 2019 at 1:29 AM XIANG Yuanhang notifications@github.com wrote:

Hi, I wonder if it's possible to start different groups of agent at different time? For example, group1 starts immediately after clicking the space, group2 starts 5 seconds after clicking the space.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MengeCrowdSim/Menge/issues/109, or mute the thread https://github.com/notifications/unsubscribe-auth/AH8tK3DzAE69Q3WzrTsWW9VIegmaTaDuks5vJVpYgaJpZM4afgmx .

curds01 commented 5 years ago

There are two PRs in flight: #110 and #111.

If you look at the example in #111 (examples\core\events\change_state_effect), you'll see a case where the movement of two groups isn't coordinated by a timer, but by events.

MengeCrowdSim commented 5 years ago

PRs #110 and #111 have now been merged.

So, there are now a couple solutions to your question:

xiangyuanhang commented 5 years ago

Thanks for your answers! For adding a 5-second timer, I have tried to modify pedModelSwapB.xml, haven't succeeded yet. Could you please tell me how to modify pedModelSwapB.xml and any other files if necessary?

curds01 commented 5 years ago

I've created a gist: https://gist.github.com/curds01/025c125fdeef5fd7dc31076d6d4ee145#file-pedmodelswapb_delayed_movement-xml-L38

This is based on the new example created in #111. That, in turn, is a simplification of the pedModelSwapB.xmlfile. I would emphasize several things:

  1. I've added a new state: WaitLeft
  2. I've also added a transition from WaitLeft to MoveLeft that depends on a 3-second timer.
  3. What isn't shown is the change to the specification. This line that specifies the initial state as MoveLeft should be changed to WaitLeft.
xiangyuanhang commented 5 years ago

Thanks for your answer! I downloaded the lastest version but I have been running into these errors when building "MengeCore.vcxproj" . Is there something wrong with EventEffectDB.cpp?

2>EventEffectDB.obj : error LNK2001: unresolved external symbol "public: virtual void thiscall Menge::ChangeStateEffect::finalize(void)" (?finalize@ChangeStateEffect@Menge@@UAEXXZ) 2>EventEffectDB.obj : error LNK2001: unresolved external symbol "protected: virtual void thiscall Menge::ChangeStateEffect::agentEffect(class Menge::Agents::BaseAgent )" (?agentEffect@ChangeStateEffect@Menge@@MAEXPAVBaseAgent@Agents@2@@Z) 2>EventEffectDB.obj : error LNK2019: unresolved external symbol "public: thiscall Menge::ChangeStateEffectFactory::ChangeStateEffectFactory(void)" (??0ChangeStateEffectFactory@Menge@@QAE@XZ) referenced in function "public: static void cdecl Menge::ElementDB<class Menge::EventEffectFactory,class Menge::EventEffect>::addBuiltins(void)" (?addBuiltins@?$ElementDB@VEventEffectFactory@Menge@@VEventEffect@2@@Menge@@SAXXZ) 2>EventEffectDB.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall Menge::ChangeStateEffectFactory::setFromXML(class Menge::EventEffect ,class TiXmlElement *,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)const " (?setFromXML@ChangeStateEffectFactory@Menge@@MBE_NPAVEventEffect@2@PAVTiXmlElement@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

curds01 commented 5 years ago

Sorry about the linking difficulty. Which VS project are you using? I hadn't tested either VS2015 or VS2013 and there could be an error there. It seems like the ChangeStateEffect symbols aren't being properly exported.

curds01 commented 5 years ago

Try pulling PR #113; it's the 2017 project that I was working in.

curds01 commented 5 years ago

Also, PR #114 corrects the oversight of not having included the change effect in the projects.

xiangyuanhang commented 5 years ago

Thanks for your answer! I have successfully built the project vs2017 and I made the three changes you have emphasized:

  1. I added the state: WaitLeft (in pedModelSwapB.xml)
  2. I added the transition: from WaitLeft to MoveLeft (in pedModelSwapB,xml) https://gist.github.com/xiangyuanhang/24819ad80671b21fcfa205afa0c2d795
  3. And I changed the initial state of group2 in pedModelSwapS.xml to WaitLeft (in pedModelSwapS.xml) https://gist.github.com/xiangyuanhang/9017cde8c6e0806856a83b8c5aa5dfbe But the simulation still fails...
xiangyuanhang commented 5 years ago

It returns Simulation terminated through error. See error log for details. Where could we find the error log? Thanks

curds01 commented 5 years ago

It writes to a file called log.html in the Exe directory. That should give you some information about how things are.

Did you try running the examples/core/events/change_state_effect/change_state.xml example? Can you confirm that runs?

Also, I didn't test the XML I'd put in the gist, I may have introduced an error there. I'd start with the example I indicated just above (change_state.xml).

xiangyuanhang commented 5 years ago

Thanks for your answer! I have confirmed change_state.xml. It runs perfectly. So I suppose this could be the problem with the timer.

xiangyuanhang commented 5 years ago

For XML containing a timer, it returns these errors according to error log: image

curds01 commented 5 years ago

So, in that case, it's just badly formatted XML. Tinyxml parsed it and said, "This isn't real xml". If you dump the contents of that file into an online XML linter it'll tell you more detail about the problem.

xiangyuanhang commented 5 years ago

Thanks for your answer! I did make some syntax errors with xml file (sorry for that) and I corrected them. And now I ran into these errors, it seemed that there is something wrong with timer: image

curds01 commented 5 years ago

The error message says you're missing an attribute on the "timer" condition. Specifically, the per_agent attribute. It should look something like:

<Condition type="timer" per_agent="0" dist="c" value="10" />

(By the way, the gist links you provided above aren't valid.)

xiangyuanhang commented 5 years ago

Thanks for your answer! Yes I did miss per_agent attribute. Now it works! Many THANKS for your help !

BTW, Sorry for the unvalid gist links, the corrected links are as follows (the final version which works): https://gist.github.com/xiangyuanhang/9017cde8c6e0806856a83b8c5aa5dfbe https://gist.github.com/xiangyuanhang/24819ad80671b21fcfa205afa0c2d795

curds01 commented 5 years ago

Glad it's working for you.

curds01 commented 5 years ago

This underscores the difficulty in authoring scenarios. That puts a little more weight on the scales of providing a tool that makes it easier to create scenarios....