-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add collisions as part of the simulator state and change default values #46
Conversation
TODO : Fix the requirements.txt, there seems to be a problem with the version of the newly added grpcio-tools |
I think we could put Or we could just set the versions of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for the requirement bug, the new parameters seems to work as expected
Modified a bit the logic of the mask in the collision functions. Before the mask was applied on the whole array of energies for all pairs of neighbor particles in |
…corentin/new_collisions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool that you manage by yourself to add a new argument in the entire pipeline, well done :)
And thanks for the having documented the collision functions.
I have written some comments in the code, please have a look.
When testing it, I observed that the agents/objects where largely overlapping with each other, as if the collision parameters were way too low. I increased them in the interface, but even at every large values it was still the same
scripts/run_server.py
Outdated
# TODO : Quick nnote : would be cool to have a separate file to have all the default values | ||
# In fact the best solution might be to use hydra with yaml files instead of argparse, | ||
# Would also be pretty convenient to store positions etcc for different notebook scenes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can discuss this yes, my impression is that this could be done in the context of #30 , so you could move this comment there (and remove it from this file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed I forgot to remove these comments
vivarium/controllers/config.py
Outdated
col_eps = param.Number(0.003) | ||
col_alpha = param.Number(0.7) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These names are not very informative. They might actually be misleading because we already use "col" as a shortcut for column in some files. I would suggest "collision_*" instead (in general better to favor clarity than concision for variable name).
This is a bit fastidious to change though ... but using "search and replace", or even the "refactor" functionality of you IDE, this could be done relatively quickly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I thought about it, the "collision_*" syntax will be more informative
:param epsilon: interaction energy scale between two particles | ||
:param alpha: interaction stiffness between two particles | ||
:return: sum of all collisions energies of the system | ||
""" | ||
diameter = lax.stop_gradient(diameter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure at all about this but I mention it here just in case you have thoughts about it:
From what I understood of jax/jax_md, the stop_gradient
here is to avoid that the system goes down the energy function by reducing the particle diameter, as we only want it to change particle positions. But I'm wondering if internally, it could minimize the energy by changing other parameters in this function, e.g. epsilon and alpha, or even exists_mask?
Do you see a way to check this? Potential options could be to either check manually that those values are not modified during a collision, or asserting that their gradient is at 0.
Not sure at all, but I'm actually wondering if this could be the reason of the bug we observed yesterday (imagine that it was actually modifying the exists_mask as a way to minimize energy ... I'm doubting it was the case though because the best way to do this would be to make entities non-existing, whereas we observe the opposite somehow ..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good question, I'm not sure to understand how everything works in jax_md.
For the epsilon and alpha parameters, we see in the web interface that they aren't changed during the simulation. For the exists_mask,
I tried to debug the code and the exists mask seemed to work fine (but I could do a further checking if you want, for example by creating a copy of the exists_mask at the beginning of each update, and asserting it isn't changed after the update). But it doesn't tell us why the collisions were acting weirdly ...
I tested it again and indeed the default values are not optimal (I don't understand why they give a different result compared to last time). It you increase the epsilon, you should have collisions with a really strong 'repulsive' effect. If you increase the alpha, you should have collisions that are softer and softer (in fact you need to lower alpha to prevent particles from overlapping, so stiffness is kind of misleading for this parameter). I'll change the default values and precise how to use these parameters in the docstring of the collision function. |
Description
Added the collision parameters (
alpha
: interaction stiffness andepsilon
: the interaction energy scale ) as part of the simulator state. In the future this could change (because we would ideally want to have custom alphas and epsilons between different types of particles) but it is already useful at the moment. This enables defining initial values for these parameters when launching experiments, and moreover to play with them directly in the web interface (in theSimulator
config).I think I fixed a small bug in the
sim_computation
: the sigma (diameter of the particle undergoing the soft_sphere_energy) was the sum of the diameter of sender and receiver, I set it to the sum of the radius (but I'm not sure to understand very well how this function works so I might be wrong). From their documentation, it almost seems like sigma is only the diameter of 1 particle (and then it should maybe be the diameter of the receiving particle ...).I also added a module (
grpcio-tools
) to therequirements.txt
because it was missing (to recompile proto files).I also played a bit with the parameters and set them to values that didn't seem horrible. For example try to set an epsilon really high or an alpha really low, you'll see that it makes the simulation extremely chaotic ! Feel free to change the default values to ones that make the simulation looks cooler (: @Marsolo1 @clement-moulin-frier
Related Issue (if applicable)
#29
this PR replaces the #35 (which wasn't really clean)
How to Test
Launch the server
Launch the Panel interface