Il Sat, 07 Mar 2009 00:05:53 -0200, Gabriel Genellina ha scritto:
En Fri, 06 Mar 2009 21:31:01 -0200, mattia ger...@gmail.com escribió:
Thanks, I've found another solution here:
http://www.obitko.com/tutorials/
genetic-algorithms/selection.php
so here is my implementation:
def
mattia wrote:
Il Sat, 07 Mar 2009 00:05:53 -0200, Gabriel Genellina ha scritto:
En Fri, 06 Mar 2009 21:31:01 -0200, mattia ger...@gmail.com escribió:
Thanks, I've found another solution here:
http://www.obitko.com/tutorials/
genetic-algorithms/selection.php
so here is my implementation:
Lie Ryan wrote:
mattia wrote:
Yes, sorry, I have to recycle! But how about this:
rw = [[2,4], [4,5,6],[5,5]]
rw += [[1,1]]*2
rw
[[2, 4], [4, 5, 6], [5, 5], [1, 1], [1, 1]]
How can I recicle in this way using append?
Not .append() but .extend()
Whether you use
items += [item]*N
or
Gabriel Genellina wrote:
Imagine you're working with someone side by side. You write a note in a
piece of paper, put it into an envelope, and hand it to your co-worker. He
opens the envelope, throws it away, takes the note and files it inside a
folder right at the end. And you do this over
On Sun, 2009-03-08 at 15:49 +1100, Steven D'Aprano wrote:
If the environmental costs of recycling something are worse than the
environmental costs of throwing it away and making a new one, then
recycling that object is actually harmful. But I digress.
Unless you live in a country that imports
Hi, I'm new to python, and as the title says, can I improve this snippet
(readability, speed, tricks):
def get_fitness_and_population(fitness, population):
return [(fitness(x), x) for x in population]
def selection(fitness, population):
'''
Select the parent chromosomes from a
On Fri, Mar 6, 2009 at 2:19 AM, mattia ger...@gmail.com wrote:
Hi, I'm new to python, and as the title says, can I improve this snippet
(readability, speed, tricks):
def get_fitness_and_population(fitness, population):
return [(fitness(x), x) for x in population]
def selection(fitness,
Il Fri, 06 Mar 2009 10:19:22 +, mattia ha scritto:
Hi, I'm new to python, and as the title says, can I improve this snippet
(readability, speed, tricks):
def get_fitness_and_population(fitness, population):
return [(fitness(x), x) for x in population]
def selection(fitness,
On Fri, Mar 6, 2009 at 3:07 AM, mattia ger...@gmail.com wrote:
Great, the for statement has not to deal with fap anymore, but with
another sequence, like this:
def get_roulette_wheel(weight_value_pairs):
roulette_wheel = []
for weight, value in weight_value_pairs:
Il Fri, 06 Mar 2009 03:43:22 -0800, Chris Rebert ha scritto:
On Fri, Mar 6, 2009 at 3:07 AM, mattia ger...@gmail.com wrote:
Great, the for statement has not to deal with fap anymore, but with
another sequence, like this:
def get_roulette_wheel(weight_value_pairs):
roulette_wheel = []
On Fri, Mar 6, 2009 at 3:52 AM, mattia ger...@gmail.com wrote:
Il Fri, 06 Mar 2009 03:43:22 -0800, Chris Rebert ha scritto:
On Fri, Mar 6, 2009 at 3:07 AM, mattia ger...@gmail.com wrote:
Great, the for statement has not to deal with fap anymore, but with
another sequence, like this:
def
mattia wrote:
Hi, I'm new to python, and as the title says, can I improve this snippet
(readability, speed, tricks):
def get_fitness_and_population(fitness, population):
return [(fitness(x), x) for x in population]
def selection(fitness, population):
'''
Select the parent
Chris Rebert c...@rebertia.com writes:
for i in range(len(fap)):
selected_population.append(choice(rw))
for i in range(len(something)) is a bit of a code smell. You could
instead say:
selected_population.extend(choice(rw) for x in fap)
The unused x is also a slight code smell,
Il Fri, 06 Mar 2009 14:06:14 +0100, Peter Otten ha scritto:
mattia wrote:
Hi, I'm new to python, and as the title says, can I improve this
snippet (readability, speed, tricks):
def get_fitness_and_population(fitness, population):
return [(fitness(x), x) for x in population]
def
mattia wrote:
Il Fri, 06 Mar 2009 14:06:14 +0100, Peter Otten ha scritto:
mattia wrote:
Hi, I'm new to python, and as the title says, can I improve this
snippet (readability, speed, tricks):
def get_fitness_and_population(fitness, population):
return [(fitness(x), x) for x in
Il Fri, 06 Mar 2009 22:28:00 +0100, Peter Otten ha scritto:
mattia wrote:
Il Fri, 06 Mar 2009 14:06:14 +0100, Peter Otten ha scritto:
mattia wrote:
Hi, I'm new to python, and as the title says, can I improve this
snippet (readability, speed, tricks):
def
i have not been following this discussion in detail, so someone may have
already explained this, but it should not be necessary to actually
construct the roulette wheel to select values from it. what you are doing
is selecting from a list where the there are different probabilities of
selecting
mattia wrote:
Here is my last shot, where I get rid of all the old intermediate
functions:
def selection(fitness, population):
lp = len(population)
roulette_wheel = []
for x in population:
roulette_wheel += [x]*fitness(x)
selected_population = [[]]*lp
understood correctly).
more precisely, i think you can adapt the trick used to select a line at
random from a file by scanning the file just once.
sorry if i have misunderstood,
andrew
Well, I believe that using the right distribution I can for sure find a
better way for doing the roulette
Il Fri, 06 Mar 2009 14:13:47 -0800, Scott David Daniels ha scritto:
mattia wrote:
Here is my last shot, where I get rid of all the old intermediate
functions:
def selection(fitness, population):
lp = len(population)
roulette_wheel = []
for x in population:
En Fri, 06 Mar 2009 21:31:01 -0200, mattia ger...@gmail.com escribió:
Thanks, I've found another solution here:
http://www.obitko.com/tutorials/
genetic-algorithms/selection.php
so here is my implementation:
def get_fap(fitness, population):
fap = []
total = 0
for x in
Gabriel Genellina gagsl-...@yahoo.com.ar writes:
for x in population:
f = fitness(x)
fap += [(f, x)]
total += f
return sorted(fap, reverse=True), total
...
Environmentally friendly Pythoneers avoid using discardable
intermediate envelopes:
On Mon, 30 May 2005 14:05:36 +0200, Magnus Lycka wrote:
Steven D'Aprano wrote:
print is a statement, not a function. The brackets are syntactically
correct, but pointless. Remove them.
...
On Sat, 28 May 2005 13:24:19 +, Michael wrote:
while( newNS ):
Guido (our Benevolent
Steven D'Aprano wrote:
print is a statement, not a function. The brackets are syntactically
correct, but pointless. Remove them.
...
On Sat, 28 May 2005 13:24:19 +, Michael wrote:
while( newNS ):
Guido (our Benevolent Dictator For Life and creator of Python) hates
seeing whitespace
On Sat, 28 May 2005 13:24:19 +, Michael wrote:
Hi,
I'm fairly new at Python, and have the following code that works but isn't
very concise, is there a better way of writing it?? It seems much more
lengthy than python code i have read. :-)
(takes a C++ block and extracts the
Steven D'Aprano wrote:
Guido (our Benevolent Dictator For Life and creator of Python) hates
seeing whitespace next to parentheses. I agree with him. while(newNS)
good, while( newNS ) bad.
while is a statement, so while(newNS) is bad in more than one way.
/F
--
Hi,
I don't know very well what you want to do, but if you want to parse
c++, take a look at GCC-XML python (http://www.gccxml.org) and the
python binding (http://pygccxml.sourceforge.net/). These tools
translate c++ code to XML. Then, you can parse xml with your favorite
tools and find the
On 5/29/05, Cyril BAZIN [EMAIL PROTECTED] wrote:
Hi,
I don't know very well what you want to do, but if you want to parse c++,
take a look at GCC-XML python (http://www.gccxml.org) and the python
binding (http://pygccxml.sourceforge.net/). These tools
translate c++ code to XML. Then, you
Michael wrote:
I'm fairly new at Python, and have the following code that works but
isn't very concise, is there a better way of writing it?? It seems
much more lengthy than python code i have read. :-)
(takes a C++ block and extracts the namespaces from it)
Yes, there is a better way to
Hi,
I'm fairly new at Python, and have the following code that works but isn't
very concise, is there a better way of writing it?? It seems much more
lengthy than python code i have read. :-)
(takes a C++ block and extracts the namespaces from it)
def ExtractNamespaces(data):
30 matches
Mail list logo