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

Passing dictionary argument to BatchRunner #307

Closed
devforfu opened this issue Aug 17, 2016 · 3 comments
Closed

Passing dictionary argument to BatchRunner #307

devforfu opened this issue Aug 17, 2016 · 3 comments

Comments

@devforfu
Copy link
Contributor

devforfu commented Aug 17, 2016

Not sure if it is an issue and not intended behaviour but nevertheless decided to notify about it.

When you pass a dictionary value into batch runner it only takes keys and not values. So you'll not get a cartesian product of your values. For example, if you pass something like this:

class MoneyModel(Model):

    def __init__(self, n, grid_params):  # grid_params is intended to be a dictionary
        super().__init__(self)
        ...


def main():
    ...
    n_iters, n_steps = 5, 200
    params = {
        "grid_params": {"height": 10, "width": 10},
        "n": range(10, 500, 10)}
    batch = BatchRunner(MoneyModel, params,
        iterations=n_iters, max_steps=n_steps,
        model_reporters={"Gini": compute_gini})
    batch.run_all()

You'll get issue in there: https://github.com/projectmesa/mesa/blob/master/mesa/batchrunner.py#L71, i.e. variable kwargs will be equal to {'grid_params': 'width', 'n': 10} (or any other dictionary key) instead of original value.

@jackiekazil
Copy link
Member

Interesting. I didn't notice this before. This was not on purpose. I just think that no one noticed it before.

Do you want to submit a PR for it? (If not, would you mind writing a test for it and someone else can code against?)

@devforfu
Copy link
Contributor Author

Yes, sure, I'll do it.

@njvrzm
Copy link
Contributor

njvrzm commented May 22, 2017

This should be fixed by #374!

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

No branches or pull requests

3 participants