Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different groups start at different time #109

Open
xiangyuanhang opened this issue Feb 2, 2019 · 20 comments
Open

Different groups start at different time #109

xiangyuanhang opened this issue Feb 2, 2019 · 20 comments

Comments

@xiangyuanhang
Copy link

xiangyuanhang commented Feb 2, 2019

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
Copy link
Owner

MengeCrowdSim commented Feb 2, 2019 via email

@curds01
Copy link
Collaborator

curds01 commented Feb 4, 2019

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
Copy link
Owner

PRs #110 and #111 have now been merged.

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

  • a timer if the cause for the delay lasts an arbitrary time value
  • An event if the delay lasts until other agents have moved.

@xiangyuanhang
Copy link
Author

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
Copy link
Collaborator

curds01 commented Feb 5, 2019

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.xml file. 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.

@curds01 curds01 reopened this Feb 5, 2019
@xiangyuanhang
Copy link
Author

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
Copy link
Collaborator

curds01 commented Feb 6, 2019

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
Copy link
Collaborator

curds01 commented Feb 6, 2019

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

@curds01
Copy link
Collaborator

curds01 commented Feb 7, 2019

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

@xiangyuanhang
Copy link
Author

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
Copy link
Author

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

@curds01
Copy link
Collaborator

curds01 commented Feb 10, 2019

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
Copy link
Author

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
Copy link
Author

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

@curds01
Copy link
Collaborator

curds01 commented Feb 10, 2019

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
Copy link
Author

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
Copy link
Collaborator

curds01 commented Feb 11, 2019

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
Copy link
Author

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
Copy link
Collaborator

curds01 commented Feb 11, 2019

Glad it's working for you.

@curds01
Copy link
Collaborator

curds01 commented Feb 11, 2019

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....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants