Skip to content

Commit

Permalink
push reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
mzargham committed May 31, 2019
1 parent dbfc657 commit 8e75fe0
Show file tree
Hide file tree
Showing 10 changed files with 3,636 additions and 240 deletions.
Binary file modified __pycache__/conviction_system_logic.cpython-36.pyc
Binary file not shown.
3,292 changes: 3,065 additions & 227 deletions conviction_cadCAD.ipynb

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions conviction_system_logic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from conviction_helpers import get_nodes_by_type, trigger_threshold
from conviction_helpers import get_nodes_by_type
#import networkx as nx
from scipy.stats import expon, gamma

Expand Down Expand Up @@ -31,9 +31,12 @@ def gen_new_participant(network, new_participant_holdings):
return network


scale_factor = 1000

def gen_new_proposal(network, funds, supply, total_funds, trigger_func):

def gen_new_proposal(network, funds, supply, trigger_func, scale_factor = 1.0/10):



j = len([node for node in network.nodes])
network.add_node(j)
network.nodes[j]['type']="proposal"
Expand All @@ -42,7 +45,7 @@ def gen_new_proposal(network, funds, supply, total_funds, trigger_func):
network.nodes[j]['status']='candidate'
network.nodes[j]['age']=0

rescale = scale_factor*funds/total_funds
rescale = funds*scale_factor
r_rv = gamma.rvs(3,loc=0.001, scale=rescale)
network.node[j]['funds_requested'] = r_rv

Expand Down Expand Up @@ -94,10 +97,10 @@ def driving_process(params, step, sL, s):

sentiment = s['sentiment']
funds = s['funds']
scale_factor = 1+4000*sentiment**2
scale_factor = funds*sentiment**2/10000

#this shouldn't happen but expon is throwing domain errors
if scale_factor > 1:
if sentiment>.4:
funds_arrival = expon.rvs(loc = 0, scale = scale_factor )
else:
funds_arrival = 0
Expand All @@ -111,14 +114,12 @@ def driving_process(params, step, sL, s):
#Mechanisms for updating the state based on driving processes
##---
def update_network(params, step, sL, s, _input):

print(params)
print(type(params))


network = s['network']
funds = s['funds']
supply = s['supply']
trigger_func = params['trigger_func']
#print(trigger_func)

new_participant = _input['new_participant'] #T/F
new_proposal = _input['new_proposal'] #T/F
Expand All @@ -128,7 +129,7 @@ def update_network(params, step, sL, s, _input):
network = gen_new_participant(network, new_participant_holdings)

if new_proposal:
network= gen_new_proposal(network,funds,supply )
network= gen_new_proposal(network,funds,supply,trigger_func )

#update age of the existing proposals
proposals = get_nodes_by_type(network, 'proposal')
Expand Down Expand Up @@ -260,14 +261,15 @@ def trigger_function(params, step, sL, s):
supply = s['supply']
proposals = get_nodes_by_type(network, 'proposal')
tmin = params['tmin']
trigger_func = params['trigger_func']

accepted = []
triggers = {}
for j in proposals:
if network.nodes[j]['status'] == 'candidate':
requested = network.nodes[j]['funds_requested']
age = network.nodes[j]['age']
threshold = trigger_threshold(requested, funds, supply)
threshold = trigger_func(requested, funds, supply)
if age > tmin:
conviction = network.nodes[j]['conviction']
if conviction >threshold:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8e75fe0

Please sign in to comment.