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

Introduce simulation generators #604

Merged
merged 3 commits into from
Feb 15, 2018
Merged

Introduce simulation generators #604

merged 3 commits into from
Feb 15, 2018

Conversation

fpagnoux
Copy link
Member

@fpagnoux fpagnoux commented Dec 12, 2017

Introduce a helper function to generate arbitrarily big populations.

I used it a lot to investigate performances, and it could be reused. I put in in tests, but there may be a better spot.

This is clearly low priority

adults = [0] + sorted(random.sample(xrange(1, nb_persons), nb_groups - 1))

members_entity_id = np.empty(nb_persons, dtype = int)
members_legacy_role = np.empty(nb_persons, dtype = int)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be helpful to write a reminder of the legacy_role indexes ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment to explain what legacy roles are


def make_simulation(tax_benefit_system, nb_persons, nb_groups, **kwargs):
"""
Generate a simulation containing nb_persons persons spread in nb_groups groups
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would an example (or a link to one) would be useful for fist time users ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an example


def randomly_init_variable(simulation, variable_name, period, max_value, condition = None):
"""
Initialise a variable with random values (from 0 to max_value) for the given period.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would an example (or a link to one) would be useful for fist time users ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an example

@Anna-Livia
Copy link
Contributor

As for the directory, would openfisca_core/tools/script be more appropriate ?

@fpagnoux fpagnoux force-pushed the simulation-generator branch 2 times, most recently from 7b31f87 to c761e48 Compare February 15, 2018 04:25
@fpagnoux fpagnoux force-pushed the simulation-generator branch from c761e48 to daa52b6 Compare February 15, 2018 04:29
@fpagnoux fpagnoux requested a review from Anna-Livia February 15, 2018 04:33
@fpagnoux fpagnoux force-pushed the simulation-generator branch from a9261b9 to 37b310a Compare February 15, 2018 04:33
@Anna-Livia Anna-Livia merged commit b04bc7b into master Feb 15, 2018
@fpagnoux fpagnoux deleted the simulation-generator branch March 20, 2018 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants