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

Group entity #175

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open

Group entity #175

wants to merge 32 commits into from

Conversation

zugnachpankow
Copy link

I think the group entity would be at a point to be merged into master. I only ran tests that used the entity with a modified seven dwarfs script, but i also ran exploit (w/o use of group entity) and had no errors due to the implementation of the group entity in the global data structure and the base component. If any problems arise with other studies or whatsoever would be good to know early on.

Changes:

  • implement group entity as globally available class
  • enable overlapping memberships of individuals in groups via a directed network (props to @mensch72 for this idea)
  • adjust implementation

Adding global group entity:
- Added necessary group.py files
- Changed all necessary files (e.g. __init__)
- Study scripts run smoothly (more testing)
- So far no functionality to group (is mostly copy of social system)
Added a possible group_network logic
minor typo and some todos
had error in runner:
TypeError: 'dict_keyiterator' object cannot be interpreted as an integer
[...]
in numpy.random.mtrand.RandomState.choice ValueError: a must be 1-dimensional or an integer
File "C:\Users\bigma\PycharmProjects\pycopancore\pycopancore\model_components\exploit_social_learning\implementation\culture.py", line 42, in social_update
    agent_j = np.random.choice(self.acquaintance_network.neighbors(agent_i))
with (self.acquaintance_network.neighbors(agent_i)) being
<dict_keyiterator object at 0x00000226F0049F90>

FIX:
extracting list from key with list()

agent_j = np.random.choice(list(self.acquaintance_network.neighbors(agent_i)))
…_network. Error while adding group to a culture (group needs to "live" somewhere, similar to cells for individuals that then give memberships to worlds and so on.
Using an directed from Individual to Group Network to handle n to n group memberships.
- Add visualisation of layered group network in run_group_test_seven_dwarfs.py
- Fix minor issues
@zugnachpankow zugnachpankow added enhancement user story marks issues that are formulated in the style of a user story, e.g. "A model composer can..." labels Jun 20, 2022
Adding global group entity:
- Added necessary group.py files
- Changed all necessary files (e.g. __init__)
- Study scripts run smoothly (more testing)
- So far no functionality to group (is mostly copy of social system)
Added a possible group_network logic
minor typo and some todos
…_network. Error while adding group to a culture (group needs to "live" somewhere, similar to cells for individuals that then give memberships to worlds and so on.
- Add visualisation of layered group network in run_group_test_seven_dwarfs.py
- Fix minor issues
…g world, environment and metabolism the group lives in via necessary object world that is passed in study script along with culture: M.Group(culture=culture, world=world)
@zugnachpankow
Copy link
Author

Add some further test: full technical functionality should be given now

- have one or several "leader" :doc:`individuals<individual>`,
of which one may be the dominant leader
- have an "intra" group network between members :doc:`individuals<individual>`
(this feature is not completely implemented yet)
Copy link

Choose a reason for hiding this comment

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

only describe (and explicitly) what feature is implemented and add TODO tags in the code.

(which will typically interact with the network of personal acquaintance between member individuals)
- (this feature is not completely implemented yet)
Copy link

Choose a reason for hiding this comment

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

same here.


- act as the current "elite" in some :doc:`social system<social system>`
- act as the current "elite" in some :doc:`social system<social system>` (this feature is not implemented yet)
Copy link

Choose a reason for hiding this comment

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

and here.


All these relationships may be dynamic.

Finally, a group may...

- be a permanent subgroup of a larger group or :doc:`social system<social system>` *by definition*
(rather than by coincidence, e.g., "scientists" are by definition a subgroup of the group "academics",
and "German workers" may be by definition a subgroup of the social system "Germany")
and "German workers" may be by definition a subgroup of the social system "Germany") - (this feature is not implemented yet)
Copy link

Choose a reason for hiding this comment

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

and here.

@@ -0,0 +1,33 @@
"""Master data model for group."""

"""https://github.com/pik-copan/pycopancore/blob/master/docs/framework_documentation/abstract_level/entity_types/group.rst"""
Copy link

@jnnsbrr jnnsbrr Oct 9, 2023

Choose a reason for hiding this comment

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

do not add absolute url paths to the code.

self._world = None
self.world = world

# self._social_system = None
Copy link

Choose a reason for hiding this comment

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

remove code in comments

Copy link

@jnnsbrr jnnsbrr left a comment

Choose a reason for hiding this comment

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

Hey @zugnachpankow, I did not find any major problems in the code, just some minor style related things.
Fine from my side 🙂

"""cache, depends on self.next_higher_group
and self.next_higher_group.higher_groups"""
# @property # read-only
# def higher_groups(self):
Copy link

Choose a reason for hiding this comment

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

delete commented out code

w._groups.add(self)
self._world = w

# @property
Copy link

Choose a reason for hiding this comment

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

delete commented out code.

readonly=True)
culture = ReferenceVariable("culture", "", type=Culture,
readonly=True)
# higher_groups = SetVariable(
Copy link

Choose a reason for hiding this comment

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

remove commented out code

"""Group entity type mixin implementation class."""

# standard methods:
# TODO: only uncomment when adding custom code!
Copy link

Choose a reason for hiding this comment

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

remove commented out code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement user story marks issues that are formulated in the style of a user story, e.g. "A model composer can..."
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants