Changeset 1158 for framspy


Ignore:
Timestamp:
10/01/21 23:40:49 (3 years ago)
Author:
Maciej Komosinski
Message:

Cosmetic/minor improvements

Location:
framspy
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • framspy/deterministic.sim

    r1149 r1158  
    1010
    1111sim_params:
     12# no need to evaluate a creature many times:
     13evalcount:1
    1214# always central location in the world:
    1315placement:1
    14 # no need to evaluate many times:
    15 evalcount:1
    1616# no random initialization of state in neurons:
    1717randinit:0.0
  • framspy/frams-test-props.py

    r1151 r1158  
     1"""An example of iterating through the properties of an ExtValue object and printing their characteristics."""
     2
    13import frams
    24import sys
     
    46frams.init(*(sys.argv[1:]))
    57
    6 def printSingleProperty(v,p):
    7         print('  %s "%s" type="%s" flags=%d group=%d help="%s"' % (v._propId(p),v._propName(p),v._propType(p),v._propFlags(p),v._propGroup(p),v._propHelp(p)))
     8
     9def printSingleProperty(v, p):
     10        print(' * %s "%s" type="%s" flags=%d group=%d help="%s"' % (v._propId(p), v._propName(p), v._propType(p), v._propFlags(p), v._propGroup(p), v._propHelp(p)))
    811
    912
    1013def printFramsProperties(v):
    11         N=v._propCount()
    12         G=v._groupCount()
    13         if G<2:
    14                
    15                 #no groups, simply iterate all props
    16                
    17                 print("'%s' has %d properties" % (v._class(),v._propCount()))
     14        N = v._propCount()
     15        G = v._groupCount()
     16        print("======================= '%s' has %d properties in %d group(s). =======================" % (v._class(), N, G))
     17        if G < 2:
     18                # No groups, simply iterate all properties
    1819                for p in range(v._propCount()):
    19                         printSingleProperty(v,p)
    20                
     20                        printSingleProperty(v, p)
    2121        else:
    22                
    23                 #iterate through groups and iterate all props in a group.
    24                 #why the distinction?
    25                 #first, just to show there are two ways. there is always at least one
    26                 #group so you can always get all props by iterating the group.
    27                 #second, groups actually do not exist as collections. iterating in
    28                 #groups works by checking all properties on each iteration and
    29                 #testing which one is the m-th property of the group.
    30                 #these inefficient _memberCount() and _groupMember() are provided
    31                 #for the sake of completeness but don't use them without good reason ;-)
    32                
    33                 print("'%s' has %d properties in %d group(s)" % (v._class(),v._propCount(),v._groupCount()))
     22                # Iterate through groups and iterate all props in a group.
     23                # Why the distinction?
     24                # First, just to show there are two ways. There is always at least one
     25                # group so you can always get all properties by iterating the group.
     26                # Second, groups actually do not exist as collections. Iterating in
     27                # groups works by checking all properties on each iteration and
     28                # testing which one is the m-th property of the group!
     29                # So these inefficient _memberCount() and _groupMember() are provided
     30                # for the sake of completeness, but don't use them without a good reason ;-)
    3431                for g in range(G):
    35                         print('\n=========== Group #%d: %s ==========' % (g,v._groupName(g)))
     32                        print('\n------------------- Group #%d: %s -------------------' % (g, v._groupName(g)))
    3633                        for m in range(v._memberCount(g)):
    37                                 p=v._groupMember(g,m)
    38                                 printSingleProperty(v,p)
    39                         print('========================\n')
    40 
    41 
     34                                p = v._groupMember(g, m)
     35                                printSingleProperty(v, p)
     36        print('\n\n')
    4237
    4338
    4439printFramsProperties(frams.World)
    45                
    46 printFramsProperties(frams.GenePools[0].add('X'))
     40
     41printFramsProperties(frams.GenePools[0].add('X'))  # add('X') returns a Genotype object
  • framspy/run-evolalg-examples.cmd

    r1149 r1158  
    77
    88
    9 rem simple one-criterion evolution
     9
     10rem simple one-criterion evolution from minimalistic example source (examples.standard)
    1011python -m evolalg.examples.standard          -path %DIR_WITH_FRAMS_LIBRARY%   -opt numneurons
    1112
    1213
    13 rem "chaining" .sim files, subsequent files overwrite selected parameters
     14rem as above but "chaining" .sim files, subsequent files overwrite selected parameters
    1415python -m evolalg.examples.standard          -path %DIR_WITH_FRAMS_LIBRARY%   -sim eval-allcriteria.sim;deterministic.sim;sample-period-longest.sim    -opt velocity
    1516
    1617
    17 rem hard limit on the number of parts
     18rem simple one-criterion evolution but more options available in examples.niching_novelty, here: hard limit on the number of parts and debugging messages
    1819python -m evolalg.examples.niching_novelty   -path %DIR_WITH_FRAMS_LIBRARY%   -opt velocity   -max_numparts 6   -debug
    1920
  • framspy/sample-period-longest.sim

    r1149 r1158  
    1 # Extremely high "performance sampling period" (likely longer than lifespan) in the first population
    2 # to measure distance and velocity rectilinearly. Such a long period results in two sampling events: at birth and at death.
     1# Extremely high "performance sampling period" in the first population to measure distance and velocity rectilinearly.
     2# Such a long period (likely longer than lifespan) results in two sampling events: at birth and at death.
    33#
    44# Before loading this file, load base settings, e.g. "eval-allcriteria.sim".
Note: See TracChangeset for help on using the changeset viewer.