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

Cleanup and restructure EpsteinCivilViolence and PdGrid examples #2408

Merged
merged 4 commits into from
Oct 24, 2024

Conversation

EwoutH
Copy link
Member

@EwoutH EwoutH commented Oct 23, 2024

Cleanup and restructure the EpsteinCivilViolence and PdGrid advanced example models. This PR is similar to what was done in the basic examples in #2365.

It draws the discrete spaces as was supported in #2386 and updates the imports to be absolute, similar to #2402.

EpsteinCivilViolence and PdGrid now:

  • Have all their Agent code in an agents.py file.
  • Use a flat structure.
  • Use the newest SolaraViz API
  • Have the old visualization code removed

Screenshot_522
Screenshot_523

A few things to note:

  • Handeling agent_portrayals is still finicky
  • I couldn't get the square shape to work
  • EpsteinCivilViolence shows remarkable stable behavior. Is this correct?
  • Claude 3.5 Sonnet went full YOLO and found a way to get a choice selector to work:
    "activation_order": {
        "type": "Select",
        "value": "Random",
        "values": PdGrid.activation_regimes,
        "label": "Activation Regime"
    }
    @Corvince Is this a proper approach? If so, does that mean that Viz: Implement Choice UserParam #2376 isn't needed anymore?
  • Real interesting changes in behavior between the random, sequential and staged activation regimes! Sequential and staged quickly go to all cooperating or all non-cooperating. Maybe we should double check if this works as intended.

@EwoutH EwoutH added the example Changes the examples or adds to them. label Oct 23, 2024
Copy link

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -1.6% [-1.9%, -1.3%] 🔵 -0.1% [-0.3%, +0.1%]
BoltzmannWealth large 🔵 -2.0% [-2.4%, -1.6%] 🔵 +0.0% [-0.3%, +0.4%]
Schelling small 🟢 -3.9% [-4.3%, -3.6%] 🔵 -0.1% [-0.4%, +0.2%]
Schelling large 🔵 -3.7% [-4.8%, -2.6%] 🔵 -1.9% [-2.9%, -1.1%]
WolfSheep small 🔵 -1.8% [-2.1%, -1.5%] 🔵 +2.7% [+1.6%, +3.7%]
WolfSheep large 🔵 -1.7% [-2.1%, -1.4%] 🔵 +3.2% [+1.8%, +4.6%]
BoidFlockers small 🔵 -1.1% [-1.5%, -0.6%] 🔵 -1.9% [-2.7%, -1.1%]
BoidFlockers large 🔵 -1.0% [-1.6%, -0.3%] 🔵 -1.7% [-2.1%, -1.2%]

@quaquel
Copy link
Member

quaquel commented Oct 23, 2024

The code reorganization etc. looks fine from my end, so I'll approve the PR on that ground.

EpsteinCivilViolence shows remarkable stable behavior. Is this correct?

Luckily for you, I wasted an entire morning on this for my teaching version of this model on this question: swap out OrthogonalMooreGrid for OrthogonalVonNeumann grid. There are a few more things I would like to do with this example (but those can wait for a separate PR).

Real interesting changes in behavior between the random, sequential and staged activation regimes! Sequential and staged quickly go to all cooperating or all non-cooperating. Maybe we should double check if this works as intended.

I plan to do a pr on this soon based on an mesa 3.0 updated version of my teaching version. It might be nice to include the activation order as a user input in the gui version. It would not be strange if activation order matters a lot in this model.

@EwoutH
Copy link
Member Author

EwoutH commented Oct 23, 2024

Thanks for the swift review!

Luckily for you, I wasted an entire morning on this for my teaching version of this model on this question: swap out OrthogonalMooreGrid for OrthogonalVonNeumann grid.

Huh, that's indeed interesting. Tell me how that went tomorrow!

It would not be strange if activation order matters a lot in this model.

Yeah definitely play with it (or I can show it tomorrow). Kind of strange! (but also haven't gave it proper brain cycles, those are scares this week)


I will leave this PR open for a bit for others to take a look at it, we can merge tomorrow.

EwoutH and others added 4 commits October 24, 2024 11:41
- Flatten structure
- Update the viz and add new discrete grid portrayal
- Remove unneeded viz
- Add to init
- Flatten structure
- Update the viz and add new discrete grid portrayal
- Remove unneeded viz
- Add to init
@EwoutH EwoutH merged commit 495e4e2 into projectmesa:main Oct 24, 2024
4 of 6 checks passed
@EwoutH
Copy link
Member Author

EwoutH commented Oct 24, 2024

@quaquel merged, go ahead and follow up with changing the OrthogonalMooreGrid to OrthogonalVonNeumann. If you figured out why that mattered, would be very curious to hear that!

@EwoutH
Copy link
Member Author

EwoutH commented Oct 26, 2024

@quaquel so we don't forget it, should I create an issue for changing the OrthogonalMooreGrid to OrthogonalVonNeumann?

@quaquel
Copy link
Member

quaquel commented Oct 26, 2024

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
example Changes the examples or adds to them.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants