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

Create initial distribution range for opinion models #249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ndlib/models/opinions/ARWHKModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ def __init__(self, graph):
"optional": True,
"default": 0,
},
"init_dist_lower" : {
"descr": "The lower bound of the initial distribution",
"range": [-1, 1],
"optional": True,
"default": -1,
},
"init_dist_upper" : {
"descr": "The upper bound of the initial distribution",
"range": [-1, 1],
"optional": True,
"default": 1,
}
},
"edges": {
"weight": {
Expand Down Expand Up @@ -98,7 +110,7 @@ def set_initial_status(self, configuration=None):

# set node status
for node in self.status:
self.status[node] = random.uniform(-1, 1)
self.status[node] = np.random.uniform(self.params["model"]["init_dist_lower"], self.params["model"]["init_dist_upper"])
self.initial_status = self.status.copy()

"""
Expand Down
14 changes: 13 additions & 1 deletion ndlib/models/opinions/AlgorithmicBiasMediaModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ def __init__(self, graph, seed=None):
"range": [0, self.graph.number_of_nodes],
"optional": False,
},
"init_dist_lower" : {
"descr": "The lower bound of the initial distribution",
"range": [0, 1],
"optional": True,
"default": 0,
},
"init_dist_upper" : {
"descr": "The upper bound of the initial distribution",
"range": [0, 1],
"optional": True,
"default": 1,
}
},
"nodes": {},
"edges": {},
Expand All @@ -76,7 +88,7 @@ def set_initial_status(self, configuration=None):

# set node status
for node in self.status:
self.status[node] = np.random.random_sample()
self.status[node] = np.random.uniform(self.params["model"]["init_dist_lower"], self.params["model"]["init_dist_upper"])
self.initial_status = self.status.copy()

### Initialization numpy representation
Expand Down
14 changes: 13 additions & 1 deletion ndlib/models/opinions/AlgorithmicBiasModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ def __init__(self, graph, seed=None):
"range": [0, 100],
"optional": False,
},
"init_dist_lower" : {
"descr": "The lower bound of the initial distribution",
"range": [0, 1],
"optional": True,
"default": 0,
},
"init_dist_upper" : {
"descr": "The upper bound of the initial distribution",
"range": [0, 1],
"optional": True,
"default": 1,
}
},
"nodes": {},
"edges": {},
Expand All @@ -69,7 +81,7 @@ def set_initial_status(self, configuration=None):

# set node status
for node in self.status:
self.status[node] = np.random.random_sample()
self.status[node] = np.random.uniform(self.params["model"]["init_dist_lower"], self.params["model"]["init_dist_upper"])
self.initial_status = self.status.copy()

### Initialization numpy representation
Expand Down
14 changes: 13 additions & 1 deletion ndlib/models/opinions/CognitiveOpDynModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ def __init__(self, graph, seed=None):
"range": [0, 1],
"optional": False,
},
"init_dist_lower" : {
"descr": "The lower bound of the initial distribution",
"range": [0, 1],
"optional": True,
"default": 0,
},
"init_dist_upper" : {
"descr": "The upper bound of the initial distribution",
"range": [0, 1],
"optional": True,
"default": 1,
}
},
"nodes": {},
"edges": {},
Expand All @@ -97,7 +109,7 @@ def set_initial_status(self, configuration=None):

# set node status
for node in self.status:
self.status[node] = np.random.random_sample()
self.status[node] = np.random.uniform(self.params["model"]["init_dist_lower"], self.params["model"]["init_dist_upper"])
self.initial_status = self.status.copy()

# set new node parameters
Expand Down
14 changes: 13 additions & 1 deletion ndlib/models/opinions/HKModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ def __init__(self, graph):
"descr": "Bounded confidence threshold",
"range": [0, 1],
"optional": False,
},
"init_dist_lower" : {
"descr": "The lower bound of the initial distribution",
"range": [-1, 1],
"optional": True,
"default": -1,
},
"init_dist_upper" : {
"descr": "The upper bound of the initial distribution",
"range": [-1, 1],
"optional": True,
"default": 1,
}
},
"edges": {},
Expand All @@ -46,7 +58,7 @@ def set_initial_status(self, configuration=None):

# set node status
for node in self.status:
self.status[node] = random.uniform(-1, 1)
self.status[node] = random.uniform(self.params["model"]["init_dist_lower"], self.params["model"]["init_dist_upper"])
self.initial_status = self.status.copy()

def clean_initial_status(self, valid_status=None):
Expand Down
14 changes: 13 additions & 1 deletion ndlib/models/opinions/WHKModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ def __init__(self, graph):
"optional": True,
"default": 0,
},
"init_dist_lower" : {
"descr": "The lower bound of the initial distribution",
"range": [-1, 1],
"optional": True,
"default": -1,
},
"init_dist_upper" : {
"descr": "The upper bound of the initial distribution",
"range": [-1, 1],
"optional": True,
"default": 1,
}
},
"edges": {
"weight": {
Expand Down Expand Up @@ -90,7 +102,7 @@ def set_initial_status(self, configuration=None):

# set node status
for node in self.status:
self.status[node] = random.uniform(-1, 1)
self.status[node] = random.uniform(self.params["model"]["init_dist_lower"], self.params["model"]["init_dist_upper"])
self.initial_status = self.status.copy()

"""
Expand Down