mesa icon indicating copy to clipboard operation
mesa copied to clipboard

Agent size change based on size of figure

Open ankitk50 opened this issue 2 years ago • 11 comments

If the number of agents in greater than 50, I use a linearly decreasing function to calculate the size of the agent. The lower limit for the agent size is 5.

ankitk50 avatar Sep 25 '23 16:09 ankitk50

Thank you for starting to work on this 👍

Corvince avatar Sep 26 '23 06:09 Corvince

I have restructured the UI layout using some of the features by Solara. The sidebar can be minimised to expand the user view:

Screenshot 2023-09-26 at 15 57 57

ankitk50 avatar Sep 26 '23 14:09 ankitk50

That looks nice. We could adaptively change the layout by detecting whether the Solara component is run in a Jupyter notebook or not: https://stackoverflow.com/questions/15411967/how-can-i-check-if-code-is-executed-in-the-ipython-notebook. But for this PR, you should focus on solving the grid render for #1806. The layout restyling should be in a separate PR.

rht avatar Sep 26 '23 14:09 rht

I have now updated to change the size of the figure based on number of agents. This is possibly the easiest way. This avoids agent markers to come close as the number of users increase.

Changing the size of the markers itself does not look neat, although its possible.

Sure I can move future layout modifications to another PR.

ankitk50 avatar Sep 26 '23 14:09 ankitk50

To put it concisely:

  • The marker size depends mainly on figure width and grid width, and nothing else. cell_width = figure_width / grid_width. Marker size should be adaptively scaled such that it is x% of cell width
  • The figure size depends on screen width, and it is actually harder to detect screen width because it is a client-side information.

rht avatar Sep 26 '23 14:09 rht

Thanks for the explaination, I can try this out. Meanwhile UI related changes is moved to PR #1825.

ankitk50 avatar Sep 26 '23 15:09 ankitk50

The change maintains the size of the agents based on size of the figure.

ankitk50 avatar Oct 03 '23 08:10 ankitk50

Really like this idea! What's needed to move this forward?

EwoutH avatar Oct 23 '23 09:10 EwoutH

  1. Remove number of agents from the formula to calculate size. I have said several times that grid cell size has nothing to do with the number of agents. You can have a huge grid with sparse agents, and yet the agent marker still needs to be not bigger than the grid cell size
  2. https://github.com/projectmesa/mesa/pull/1825#discussion_r1349484373. Given that we haven't figured out a way to get screen size info to be sent to the Solara server, auto-scaling figure size needs to be removed for now.
  3. Print functions haven't been removed

rht avatar Oct 23 '23 09:10 rht

Secondary reason for https://github.com/projectmesa/mesa/pull/1825#discussion_r1349484373 is that it is not thread safe. Anything that is global operation via plt.* is not thread safe.

rht avatar Oct 23 '23 09:10 rht

@ankitk50 can we help you move this forward?

EwoutH avatar Jan 21 '24 21:01 EwoutH

Superseded by #2049.

rht avatar Feb 22 '24 07:02 rht