This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#My first Genetic Algorithm | |
#By David Evans | |
#05/29/2016 | |
import random as rnd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from genotype import Genotype | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
momAndDad = np.random.choice(genotypeList, 2, p=probabilityDistribution) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#My first Genetic Algorithm | |
#By David Evans | |
#05/29/2016 | |
import random as rnd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from genotype import Genotype | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random as rnd | |
#My gene class | |
class Genotype: | |
def __init__(self, fitness_test, parent1, parent2): | |
#If either parent chromosome starts off as null than make this chromosome a | |
#random collection of 1s and 0s ten digits long | |
if(parent1 == None or parent2 == None): | |
self.chromosome = ''.join(rnd.choice('01') for i in range(10)) | |
self.chromosomeList = list(self.chromosome) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The stuff in our TODO section, we've also added the variables wind_speed and amplitude to the variable list | |
//at the top of the application. | |
frames_per_second = 24; | |
frames_in_animation = 34; | |
frame = 0; | |
float wind_speed = llWind().x | |
if(wind_speed > 25.0){ | |
amplitude = PI / 2.0; //25 * PI /50; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//As a good programming practice, let's instantiate all of our variables out here so they're available | |
//to us in the scopes below. | |
float frames_per_second; | |
integer frames_in_animation; | |
integer frame; | |
default | |
{ | |
state_entry() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def groupfinder(userid, request): | |
userGroup = request.db.query(UserGroup.name).join(RegisteredUser, UserGroup.id == RegisteredUser.group_id).\ | |
group_by(UserGroup.id).filter(UserGroup.id == userid).first() | |
if(userGroup): | |
return userGroup | |
else: | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#What we do when we save the user state | |
if(user and crypto_manager.check(user.getPassword(), password)): | |
headers = remember(request, user.id) | |
self.request.session.flash("You have successfully logged in to your account.", "success") | |
return HTTPFound(location=came_from, headers=headers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psycopg2 | |
import pgdb | |
from py2neo import authenticate, Graph, Node, Relationship | |
import os | |
p_connection = psycopg2.connect(host = 'localhost', | |
user='USER', | |
password='SECRET', | |
dbname='lexinomicon') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lxml import etree | |
from py2neo import authenticate, Graph, Node | |
import re | |
import time | |
import sys | |
import os | |
def save_definitions(filNum, gdb, start_page = 1): | |
#For the given file in the xml file list | |
filLoc = '../../../wikitionary_files/enwikitionary_%s.xml'%filNum |