#!/usr/bin/env python
"""
Authors: Justin Pusztay, Matt Lubas, Griffin Noe
Filename: latticemain.py
Project: Research for Irina Mazilu, Ph.D.

A main file that runs the Monte Carlo simulation and draws a picture
of the Lattice tree.
"""

import Cayley as cy
import Cayley.graphics as cg
import Cayley.research as cr
temp_d = cr.variable('temp_d',dict,float)

def main():
    print("Enter 'NN', 'TL', 'EI', or 'TM' for nearest neighbors, total " +
          "lattice density, empty interval, or temperature methods.")
    method = input("Method: ").upper()
    x_dir = int(input("What is length? "))
    y_dir = int(input("What is width? "))
    z_dir = int(input("What is height? "))
    loop_yes = 'N'
    if x_dir <= 0 or y_dir <= 0 or z_dir <= 0:
        raise ValueError("Zero or negative is invalid dimension")
    if x_dir+y_dir+z_dir in [x_dir+2,y_dir+2,z_dir+2]:
        loop_yes = input("Loop graph?[Y/N]").upper
    print("\n" + "The default values for alpha, beta, gamma are: \n"
          + "Alpha = 0.5 \n"
          + "Beta = 0.8 \n"
          + "Gamma = 0.2 \n")
Exemple #2
0
"""
Author: Will Hanstedt
Filename: latticevol.py
Project: Research for Irina Mazilu, Ph.D.

A file to run large numbers of trials for the lattice type network.
"""

import Cayley as cy
import Cayley.graphics as cg
import Cayley.research as cr
import xlsxwriter as xl
import time
from math import sqrt

timesteps = cr.variable('timesteps', int)
initial_state = cr.variable('initial_state', str)
node_list = cr.variable('node_list', list, int)
temp_d = cr.variable('temp_d', dict, float)


def simulate(method, model, length, width, height, alpha, beta, gamma, mu, r1,
             r2, trials, k, J):
    """The important one"""
    length_tag = length
    width_tag = width
    height_tag = height
    if model == 'full':
        length += 2
        width += 2
        height += 2
Exemple #3
0
"""
Author: Will Hanstedt
Filename: senatemain.py
Project: Research for Irina Mazilu, Ph.D.

Runs single iterations of Senate network models.
"""

import Cayley.classes as cy
import Cayley.game_theory as cg
import Cayley.research as cr
timesteps = cr.variable('timesteps', int)
import csv


def main():
    print("Enter 'Linear', 'Limited', or 'Complete' for model type.")
    model = input('Model: ').lower()
    const = float(input("Input proportionality constant for beta and phi: "))
    if model == 'limited':
        radius = float(input("Radius of connection: "))
    else:
        radius = 0
    network = cg.Senate(model, const, radius)

    issue = float(input("What is the issue rating? "))
    polarity = issue - 0.5
    const = float(
        input("Input proportionality constant for alpha and gamma: "))
    senate = cy.MonteCarlo(network, 1 / (const * abs(polarity)), 0,
                           1 / (const * abs(polarity)))
Exemple #4
0
"""
Author: Will Hanstedt
Filename: gamevol.py
Project: Research for Irina Mazilu, Ph.D.

A file to run high numbers of simulations for the game theory Senate model.
"""

import csv
import Cayley as cy
import Cayley.game_theory as cgt
import Cayley.research as cr
import xlsxwriter as xl
import time
a_list = cr.variable('a_list',list,float)
b_list = cr.variable('b_list',list,float)
c_list = cr.variable('c_list',list,float)
d_list = cr.variable('d_list',list,float)
issue_list = cr.variable('issue_list',list,float)
timesteps = cr.variable('timesteps',int)

def simulate(ac,bc,cc,dc,kc,issue_rating,trials):
    """The big one"""
    run_time = time.time()
    endcol = xl.utility.xl_col_to_name(timesteps+1)
    name = '%.2fa_%.2fb_%.2fc_%.2fd_%.2fIV' %(ac,bc,cc,dc,issue_rating)
    graph = cgt.Senate('blank',1)
    vote_d = dict()
    real_d = dict()
    imag_d = dict()
    workbook = xl.Workbook(name+'.xlsx')
Exemple #5
0
"""
Author: Will Hanstedt
Filename: latticevol.py
Project: Research for Irina Mazilu, Ph.D.

A file to run large numbers of trials for the lattice type network.
"""

import Cayley as cy
import Cayley.graphics as cg
import Cayley.research as cr
import xlsxwriter as xl
import time
from math import sqrt
timesteps = cr.variable('timesteps',int)
initial_state = cr.variable('initial_state',str)
node_list = cr.variable('node_list',list,int)
temp_d = cr.variable('temp_d',dict,float)


def simulate(method, model, length, width, height, alpha, beta, gamma, mu, r1, r2,trials,k,J):
    """The important one"""
    length_tag = length
    width_tag = width
    height_tag = height
    if model == 'full':
        length += 2
        width += 2
        height += 2
    elif model == 'flat':
        length += 2
Exemple #6
0
"""
Author: Will Hanstedt
Filename: senatemain.py
Project: Research for Irina Mazilu, Ph.D.

Runs single iterations of Senate network models.
"""

import Cayley.classes as cy
import Cayley.game_theory as cg
import Cayley.research as cr
timesteps = cr.variable('timesteps',int)
import csv

def main():
    print("Enter 'Linear', 'Limited', or 'Complete' for model type.")
    model = input('Model: ').lower()
    const = float(input("Input proportionality constant for beta and phi: "))
    if model == 'limited':
        radius = float(input("Radius of connection: "))
    else: radius = 0
    network = cg.Senate(model, const, radius)

    issue = float(input("What is the issue rating? "))
    polarity = issue-0.5
    const = float(input("Input proportionality constant for alpha and gamma: "))
    senate = cy.MonteCarlo(network, 1/(const*abs(polarity)), 0, 1/(const*abs(polarity)))

    print("\n" + "Enter Excel file name \n"
          + "Example: monteCarloData")
    filename = str(input("Filename: "))
Exemple #7
0
#!/usr/bin/env python
"""
Authors: Justin Pusztay, Matt Lubas, Griffin Noe
Filename: latticemain.py
Project: Research for Irina Mazilu, Ph.D.

A main file that runs the Monte Carlo simulation and draws a picture
of the Lattice tree.
"""

import Cayley as cy
import Cayley.graphics as cg
import Cayley.research as cr
temp_d = cr.variable('temp_d', dict, float)


def main():
    print("Enter 'NN', 'TL', 'EI', or 'TM' for nearest neighbors, total " +
          "lattice density, empty interval, or temperature methods.")
    method = input("Method: ").upper()
    x_dir = int(input("What is length? "))
    y_dir = int(input("What is width? "))
    z_dir = int(input("What is height? "))
    loop_yes = 'N'
    if x_dir <= 0 or y_dir <= 0 or z_dir <= 0:
        raise ValueError("Zero or negative is invalid dimension")
    if x_dir + y_dir + z_dir in [x_dir + 2, y_dir + 2, z_dir + 2]:
        loop_yes = input("Loop graph?[Y/N]").upper
    print("\n" + "The default values for alpha, beta, gamma are: \n" +
          "Alpha = 0.5 \n" + "Beta = 0.8 \n" + "Gamma = 0.2 \n")
    custom = input(
Exemple #8
0
"""
Author: Will Hanstedt
Filename: gamevol.py
Project: Research for Irina Mazilu, Ph.D.

A file to run high numbers of simulations for the game theory Senate model.
"""

import csv
import Cayley as cy
import Cayley.game_theory as cgt
import Cayley.research as cr
import xlsxwriter as xl
import time
a_list = cr.variable('a_list', list, float)
b_list = cr.variable('b_list', list, float)
c_list = cr.variable('c_list', list, float)
d_list = cr.variable('d_list', list, float)
issue_list = cr.variable('issue_list', list, float)
timesteps = cr.variable('timesteps', int)


def simulate(ac, bc, cc, dc, kc, issue_rating, trials):
    """The big one"""
    run_time = time.time()
    endcol = xl.utility.xl_col_to_name(timesteps + 1)
    name = '%.2fa_%.2fb_%.2fc_%.2fd_%.2fIV' % (ac, bc, cc, dc, issue_rating)
    graph = cgt.Senate('blank', 1)
    vote_d = dict()
    real_d = dict()
    imag_d = dict()
Exemple #9
0
"""
Author: Will Hanstedt
Filename: senatevol.py
Project: Research for Irina Mazilu Ph.D.

A file to run a large number of Senate network simulations.
"""

import Cayley as cy
import Cayley.game_theory as cg
import Cayley.research as cr
import xlsxwriter as xl
import time
from math import sqrt
timesteps = cr.variable('timesteps', int)
senate_corr = cr.variable('senate_corr',list,str)
radius_of_connection = cr.variable('radius_of_connection', float)
import csv

def simulate(model, const, a_const, radius, issue, trials):
    network = cg.Senate(model, const, radius)
    polarity = issue-0.5
    senate = cy.MonteCarlo(network, 1/(a_const*abs(polarity)), 0, 1/(a_const*abs(polarity)))
    run_time = time.time()
    endcol = xl.utility.xl_col_to_name(timesteps+1)


    bp_tag = "%.1d" %const
    ag_tag = "%.1d" %a_const
    rad_tag = "%.3f" %radius
    IV_tag = "%.2f" %issue