FLAMEGPU / FLAMEGPU2

FLAME GPU 2 is a GPU accelerated agent based modelling framework for CUDA C++ and Python
https://flamegpu.com
MIT License
106 stars 22 forks source link

[Bug]:The results simulated by using Python Agent API in Tutorial Code are different from those using c++ Agent API. #1158

Closed chenyuyou closed 11 months ago

chenyuyou commented 11 months ago

Bug Description

The results simulated by using Python Agent API in Tutorial Code are different from those using c++ Agent API. https://docs.flamegpu.com/tutorial/index.html#complete-tutorial-code

To Reproduce

image This is the result by using python agent api image This is the result by using C++ agent api

Expected Behaviour

I think that the result of by using python agent api is wrong.

OS

win11

CUDA Versions

cuda 11

GPUs

3080

GPU Driver

No response

Additional Information

No response

Robadob commented 11 months ago

I have a feeling this is a bug I've seen before and thought I addressed. Will take a look later this afternoon.

Thanks for reporting.

Robadob commented 11 months ago

Hi,

I've tried both the "Python (using C++ Agent API)" and "Python (using Python Agent API)" versions found here and the both produce output like this (which is correct):

image

Is it possible you've modified one of the environment properties or made a mistake whilst copying from the individual code snippets?

Behaviour similar to your first screenshot can be achieved by setting repulse to a negative number.

image

If you can share your implementation I will try running that too.

chenyuyou commented 11 months ago

I completely copy the code of python style here and run. The result is not different than before.

And I rewrite those code in my repositories. Their codes are the same but the results are different. The python code is https://github.com/chenyuyou/fg2-example/blob/main/circles_spatial2D/python/model.py The c++ code is https://github.com/chenyuyou/fg2-example/blob/main/circles_spatial2D/python_rtc/model.py

Robadob commented 11 months ago

I've just downloaded and ran both of your versions of the code. Both execute and produce the correct circle arrangement of agents after around 200 steps.

I don't think this would be a difference with the version of pyflamegpu you are using (I just built the latest from master), is it possible you have changes that you haven't pushed to git (e.g. check git diff)?

chenyuyou commented 11 months ago

I've just downloaded and ran both of your versions of the code. Both execute and produce the correct circle arrangement of agents after around 200 steps.

I don't think this would be a difference with the version of pyflamegpu you are using (I just built the latest from master), is it possible you have changes that you haven't pushed to git (e.g. check git diff)?

How to build pyflamegpu lastest version?

Robadob commented 11 months ago

How to build pyflamegpu lastest version?

Clone the git repo (or download the latest zip)

Then follow this guide from the docs.

Robadob commented 11 months ago

Ah, this PR was merged a while back but isn't currently in a release. I expect that may explain your problem.

https://github.com/FLAMEGPU/FLAMEGPU2/pull/1077

Apologies, for not realising sooner.

Edit: I reverted that commit locally, and it produced the behaviour you are seeing.

image

Robadob commented 11 months ago

We're hoping to get another release out "soon", once #1090 #1089 and #1150 have been merged (the latter is waiting on a 3rd party PR to be merged [which itself is waiting on two other PRs]). This will hopefully be Jan/Feb.

I can manually trigger a draft release build, which will generate new wheels (that expire after ~24h) if you are unable to build pyflamegpu yourself.

chenyuyou commented 11 months ago

How to build pyflamegpu lastest version?

Clone the git repo (or download the latest zip)

Then follow this guide from the docs.

Thanks for your help, I will try soon.

chenyuyou commented 11 months ago

Install pyflamegpu 2.0.0rc1+cuda118 wheel into D:/Downloads/FLAMEGPU2/build/lib/Release/python/venv Looking in links: dist EXEC : error : Could not find a version that satisfies the requirement pyflamegpu==2.0.0rc1+cuda118 (from versions: non e) [D:\Downloads\FLAMEGPU2\build\swig\python\pyflamegpu.vcxproj] EXEC : error : No matching distribution found for pyflamegpu==2.0.0rc1+cuda118 [D:\Downloads\FLAMEGPU2\build\swig\pytho n\pyflamegpu.vcxproj]