Changeset 1079
- Timestamp:
- 02/17/21 14:32:44 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/FramsticksCLI.py
r1076 r1079 11 11 12 12 class FramsticksCLI: 13 """Runs Framsticks CLI (command-line) executable and communicates with it using standard input and output. 13 """Note: instead of this class, you should use the simpler, faster, and more reliable FramsticksLib.py. 14 15 This class runs Framsticks CLI (command-line) executable and communicates with it using standard input and output. 14 16 You can perform basic operations like mutation, crossover, and evaluation of genotypes. 15 17 This way you can perform evolution controlled by python as well as access and manipulate genotypes. … … 21 23 22 24 PRINT_FRAMSTICKS_OUTPUT: bool = False # set to True for debugging 23 DETERMINISTIC: bool = False # set to True to have the same results on each run25 DETERMINISTIC: bool = False # set to True to have the same results in each run 24 26 25 27 GENO_SAVE_FILE_FORMAT = Enum('GENO_SAVE_FILE_FORMAT', 'NATIVEFRAMS RAWGENO') # how to save genotypes … … 236 238 """ 237 239 Returns: 238 The genotype of the offspring. Empty stringif the crossing over failed.240 The genotype of the offspring. self.GENOTYPE_INVALID if the crossing over failed. 239 241 """ 240 242 files = self.__runCommand(self.CROSSOVER_CMD, [genotype_parent1, genotype_parent2], self.CROSSOVER_FILE, self.GENO_SAVE_FILE_FORMAT["RAWGENO"]) … … 302 304 # - "vectorize" crossover so that many genotypes is handled in one call. Even better, use .so/.dll direct communication to CLI 303 305 # - use threads for non-blocking reading from frams' stdout and thus not relying on specific strings printed by frams 304 # - a pool of binaries run at the same time, balance load - in particular evaluation306 # - a pool of binaries running simultaneously, balance load - in particular evaluation 305 307 # - if we read genotypes in "org:" format anywhere: import https://pypi.org/project/framsreader and use it if successful, 306 308 # if not then print a message "framsreader not available, using simple internal method to save a genotype" and proceed as it is now. … … 317 319 parent2 = parent1 318 320 MUTATE_COUNT = 10 319 for x in range(MUTATE_COUNT): # example of a chain of 20 mutations321 for x in range(MUTATE_COUNT): # example of a chain of 10 mutations 320 322 parent2 = framsCLI.mutate([parent2])[0] 321 323 print("\tParent1 (mutated simplest):", parent1)
Note: See TracChangeset
for help on using the changeset viewer.