Use a genetic algorithm to evolve populations of bit strings.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

138 lines
2.3 KiB

  1. # Custom functions
  2. define say
  3. $(info [BitEvolver] $1)
  4. endef
  5. define error
  6. $(error [BitEvolver] $1)
  7. endef
  8. define die
  9. $(call error,$1)
  10. $(exit 1)
  11. endef
  12. # Demand BUILD_DIR and BIN_DIR
  13. ifeq ($(BUILD_DIR),)
  14. $(call die,Please provide BUILD_DIR)
  15. endif
  16. ifeq ($(BIN_DIR),)
  17. $(call die,Please provide BIN_DIR)
  18. endif
  19. #
  20. CC=g++
  21. CFLAGS= -c -std=c++11 -Wall -I..
  22. #
  23. OBJECT_PREFIX=BitEvolver_
  24. #
  25. default: default-say
  26. default: release
  27. default:
  28. $(call say,Default target finished)
  29. default-say:
  30. $(call say,Using default target: release)
  31. #
  32. release: release-say
  33. release: CFLAGS+= -O2
  34. release: build-objects
  35. release:
  36. $(call say,Done building RELEASE)
  37. release-say:
  38. $(call say,Building RELEASE)
  39. #
  40. debug: debug-say
  41. debug: CFLAGS+= -g -g3
  42. debug: build-objects
  43. debug:
  44. $(call say,Done building DEBUG)
  45. debug-say:
  46. $(call say,Building DEBUG)
  47. #
  48. build-objects: \
  49. $(BUILD_DIR)/$(OBJECT_PREFIX)Random.o \
  50. $(BUILD_DIR)/$(OBJECT_PREFIX)Population.o \
  51. $(BUILD_DIR)/$(OBJECT_PREFIX)Breeder.o \
  52. $(BUILD_DIR)/$(OBJECT_PREFIX)RouletteWheel.o \
  53. $(BUILD_DIR)/$(OBJECT_PREFIX)Chromosome.o
  54. $(call say,Done building objects)
  55. # Population.o
  56. $(BUILD_DIR)/$(OBJECT_PREFIX)Population.o: \
  57. Population.h \
  58. Population.cpp \
  59. Defines.h Enums.h Includes.h \
  60. Random.h \
  61. Chromosome.h
  62. $(CC) -o $@ \
  63. Population.cpp \
  64. $(CFLAGS)
  65. $(call say,Built $@)
  66. # Breeder.o
  67. $(BUILD_DIR)/$(OBJECT_PREFIX)Breeder.o: \
  68. Breeder.h \
  69. Breeder.cpp \
  70. Defines.h Enums.h Includes.h \
  71. Random.h \
  72. Chromosome.h
  73. $(CC) -o $@ \
  74. Breeder.cpp \
  75. $(CFLAGS)
  76. $(call say,Built $@)
  77. # RouletteWheel.o
  78. $(BUILD_DIR)/$(OBJECT_PREFIX)RouletteWheel.o: \
  79. RouletteWheel.h \
  80. RouletteWheel.cpp \
  81. Defines.h Enums.h Includes.h \
  82. Random.h
  83. $(CC) -o $@ \
  84. RouletteWheel.cpp \
  85. $(CFLAGS)
  86. $(call say,Built $@)
  87. # Chromosome.o
  88. $(BUILD_DIR)/$(OBJECT_PREFIX)Chromosome.o: \
  89. Chromosome.h \
  90. Chromosome.cpp \
  91. Defines.h Enums.h Includes.h \
  92. Random.h
  93. $(CC) -o $@ \
  94. Chromosome.cpp \
  95. $(CFLAGS)
  96. $(call say,Built $@)
  97. # Random.o
  98. $(BUILD_DIR)/$(OBJECT_PREFIX)Random.o: \
  99. Random.h \
  100. Random.cpp \
  101. Defines.h Enums.h Includes.h
  102. $(CC) -o $@ \
  103. Random.cpp \
  104. $(CFLAGS)
  105. $(call say,Built $@)