Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

ash7

proc genrand {max num} {
set result [list] for {set i 0} {$i < $num} {incr i} {
lappend result [expr {int($max * rand())}] }
return $result
}
proc generation {name gen} {
puts “0eneration: $gen0
}
proc evaluate {name entity} {
global goal
set result [expr {100 * 10}] for {set i 0} {$i < 10} {incr i} {
incr result [expr {−1 * abs([lindex $goal $i] − [lindex $entity $i])}] }
return $result
}
proc seed {name entity} {
set seed [genrand 100 10] return $seed
}
proc adapt {name entity} {
return $entity
}
proc mutate {name entity} {
lset entity [genrand 10 1] [genrand 100 1] return $entity
}
proc crossover {name entity1 entity2} {
set cross [genrand 10 1] set child1 [concat [lrange $entity1 0 $cross−1] [lrange $entity2 $cross end]] set child2 [concat [lrange $entity2 0 $cross−1] [lrange $entity1 $cross end]] return [list $child1 $child2] }

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.