All Samples(20) | Call(16) | Derive(0) | Import(4)
Triangular distribution. Continuous distribution bounded by given lower and upper limits, and having a given mode value in-between. http://en.wikipedia.org/wiki/Triangular_distribution
src/s/h/shedskin-HEAD/examples/genetic2.py shedskin(Download)
#!/usr/bin/env python # placed in the public domain by Stavros Korokithakis import time import copy from random import randrange, randint, seed, random, choice, triangular
iters = int(Pool.population_size * 0.6)
for counter in range(0, iters, 2):
# Perform rank roulette selection.
father = self.population[int(triangular(0, iters, 0))]
mother = self.population[int(triangular(0, iters, 0))]
children = self.crossover(father, mother)
children[0].mutate()
src/m/y/mysql.integra.dbfiller-HEAD/simulation.py mysql.integra.dbfiller(Download)
import calendar import datetime from datetime import datetime, timedelta, date from random import randint, gauss, triangular import MySQLdb from helpers.XMLparsers import * from helpers import *
def __addUserHasOperation (self, user, day, shift) :
"""Metoda dodająca do bazy log operacji użytkownika w ciągu jednej zmiany."""
cur = self.__connection.cursor()
# wyznaczamy czas pierwszej operacji (początek zmiany + od -30 do 60 min (rozkład trójkątny(-30, 60, 0) ) )
latetime = timedelta(seconds=triangular(-30*60,60*60, 0) ) #czas spóznienia
starttime = datetime(day.year, day.month, day.day, SHIFTS[shift -1][0]) + latetime
src/p/g/pgaf-HEAD/trunk/genetics/population.py pgaf(Download)
from copy import deepcopy from genetics.creature import creature from genetics.gene import gene from random import triangular from genetics.reproduction import asex_gauss, asex_uniform, sex_gauss class Population:
def get(self):
"""Get a creature [to reproduce], weighted towards higher fitness"""
if len(self.all) < self.pool:
return asex_uniform(self.all[0])
with self.pad:
father = self.all[int(triangular(0, self.pool-1, 0))]
src/p/g/pgaf-HEAD/genetics/population.py pgaf(Download)
from copy import deepcopy from genetics.creature import creature from genetics.gene import gene from random import triangular from genetics.reproduction import asex_gauss, asex_uniform, sex_gauss class Population:
def get(self):
"""Get a creature [to reproduce], weighted towards higher fitness"""
if len(self.all) < self.pool:
return asex_uniform(self.all[0])
with self.pad:
father = self.all[int(triangular(0, self.pool-1, 0))]