Skip to content

Instantly share code, notes, and snippets.

@shipof123
Created May 19, 2019 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shipof123/d595bb4f887b58d76360a6407636fd03 to your computer and use it in GitHub Desktop.
Save shipof123/d595bb4f887b58d76360a6407636fd03 to your computer and use it in GitHub Desktop.
#!/bin/python
# Connell Paxton
import plotly as pl
import plotly.graph_objs as go
from sys import argv
from random import randint
crx = [] # [0]
mut = [] # [1]
gav= [] # [2]
avg = [] # [3]
gst = [] # [4]
std = [] # [5]
gmn = [] # [6]
min = [] # [7]
gmx = [] # [8]"""
max = [] # [3] # [9]
i = open(argv[1], "r")
for line in i.readlines():
(_cx, _mu, _ga, _avg, _gs, _s, _gm, _m, _gmx, _max) = line.split()
#crx.append(_cx)
#mut.append(_mu)
avg.append(_avg)
#std.append(_std)
#min.append(_min)
max.append(_max)
_crx = []
_mut = []
for i in range(8):
_crx.append(0.55 + i* 0.05)
for i in range(10):
_mut.append(0.005 + i* 0.001)
mut = _mut
crx = _crx
colors = [
'200, 56, 23',
'45, 0, 122',
'231, 44, 0',
'243, 233, 199',
'256, 0, 0',
'0, 256, 0',
'256, 256, 0',
'256, 0, 256',
'0, 0, 0'
]
mut_avg = [go.Scatter(
x = crx,
y = avg[0:8],
name = "0.005",
line = dict(
color = 'rgb(200, 56, 23)',
dash = 'solid'
)
)]
mut_max = []
data_avg = []
data_max = []
__avg = []
for i in range(8):
temp = mut_avg[i]
temp.name = str(mut[i])
temp.y = avg[i*10:i*10+9]
eval("mut_avg.append(go.Scatter(x=crx,y=temp.y, name=temp.name, line = dict(color='rgb('+colors[i+1]+')')))")
print(temp)
for i in range(9):
temp = mut_avg[i]
name = str(mut[i])
y = max[i*10:i*10+9]
eval("mut_max.append(go.Scatter(x=crx,y=y, name=name, line = dict(color='rgb(' + colors[i]+ ')', dash = 'solid')))")
print(temp)
for i in range(9):
data_avg.append(go.Scatter(mut_avg[i]))
data_max.append(go.Scatter(mut_max[i]))
print len(mut_max)
layout = dict(title = "Fitness vs Crossover & Mutation",
xaxis = dict(title = "Crossover"),
yaxis = dict(title = "Fitness")
)
fig1 = dict(data=data_avg, layout=layout)
fig2 = dict(data=data_max, layout=layout)
pl.offline.plot(fig1, filename=argv[2], auto_open=False)
pl.offline.plot(fig2, filename=argv[3], auto_open=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment