Skip to content

Instantly share code, notes, and snippets.

@dmasad
Last active August 29, 2015 13:55
Show Gist options
  • Save dmasad/8726781 to your computer and use it in GitHub Desktop.
Save dmasad/8726781 to your computer and use it in GitHub Desktop.
Work-in-progress to replicate the 1972 Garbage Can Model of Organizational Choice.
'''
GARBAGE CAN MODEL OF ORGANIZATIONAL CHOICE
Replicating Cohen et al., 1972
Note: Choices are actually *opportunities* for decisions.
'''
import numpy as np
# Model parameters
T = 20 # Time periods
m = 10 # Number of choices
v = 10 # Number of decision-makers
w = 20 # Number of problems
solution_coeff = 0.6 # Solution coefficient
energy_loads = [1.1, 2.2, 3.3]
energy_load = energy_loads[0] # Light load
# Access structure
A = np.ones((w,m)) # A0, unsegmented access
# Decision structure
D = np.ones((v,m)) # Unsegmented decisions, D0
# Energy distribution
E = np.zeros(v)
# E0; Important people -- less energy
for i in range(v):
E[i] = 0.1 + 0.1*(i+1)
# MAIN LOOP
# ========================
# Pre-randomized entry times for choices and problems
# Subtracting 1 to zero-index
choice_order = list(np.array([10, 7, 9, 5, 2, 3, 1, 6, 8]) - 1)
problem_order = list(np.array([8,20,14,16,6,7,15,17,2,13,11,19,4,9,3,12,1,10,5,18]) - 1)
active_choices = []
active_problems = []
energy_required = np.zeros(m)
energy_expended = np.zeros(m)
for t in range(T):
print "Round", t
energy_deficit = energy_required - energy_expended # Apparent energy deficit
energy_allocated = np.zeros(m) # Energy allocated in the current round
# Insert next choices and problems:
if t < len(choice_order):
active_choices += [choice_order[t]]
active_problems += problem_order[2*t:2*(t+1)]
# Associate each problem with the accessible choice closest to completion
problem_to_choice = {}
for p in active_problems:
accessible_choices = {c: energy_deficit[c]
for c in active_choices
if A[p,c]==1}
if len(accessible_choices) > 0:
closest_choice = min(accessible_choices,
key=lambda x: accessible_choices[x])
problem_to_choice[p] = closest_choice
# Associate each agent with the accesible choice closest to completion:
for a in range(v):
accessible_choices = {c: energy_deficit[c]
for c in active_choices
if D[a,c]==1}
if len(accessible_choices) > 0:
closest_choice = min(accessible_choices,
key=lambda x: accessible_choices[x])
energy_allocated[closest_choice] += E[a] * solution_coeff
# Update decision energy requirements
energy_required = np.zeros(m)
for c in range(m):
for p, c in problem_to_choice.items():
energy_required[c] += energy_load
for c in active_choices:
if energy_expended[c] + energy_allocated[c] >= energy_required[c]:
print "Choice", c, "resolved!"
active_choices.remove(c)
for problem, choice in problem_to_choice.items():
if choice == c:
print "Problem", problem, "solved!"
active_problems.remove(problem)
energy_expended += energy_allocated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment