nudge 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +23 -0
- data/VERSION +1 -0
- data/_spikes/couch_document_spike.rb +24 -0
- data/_spikes/nested_parsing/nested.rb +0 -0
- data/_spikes/nested_parsing/nested.treetop +6 -0
- data/_spikes/nudgeview/init.rb +19 -0
- data/_spikes/nudgeview/public/javascripts/app.js +12 -0
- data/_spikes/nudgeview/public/javascripts/jquery.js +4376 -0
- data/_spikes/nudgeview/public/javascripts/jquery.svg.js +1325 -0
- data/_spikes/nudgeview/views/index.erb +18 -0
- data/_spikes/nudgeview/views/index.haml +8 -0
- data/_spikes/simplestWeb/simplest.rb +44 -0
- data/_spikes/simplestWeb/views/main.erb +19 -0
- data/_spikes/sketches/nudgecode_spike.rb +146 -0
- data/_spikes/sketches/searchDSL_spike.rb +25 -0
- data/_spikes/sketches/search_operator_sketch_spike.txt +287 -0
- data/_spikes/sketches/searchspace_spike.rb +96 -0
- data/_spikes/symbolic_regression/activate.rb +35 -0
- data/_spikes/symbolic_regression/config/environment.rb +340 -0
- data/_spikes/symbolic_regression/config/environments/deployment.rb +0 -0
- data/_spikes/symbolic_regression/config/environments/development.rb +0 -0
- data/_spikes/symbolic_regression/experiment/objectives/programLength.rb +2 -0
- data/_spikes/symbolic_regression/experiment/objectives/summedSquaredError.rb +2 -0
- data/_spikes/symbolic_regression/lib/tasks/run.rake +0 -0
- data/doc/classes/BlockNode.html +146 -0
- data/doc/classes/BlockNode.src/M000246.html +18 -0
- data/doc/classes/BoolAndInstruction.html +218 -0
- data/doc/classes/BoolAndInstruction.src/M000003.html +15 -0
- data/doc/classes/BoolAndInstruction.src/M000004.html +16 -0
- data/doc/classes/BoolAndInstruction.src/M000005.html +15 -0
- data/doc/classes/BoolAndInstruction.src/M000006.html +15 -0
- data/doc/classes/BoolEqualQInstruction.html +218 -0
- data/doc/classes/BoolEqualQInstruction.src/M000015.html +15 -0
- data/doc/classes/BoolEqualQInstruction.src/M000016.html +16 -0
- data/doc/classes/BoolEqualQInstruction.src/M000017.html +15 -0
- data/doc/classes/BoolEqualQInstruction.src/M000018.html +15 -0
- data/doc/classes/BoolFromFloatInstruction.html +218 -0
- data/doc/classes/BoolFromFloatInstruction.src/M000071.html +15 -0
- data/doc/classes/BoolFromFloatInstruction.src/M000072.html +15 -0
- data/doc/classes/BoolFromFloatInstruction.src/M000073.html +15 -0
- data/doc/classes/BoolFromFloatInstruction.src/M000074.html +15 -0
- data/doc/classes/BoolFromIntInstruction.html +218 -0
- data/doc/classes/BoolFromIntInstruction.src/M000067.html +15 -0
- data/doc/classes/BoolFromIntInstruction.src/M000068.html +15 -0
- data/doc/classes/BoolFromIntInstruction.src/M000069.html +15 -0
- data/doc/classes/BoolFromIntInstruction.src/M000070.html +15 -0
- data/doc/classes/BoolNotInstruction.html +218 -0
- data/doc/classes/BoolNotInstruction.src/M000019.html +15 -0
- data/doc/classes/BoolNotInstruction.src/M000020.html +15 -0
- data/doc/classes/BoolNotInstruction.src/M000021.html +15 -0
- data/doc/classes/BoolNotInstruction.src/M000022.html +15 -0
- data/doc/classes/BoolOrInstruction.html +218 -0
- data/doc/classes/BoolOrInstruction.src/M000007.html +15 -0
- data/doc/classes/BoolOrInstruction.src/M000008.html +16 -0
- data/doc/classes/BoolOrInstruction.src/M000009.html +15 -0
- data/doc/classes/BoolOrInstruction.src/M000010.html +15 -0
- data/doc/classes/BoolRandomInstruction.html +218 -0
- data/doc/classes/BoolRandomInstruction.src/M000187.html +15 -0
- data/doc/classes/BoolRandomInstruction.src/M000188.html +14 -0
- data/doc/classes/BoolRandomInstruction.src/M000189.html +15 -0
- data/doc/classes/BoolRandomInstruction.src/M000190.html +15 -0
- data/doc/classes/BoolType.html +196 -0
- data/doc/classes/BoolType.src/M000240.html +16 -0
- data/doc/classes/BoolType.src/M000241.html +15 -0
- data/doc/classes/BoolType.src/M000242.html +15 -0
- data/doc/classes/BoolXorInstruction.html +218 -0
- data/doc/classes/BoolXorInstruction.src/M000011.html +15 -0
- data/doc/classes/BoolXorInstruction.src/M000012.html +16 -0
- data/doc/classes/BoolXorInstruction.src/M000013.html +15 -0
- data/doc/classes/BoolXorInstruction.src/M000014.html +15 -0
- data/doc/classes/ChannelNode.html +161 -0
- data/doc/classes/ChannelNode.src/M000249.html +15 -0
- data/doc/classes/ChannelNode.src/M000250.html +16 -0
- data/doc/classes/CodeType.html +269 -0
- data/doc/classes/CodeType.src/M000219.html +38 -0
- data/doc/classes/CodeType.src/M000220.html +16 -0
- data/doc/classes/CodeType.src/M000221.html +16 -0
- data/doc/classes/CodeType.src/M000222.html +16 -0
- data/doc/classes/CodeType.src/M000223.html +24 -0
- data/doc/classes/CodeType.src/M000224.html +42 -0
- data/doc/classes/ERCNode.html +183 -0
- data/doc/classes/ERCNode.src/M000254.html +15 -0
- data/doc/classes/ERCNode.src/M000255.html +16 -0
- data/doc/classes/ERCNode.src/M000256.html +16 -0
- data/doc/classes/ExecPopInstruction.html +218 -0
- data/doc/classes/ExecPopInstruction.src/M000075.html +15 -0
- data/doc/classes/ExecPopInstruction.src/M000076.html +14 -0
- data/doc/classes/ExecPopInstruction.src/M000077.html +15 -0
- data/doc/classes/ExecPopInstruction.src/M000078.html +14 -0
- data/doc/classes/FloatAbsInstruction.html +218 -0
- data/doc/classes/FloatAbsInstruction.src/M000107.html +15 -0
- data/doc/classes/FloatAbsInstruction.src/M000108.html +15 -0
- data/doc/classes/FloatAbsInstruction.src/M000109.html +15 -0
- data/doc/classes/FloatAbsInstruction.src/M000110.html +15 -0
- data/doc/classes/FloatAddInstruction.html +218 -0
- data/doc/classes/FloatAddInstruction.src/M000079.html +15 -0
- data/doc/classes/FloatAddInstruction.src/M000080.html +16 -0
- data/doc/classes/FloatAddInstruction.src/M000081.html +15 -0
- data/doc/classes/FloatAddInstruction.src/M000082.html +15 -0
- data/doc/classes/FloatCosineInstruction.html +218 -0
- data/doc/classes/FloatCosineInstruction.src/M000123.html +15 -0
- data/doc/classes/FloatCosineInstruction.src/M000124.html +15 -0
- data/doc/classes/FloatCosineInstruction.src/M000125.html +15 -0
- data/doc/classes/FloatCosineInstruction.src/M000126.html +15 -0
- data/doc/classes/FloatDivideInstruction.html +218 -0
- data/doc/classes/FloatDivideInstruction.src/M000091.html +15 -0
- data/doc/classes/FloatDivideInstruction.src/M000092.html +16 -0
- data/doc/classes/FloatDivideInstruction.src/M000093.html +20 -0
- data/doc/classes/FloatDivideInstruction.src/M000094.html +15 -0
- data/doc/classes/FloatFromBoolInstruction.html +218 -0
- data/doc/classes/FloatFromBoolInstruction.src/M000055.html +15 -0
- data/doc/classes/FloatFromBoolInstruction.src/M000056.html +15 -0
- data/doc/classes/FloatFromBoolInstruction.src/M000057.html +15 -0
- data/doc/classes/FloatFromBoolInstruction.src/M000058.html +15 -0
- data/doc/classes/FloatFromIntInstruction.html +218 -0
- data/doc/classes/FloatFromIntInstruction.src/M000063.html +15 -0
- data/doc/classes/FloatFromIntInstruction.src/M000064.html +15 -0
- data/doc/classes/FloatFromIntInstruction.src/M000065.html +15 -0
- data/doc/classes/FloatFromIntInstruction.src/M000066.html +15 -0
- data/doc/classes/FloatGreaterThanQInstruction.html +218 -0
- data/doc/classes/FloatGreaterThanQInstruction.src/M000035.html +15 -0
- data/doc/classes/FloatGreaterThanQInstruction.src/M000036.html +16 -0
- data/doc/classes/FloatGreaterThanQInstruction.src/M000037.html +15 -0
- data/doc/classes/FloatGreaterThanQInstruction.src/M000038.html +15 -0
- data/doc/classes/FloatIfInstruction.html +218 -0
- data/doc/classes/FloatIfInstruction.src/M000047.html +16 -0
- data/doc/classes/FloatIfInstruction.src/M000048.html +15 -0
- data/doc/classes/FloatIfInstruction.src/M000049.html +14 -0
- data/doc/classes/FloatIfInstruction.src/M000050.html +17 -0
- data/doc/classes/FloatLessThanQInstruction.html +218 -0
- data/doc/classes/FloatLessThanQInstruction.src/M000039.html +15 -0
- data/doc/classes/FloatLessThanQInstruction.src/M000040.html +16 -0
- data/doc/classes/FloatLessThanQInstruction.src/M000041.html +15 -0
- data/doc/classes/FloatLessThanQInstruction.src/M000042.html +15 -0
- data/doc/classes/FloatMaxInstruction.html +218 -0
- data/doc/classes/FloatMaxInstruction.src/M000095.html +15 -0
- data/doc/classes/FloatMaxInstruction.src/M000096.html +16 -0
- data/doc/classes/FloatMaxInstruction.src/M000097.html +15 -0
- data/doc/classes/FloatMaxInstruction.src/M000098.html +15 -0
- data/doc/classes/FloatMinInstruction.html +218 -0
- data/doc/classes/FloatMinInstruction.src/M000099.html +15 -0
- data/doc/classes/FloatMinInstruction.src/M000100.html +16 -0
- data/doc/classes/FloatMinInstruction.src/M000101.html +15 -0
- data/doc/classes/FloatMinInstruction.src/M000102.html +15 -0
- data/doc/classes/FloatMultiplyInstruction.html +218 -0
- data/doc/classes/FloatMultiplyInstruction.src/M000083.html +15 -0
- data/doc/classes/FloatMultiplyInstruction.src/M000084.html +16 -0
- data/doc/classes/FloatMultiplyInstruction.src/M000085.html +15 -0
- data/doc/classes/FloatMultiplyInstruction.src/M000086.html +15 -0
- data/doc/classes/FloatNegativeInstruction.html +218 -0
- data/doc/classes/FloatNegativeInstruction.src/M000103.html +15 -0
- data/doc/classes/FloatNegativeInstruction.src/M000104.html +15 -0
- data/doc/classes/FloatNegativeInstruction.src/M000105.html +15 -0
- data/doc/classes/FloatNegativeInstruction.src/M000106.html +15 -0
- data/doc/classes/FloatPowerInstruction.html +218 -0
- data/doc/classes/FloatPowerInstruction.src/M000111.html +15 -0
- data/doc/classes/FloatPowerInstruction.src/M000112.html +16 -0
- data/doc/classes/FloatPowerInstruction.src/M000113.html +20 -0
- data/doc/classes/FloatPowerInstruction.src/M000114.html +15 -0
- data/doc/classes/FloatRandomInstruction.html +218 -0
- data/doc/classes/FloatRandomInstruction.src/M000191.html +15 -0
- data/doc/classes/FloatRandomInstruction.src/M000192.html +14 -0
- data/doc/classes/FloatRandomInstruction.src/M000193.html +15 -0
- data/doc/classes/FloatRandomInstruction.src/M000194.html +15 -0
- data/doc/classes/FloatSineInstruction.html +218 -0
- data/doc/classes/FloatSineInstruction.src/M000119.html +15 -0
- data/doc/classes/FloatSineInstruction.src/M000120.html +15 -0
- data/doc/classes/FloatSineInstruction.src/M000121.html +15 -0
- data/doc/classes/FloatSineInstruction.src/M000122.html +15 -0
- data/doc/classes/FloatSqrtInstruction.html +218 -0
- data/doc/classes/FloatSqrtInstruction.src/M000115.html +15 -0
- data/doc/classes/FloatSqrtInstruction.src/M000116.html +15 -0
- data/doc/classes/FloatSqrtInstruction.src/M000117.html +19 -0
- data/doc/classes/FloatSqrtInstruction.src/M000118.html +15 -0
- data/doc/classes/FloatSubtractInstruction.html +218 -0
- data/doc/classes/FloatSubtractInstruction.src/M000087.html +15 -0
- data/doc/classes/FloatSubtractInstruction.src/M000088.html +16 -0
- data/doc/classes/FloatSubtractInstruction.src/M000089.html +15 -0
- data/doc/classes/FloatSubtractInstruction.src/M000090.html +15 -0
- data/doc/classes/FloatTangentInstruction.html +218 -0
- data/doc/classes/FloatTangentInstruction.src/M000127.html +15 -0
- data/doc/classes/FloatTangentInstruction.src/M000128.html +15 -0
- data/doc/classes/FloatTangentInstruction.src/M000129.html +15 -0
- data/doc/classes/FloatTangentInstruction.src/M000130.html +15 -0
- data/doc/classes/FloatType.html +196 -0
- data/doc/classes/FloatType.src/M000243.html +19 -0
- data/doc/classes/FloatType.src/M000244.html +15 -0
- data/doc/classes/FloatType.src/M000245.html +15 -0
- data/doc/classes/Helpers.html +161 -0
- data/doc/classes/Helpers.src/M000343.html +21 -0
- data/doc/classes/Helpers.src/M000344.html +24 -0
- data/doc/classes/Instruction/InstructionMethodError.html +110 -0
- data/doc/classes/Instruction/NaNResultError.html +110 -0
- data/doc/classes/Instruction/NotEnoughStackItems.html +110 -0
- data/doc/classes/Instruction.html +500 -0
- data/doc/classes/Instruction.src/M000131.html +17 -0
- data/doc/classes/Instruction.src/M000132.html +15 -0
- data/doc/classes/Instruction.src/M000133.html +15 -0
- data/doc/classes/Instruction.src/M000134.html +15 -0
- data/doc/classes/Instruction.src/M000135.html +15 -0
- data/doc/classes/Instruction.src/M000136.html +15 -0
- data/doc/classes/Instruction.src/M000137.html +15 -0
- data/doc/classes/Instruction.src/M000138.html +15 -0
- data/doc/classes/Instruction.src/M000139.html +22 -0
- data/doc/classes/Instruction.src/M000140.html +15 -0
- data/doc/classes/Instruction.src/M000141.html +25 -0
- data/doc/classes/Instruction.src/M000142.html +15 -0
- data/doc/classes/Instruction.src/M000143.html +15 -0
- data/doc/classes/Instruction.src/M000144.html +15 -0
- data/doc/classes/Instruction.src/M000145.html +15 -0
- data/doc/classes/Instruction.src/M000146.html +15 -0
- data/doc/classes/InstructionNode.html +161 -0
- data/doc/classes/InstructionNode.src/M000247.html +15 -0
- data/doc/classes/InstructionNode.src/M000248.html +16 -0
- data/doc/classes/IntAbsInstruction.html +218 -0
- data/doc/classes/IntAbsInstruction.src/M000175.html +15 -0
- data/doc/classes/IntAbsInstruction.src/M000176.html +15 -0
- data/doc/classes/IntAbsInstruction.src/M000177.html +15 -0
- data/doc/classes/IntAbsInstruction.src/M000178.html +15 -0
- data/doc/classes/IntAddInstruction.html +218 -0
- data/doc/classes/IntAddInstruction.src/M000147.html +15 -0
- data/doc/classes/IntAddInstruction.src/M000148.html +16 -0
- data/doc/classes/IntAddInstruction.src/M000149.html +15 -0
- data/doc/classes/IntAddInstruction.src/M000150.html +15 -0
- data/doc/classes/IntDepthInstruction.html +218 -0
- data/doc/classes/IntDepthInstruction.src/M000211.html +15 -0
- data/doc/classes/IntDepthInstruction.src/M000212.html +14 -0
- data/doc/classes/IntDepthInstruction.src/M000213.html +15 -0
- data/doc/classes/IntDepthInstruction.src/M000214.html +15 -0
- data/doc/classes/IntDivideInstruction.html +218 -0
- data/doc/classes/IntDivideInstruction.src/M000155.html +15 -0
- data/doc/classes/IntDivideInstruction.src/M000156.html +16 -0
- data/doc/classes/IntDivideInstruction.src/M000157.html +20 -0
- data/doc/classes/IntDivideInstruction.src/M000158.html +15 -0
- data/doc/classes/IntDuplicateInstruction.html +218 -0
- data/doc/classes/IntDuplicateInstruction.src/M000203.html +15 -0
- data/doc/classes/IntDuplicateInstruction.src/M000204.html +15 -0
- data/doc/classes/IntDuplicateInstruction.src/M000205.html +15 -0
- data/doc/classes/IntDuplicateInstruction.src/M000206.html +15 -0
- data/doc/classes/IntEqualQInstruction.html +218 -0
- data/doc/classes/IntEqualQInstruction.src/M000023.html +15 -0
- data/doc/classes/IntEqualQInstruction.src/M000024.html +16 -0
- data/doc/classes/IntEqualQInstruction.src/M000025.html +15 -0
- data/doc/classes/IntEqualQInstruction.src/M000026.html +15 -0
- data/doc/classes/IntFlushInstruction.html +218 -0
- data/doc/classes/IntFlushInstruction.src/M000215.html +15 -0
- data/doc/classes/IntFlushInstruction.src/M000216.html +14 -0
- data/doc/classes/IntFlushInstruction.src/M000217.html +14 -0
- data/doc/classes/IntFlushInstruction.src/M000218.html +15 -0
- data/doc/classes/IntFromBoolInstruction.html +218 -0
- data/doc/classes/IntFromBoolInstruction.src/M000051.html +15 -0
- data/doc/classes/IntFromBoolInstruction.src/M000052.html +15 -0
- data/doc/classes/IntFromBoolInstruction.src/M000053.html +15 -0
- data/doc/classes/IntFromBoolInstruction.src/M000054.html +15 -0
- data/doc/classes/IntFromFloatInstruction.html +218 -0
- data/doc/classes/IntFromFloatInstruction.src/M000059.html +15 -0
- data/doc/classes/IntFromFloatInstruction.src/M000060.html +15 -0
- data/doc/classes/IntFromFloatInstruction.src/M000061.html +15 -0
- data/doc/classes/IntFromFloatInstruction.src/M000062.html +15 -0
- data/doc/classes/IntGreaterThanQInstruction.html +218 -0
- data/doc/classes/IntGreaterThanQInstruction.src/M000031.html +15 -0
- data/doc/classes/IntGreaterThanQInstruction.src/M000032.html +16 -0
- data/doc/classes/IntGreaterThanQInstruction.src/M000033.html +15 -0
- data/doc/classes/IntGreaterThanQInstruction.src/M000034.html +15 -0
- data/doc/classes/IntIfInstruction.html +218 -0
- data/doc/classes/IntIfInstruction.src/M000043.html +16 -0
- data/doc/classes/IntIfInstruction.src/M000044.html +15 -0
- data/doc/classes/IntIfInstruction.src/M000045.html +14 -0
- data/doc/classes/IntIfInstruction.src/M000046.html +17 -0
- data/doc/classes/IntLessThanQInstruction.html +218 -0
- data/doc/classes/IntLessThanQInstruction.src/M000027.html +15 -0
- data/doc/classes/IntLessThanQInstruction.src/M000028.html +16 -0
- data/doc/classes/IntLessThanQInstruction.src/M000029.html +15 -0
- data/doc/classes/IntLessThanQInstruction.src/M000030.html +15 -0
- data/doc/classes/IntMaxInstruction.html +218 -0
- data/doc/classes/IntMaxInstruction.src/M000167.html +15 -0
- data/doc/classes/IntMaxInstruction.src/M000168.html +16 -0
- data/doc/classes/IntMaxInstruction.src/M000169.html +16 -0
- data/doc/classes/IntMaxInstruction.src/M000170.html +15 -0
- data/doc/classes/IntMinInstruction.html +218 -0
- data/doc/classes/IntMinInstruction.src/M000171.html +15 -0
- data/doc/classes/IntMinInstruction.src/M000172.html +16 -0
- data/doc/classes/IntMinInstruction.src/M000173.html +16 -0
- data/doc/classes/IntMinInstruction.src/M000174.html +15 -0
- data/doc/classes/IntModuloInstruction.html +218 -0
- data/doc/classes/IntModuloInstruction.src/M000163.html +15 -0
- data/doc/classes/IntModuloInstruction.src/M000164.html +16 -0
- data/doc/classes/IntModuloInstruction.src/M000165.html +20 -0
- data/doc/classes/IntModuloInstruction.src/M000166.html +15 -0
- data/doc/classes/IntMultiplyInstruction.html +218 -0
- data/doc/classes/IntMultiplyInstruction.src/M000151.html +15 -0
- data/doc/classes/IntMultiplyInstruction.src/M000152.html +16 -0
- data/doc/classes/IntMultiplyInstruction.src/M000153.html +15 -0
- data/doc/classes/IntMultiplyInstruction.src/M000154.html +15 -0
- data/doc/classes/IntNegativeInstruction.html +218 -0
- data/doc/classes/IntNegativeInstruction.src/M000179.html +15 -0
- data/doc/classes/IntNegativeInstruction.src/M000180.html +15 -0
- data/doc/classes/IntNegativeInstruction.src/M000181.html +15 -0
- data/doc/classes/IntNegativeInstruction.src/M000182.html +15 -0
- data/doc/classes/IntPopInstruction.html +218 -0
- data/doc/classes/IntPopInstruction.src/M000195.html +15 -0
- data/doc/classes/IntPopInstruction.src/M000196.html +15 -0
- data/doc/classes/IntPopInstruction.src/M000197.html +14 -0
- data/doc/classes/IntPopInstruction.src/M000198.html +14 -0
- data/doc/classes/IntRandomInstruction.html +218 -0
- data/doc/classes/IntRandomInstruction.src/M000183.html +15 -0
- data/doc/classes/IntRandomInstruction.src/M000184.html +14 -0
- data/doc/classes/IntRandomInstruction.src/M000185.html +15 -0
- data/doc/classes/IntRandomInstruction.src/M000186.html +15 -0
- data/doc/classes/IntRotateInstruction.html +218 -0
- data/doc/classes/IntRotateInstruction.src/M000207.html +15 -0
- data/doc/classes/IntRotateInstruction.src/M000208.html +17 -0
- data/doc/classes/IntRotateInstruction.src/M000209.html +14 -0
- data/doc/classes/IntRotateInstruction.src/M000210.html +17 -0
- data/doc/classes/IntSubtractInstruction.html +218 -0
- data/doc/classes/IntSubtractInstruction.src/M000159.html +15 -0
- data/doc/classes/IntSubtractInstruction.src/M000160.html +16 -0
- data/doc/classes/IntSubtractInstruction.src/M000161.html +16 -0
- data/doc/classes/IntSubtractInstruction.src/M000162.html +15 -0
- data/doc/classes/IntSwapInstruction.html +218 -0
- data/doc/classes/IntSwapInstruction.src/M000199.html +15 -0
- data/doc/classes/IntSwapInstruction.src/M000200.html +16 -0
- data/doc/classes/IntSwapInstruction.src/M000201.html +14 -0
- data/doc/classes/IntSwapInstruction.src/M000202.html +16 -0
- data/doc/classes/IntType.html +240 -0
- data/doc/classes/IntType.src/M000235.html +15 -0
- data/doc/classes/IntType.src/M000236.html +15 -0
- data/doc/classes/IntType.src/M000237.html +18 -0
- data/doc/classes/IntType.src/M000238.html +15 -0
- data/doc/classes/IntType.src/M000239.html +15 -0
- data/doc/classes/LiteralNode.html +183 -0
- data/doc/classes/LiteralNode.src/M000251.html +15 -0
- data/doc/classes/LiteralNode.src/M000252.html +16 -0
- data/doc/classes/LiteralNode.src/M000253.html +16 -0
- data/doc/classes/Nudge/Channel.html +437 -0
- data/doc/classes/Nudge/Channel.src/M000286.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000287.html +19 -0
- data/doc/classes/Nudge/Channel.src/M000288.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000289.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000290.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000291.html +19 -0
- data/doc/classes/Nudge/Channel.src/M000292.html +19 -0
- data/doc/classes/Nudge/Channel.src/M000293.html +17 -0
- data/doc/classes/Nudge/Channel.src/M000294.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000295.html +20 -0
- data/doc/classes/Nudge/Channel.src/M000296.html +15 -0
- data/doc/classes/Nudge/Channel.src/M000297.html +17 -0
- data/doc/classes/Nudge/Channel.src/M000298.html +15 -0
- data/doc/classes/Nudge/CodeBlock.html +331 -0
- data/doc/classes/Nudge/CodeBlock.src/M000263.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000264.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000265.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000266.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000267.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000268.html +17 -0
- data/doc/classes/Nudge/CodeBlock.src/M000269.html +20 -0
- data/doc/classes/Nudge/CodeBlock.src/M000270.html +15 -0
- data/doc/classes/Nudge/CodeBlock.src/M000271.html +19 -0
- data/doc/classes/Nudge/DeadLocation.html +152 -0
- data/doc/classes/Nudge/DeadLocation.src/M000334.html +17 -0
- data/doc/classes/Nudge/Erc.html +335 -0
- data/doc/classes/Nudge/Erc.src/M000278.html +16 -0
- data/doc/classes/Nudge/Erc.src/M000279.html +15 -0
- data/doc/classes/Nudge/Erc.src/M000280.html +15 -0
- data/doc/classes/Nudge/Erc.src/M000281.html +15 -0
- data/doc/classes/Nudge/Erc.src/M000282.html +18 -0
- data/doc/classes/Nudge/Erc.src/M000283.html +15 -0
- data/doc/classes/Nudge/Erc.src/M000284.html +17 -0
- data/doc/classes/Nudge/Erc.src/M000285.html +15 -0
- data/doc/classes/Nudge/Individual.html +313 -0
- data/doc/classes/Nudge/Individual.src/M000314.html +21 -0
- data/doc/classes/Nudge/Individual.src/M000315.html +15 -0
- data/doc/classes/Nudge/Individual.src/M000316.html +15 -0
- data/doc/classes/Nudge/Individual.src/M000317.html +17 -0
- data/doc/classes/Nudge/Individual.src/M000318.html +25 -0
- data/doc/classes/Nudge/InstructionPoint/InstructionNotFoundError.html +110 -0
- data/doc/classes/Nudge/InstructionPoint.html +350 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000299.html +15 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000300.html +15 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000301.html +17 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000302.html +15 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000303.html +17 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000304.html +17 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000305.html +17 -0
- data/doc/classes/Nudge/InstructionPoint.src/M000306.html +15 -0
- data/doc/classes/Nudge/Interpreter.html +369 -0
- data/doc/classes/Nudge/Interpreter.src/M000257.html +20 -0
- data/doc/classes/Nudge/Interpreter.src/M000258.html +19 -0
- data/doc/classes/Nudge/Interpreter.src/M000259.html +15 -0
- data/doc/classes/Nudge/Interpreter.src/M000260.html +19 -0
- data/doc/classes/Nudge/Interpreter.src/M000261.html +17 -0
- data/doc/classes/Nudge/LiteralPoint.html +291 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000272.html +16 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000273.html +15 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000274.html +15 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000275.html +18 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000276.html +17 -0
- data/doc/classes/Nudge/LiteralPoint.src/M000277.html +15 -0
- data/doc/classes/Nudge/Location.html +525 -0
- data/doc/classes/Nudge/Location.src/M000319.html +19 -0
- data/doc/classes/Nudge/Location.src/M000320.html +15 -0
- data/doc/classes/Nudge/Location.src/M000321.html +26 -0
- data/doc/classes/Nudge/Location.src/M000322.html +15 -0
- data/doc/classes/Nudge/Location.src/M000323.html +20 -0
- data/doc/classes/Nudge/Location.src/M000324.html +16 -0
- data/doc/classes/Nudge/Location.src/M000325.html +25 -0
- data/doc/classes/Nudge/Location.src/M000326.html +15 -0
- data/doc/classes/Nudge/Location.src/M000327.html +21 -0
- data/doc/classes/Nudge/Location.src/M000328.html +16 -0
- data/doc/classes/Nudge/Location.src/M000329.html +15 -0
- data/doc/classes/Nudge/Location.src/M000330.html +16 -0
- data/doc/classes/Nudge/Location.src/M000331.html +20 -0
- data/doc/classes/Nudge/Location.src/M000332.html +17 -0
- data/doc/classes/Nudge/Location.src/M000333.html +17 -0
- data/doc/classes/Nudge/NondominatedSubset.html +196 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000005.html +19 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000006.html +19 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000007.html +25 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000339.html +19 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000340.html +19 -0
- data/doc/classes/Nudge/NondominatedSubset.src/M000341.html +25 -0
- data/doc/classes/Nudge/PopulationResample.html +175 -0
- data/doc/classes/Nudge/PopulationResample.src/M000003.html +22 -0
- data/doc/classes/Nudge/PopulationResample.src/M000337.html +22 -0
- data/doc/classes/Nudge/ProgramPoint.html +148 -0
- data/doc/classes/Nudge/ProgramPoint.src/M000262.html +15 -0
- data/doc/classes/Nudge/RandomGuess.html +176 -0
- data/doc/classes/Nudge/RandomGuess.src/M000002.html +21 -0
- data/doc/classes/Nudge/RandomGuess.src/M000336.html +21 -0
- data/doc/classes/Nudge/ResampleValues.html +169 -0
- data/doc/classes/Nudge/ResampleValues.src/M000004.html +36 -0
- data/doc/classes/Nudge/ResampleValues.src/M000338.html +36 -0
- data/doc/classes/Nudge/SearchOperator.html +175 -0
- data/doc/classes/Nudge/SearchOperator.src/M000001.html +15 -0
- data/doc/classes/Nudge/SearchOperator.src/M000335.html +15 -0
- data/doc/classes/Nudge/Stack.html +350 -0
- data/doc/classes/Nudge/Stack.src/M000307.html +15 -0
- data/doc/classes/Nudge/Stack.src/M000308.html +15 -0
- data/doc/classes/Nudge/Stack.src/M000309.html +18 -0
- data/doc/classes/Nudge/Stack.src/M000310.html +15 -0
- data/doc/classes/Nudge/Stack.src/M000311.html +15 -0
- data/doc/classes/Nudge/Stack.src/M000312.html +15 -0
- data/doc/classes/Nudge/Stack.src/M000313.html +15 -0
- data/doc/classes/Nudge/UniformBackboneCrossover.html +152 -0
- data/doc/classes/Nudge/UniformBackboneCrossover.src/M000008.html +35 -0
- data/doc/classes/Nudge/UniformBackboneCrossover.src/M000342.html +35 -0
- data/doc/classes/Nudge.html +174 -0
- data/doc/classes/NudgeType.html +363 -0
- data/doc/classes/NudgeType.src/M000225.html +17 -0
- data/doc/classes/NudgeType.src/M000226.html +15 -0
- data/doc/classes/NudgeType.src/M000227.html +15 -0
- data/doc/classes/NudgeType.src/M000228.html +15 -0
- data/doc/classes/NudgeType.src/M000229.html +15 -0
- data/doc/classes/NudgeType.src/M000230.html +15 -0
- data/doc/classes/NudgeType.src/M000231.html +15 -0
- data/doc/classes/NudgeType.src/M000232.html +15 -0
- data/doc/classes/NudgeType.src/M000233.html +15 -0
- data/doc/classes/NudgeType.src/M000234.html +15 -0
- data/doc/created.rid +1 -0
- data/doc/files/lib/instructions/bool_basics_rb.html +90 -0
- data/doc/files/lib/instructions/comparisons_rb.html +90 -0
- data/doc/files/lib/instructions/conditionals_rb.html +90 -0
- data/doc/files/lib/instructions/conversions_rb.html +90 -0
- data/doc/files/lib/instructions/exec_rb.html +90 -0
- data/doc/files/lib/instructions/float_arithmetic_rb.html +90 -0
- data/doc/files/lib/instructions/float_transcendental_rb.html +90 -0
- data/doc/files/lib/instructions/infrastructure_rb.html +100 -0
- data/doc/files/lib/instructions/int_arithmetic_rb.html +90 -0
- data/doc/files/lib/instructions/random_value_rb.html +90 -0
- data/doc/files/lib/instructions/stack_manipulation_rb.html +90 -0
- data/doc/files/lib/interpreter/grammars/nudge_language_helpers_rb.html +97 -0
- data/doc/files/lib/interpreter/grammars/nudge_language_treetop.html +180 -0
- data/doc/files/lib/interpreter/interpreter_rb.html +90 -0
- data/doc/files/lib/interpreter/programPoints_rb.html +90 -0
- data/doc/files/lib/interpreter/stack_rb.html +90 -0
- data/doc/files/lib/interpreter/types/codeType_rb.html +157 -0
- data/doc/files/lib/interpreter/types/codeType_rb.src/M000001.html +15 -0
- data/doc/files/lib/interpreter/types/codeType_rb.src/M000002.html +15 -0
- data/doc/files/lib/interpreter/types/pushTypes_rb.html +107 -0
- data/doc/files/lib/nudge_rb.html +152 -0
- data/doc/files/lib/search/evaluators/structural_complexity_rb.html +90 -0
- data/doc/files/lib/search/helpers_rb.html +90 -0
- data/doc/files/lib/search/individual/individual_rb.html +90 -0
- data/doc/files/lib/search/locations/location_rb.html +100 -0
- data/doc/files/lib/search/operators/basic_operators_rb.html +90 -0
- data/doc/fr_class_index.html +191 -0
- data/doc/fr_file_index.html +71 -0
- data/doc/fr_method_index.html +711 -0
- data/doc/index.html +21 -0
- data/doc/rdoc-style.css +299 -0
- data/features/parser_recognizes_nudge_language.feature +9 -0
- data/lib/instructions/bool_basics.rb +85 -0
- data/lib/instructions/code_basics.rb +14 -0
- data/lib/instructions/comparisons.rb +152 -0
- data/lib/instructions/conditionals.rb +44 -0
- data/lib/instructions/conversions.rb +94 -0
- data/lib/instructions/exec.rb +154 -0
- data/lib/instructions/float_arithmetic.rb +201 -0
- data/lib/instructions/float_transcendental.rb +47 -0
- data/lib/instructions/infrastructure.rb +84 -0
- data/lib/instructions/int_arithmetic.rb +160 -0
- data/lib/instructions/name_basics.rb +44 -0
- data/lib/instructions/name_bindings.rb +65 -0
- data/lib/instructions/random_value.rb +43 -0
- data/lib/instructions/stack_manipulation.rb +739 -0
- data/lib/interpreter/grammars/nudge_language.treetop +83 -0
- data/lib/interpreter/grammars/nudge_language_helpers.rb +64 -0
- data/lib/interpreter/interpreter.rb +176 -0
- data/lib/interpreter/programPoints.rb +236 -0
- data/lib/interpreter/stack.rb +39 -0
- data/lib/interpreter/types/codeType.rb +108 -0
- data/lib/interpreter/types/pushTypes.rb +102 -0
- data/lib/nudge.rb +38 -0
- data/lib/search/experiments/experiment.rb +53 -0
- data/lib/search/helpers.rb +22 -0
- data/lib/search/individual/batch.rb +25 -0
- data/lib/search/individual/individual.rb +147 -0
- data/lib/search/operators/basic_operators.rb +230 -0
- data/lib/search/operators/evaluators.rb +107 -0
- data/lib/search/operators/samplers_and_selectors.rb +123 -0
- data/lib/search/stations/station.rb +147 -0
- data/push_language_coverage.md +177 -0
- data/readme.md +19 -0
- data/spec/data/couchdb_spec.rb +2 -0
- data/spec/fixtures/just_block.example +1 -0
- data/spec/fixtures/just_block_with_newline.example +1 -0
- data/spec/fixtures/long_arithmetic.example +7 -0
- data/spec/fixtures/one_line_instr.example +1 -0
- data/spec/fixtures/untidy1.example +20 -0
- data/spec/fixtures/untidy1fixed.example +12 -0
- data/spec/instructions/bool_basics_spec.rb +97 -0
- data/spec/instructions/bool_stack_spec.rb +391 -0
- data/spec/instructions/code_basics_spec.rb +43 -0
- data/spec/instructions/code_stack_spec.rb +382 -0
- data/spec/instructions/comparisons_spec.rb +486 -0
- data/spec/instructions/conditionals_spec.rb +162 -0
- data/spec/instructions/conversions_spec.rb +92 -0
- data/spec/instructions/exec_spec.rb +883 -0
- data/spec/instructions/float_calculations_spec.rb +148 -0
- data/spec/instructions/float_stack_spec.rb +382 -0
- data/spec/instructions/float_transcendental_spec.rb +89 -0
- data/spec/instructions/instruction_class_spec.rb +9 -0
- data/spec/instructions/int_calculations_spec.rb +125 -0
- data/spec/instructions/int_stack_spec.rb +398 -0
- data/spec/instructions/name_basics_spec.rb +158 -0
- data/spec/instructions/name_bindings_spec.rb +257 -0
- data/spec/instructions/name_stack_spec.rb +382 -0
- data/spec/instructions/random_values_spec.rb +68 -0
- data/spec/integration/search_integration.rb +67 -0
- data/spec/interpreter/channel_spec.rb +92 -0
- data/spec/interpreter/codeblock_spec.rb +135 -0
- data/spec/interpreter/codetype_spec.rb +257 -0
- data/spec/interpreter/erc_spec.rb +130 -0
- data/spec/interpreter/instruction_spec.rb +97 -0
- data/spec/interpreter/interpreter_spec.rb +266 -0
- data/spec/interpreter/literal_spec.rb +94 -0
- data/spec/interpreter/parser_spec.rb +324 -0
- data/spec/interpreter/stack_spec.rb +81 -0
- data/spec/interpreter/types_spec.rb +102 -0
- data/spec/search/batch_spec.rb +30 -0
- data/spec/search/experiments/experiment_spec.rb +101 -0
- data/spec/search/helpers_spec.rb +59 -0
- data/spec/search/individual_spec.rb +356 -0
- data/spec/search/operators/any_one_sampler_spec.rb +40 -0
- data/spec/search/operators/dominated_quantile_spec.rb +111 -0
- data/spec/search/operators/duplicate_genomes_spec.rb +35 -0
- data/spec/search/operators/evaluators/program_point_evaluator_spec.rb +43 -0
- data/spec/search/operators/evaluators/test_case_evaluator_spec.rb +133 -0
- data/spec/search/operators/infrastructure_spec.rb +47 -0
- data/spec/search/operators/most_dominated_subset_spec.rb +47 -0
- data/spec/search/operators/nondominated_subset_spec.rb +97 -0
- data/spec/search/operators/pointCrossover_spec.rb +55 -0
- data/spec/search/operators/pointDeletion_spec.rb +57 -0
- data/spec/search/operators/pointMutation_spec.rb +71 -0
- data/spec/search/operators/random_guess_spec.rb +51 -0
- data/spec/search/operators/resample_and_clone_spec.rb +50 -0
- data/spec/search/operators/resample_values_spec.rb +126 -0
- data/spec/search/operators/sizePreservingMutation_spec.rb +2 -0
- data/spec/search/operators/uniformBackboneCrossover_spec.rb +63 -0
- data/spec/search/stations/station_spec.rb +496 -0
- data/spec/spec_helper.rb +11 -0
- metadata +738 -0
@@ -0,0 +1,126 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
describe "ResampleValuesOperator search operator" do
|
5
|
+
|
6
|
+
it "should not need any initial parameters" do
|
7
|
+
lambda{ResampleValuesOperator.new()}.should_not raise_error
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be possible to pass in stored parameters" do
|
11
|
+
lambda{ResampleValuesOperator.new(:randomIntegerLowerBound => 12)}.should_not raise_error
|
12
|
+
rs = ResampleValuesOperator.new({:boolTrueProbability => 0.2})
|
13
|
+
rs.params.should include(:boolTrueProbability)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "generate" do
|
17
|
+
before(:each) do
|
18
|
+
@rs = ResampleValuesOperator.new({:boolTrueProbability => 0.2})
|
19
|
+
@intDude = Individual.new("block {sample int(3)}")
|
20
|
+
@boolDude = Individual.new("block {sample bool(false)}")
|
21
|
+
@floatDude = Individual.new("block {sample float(-991.2213)}")
|
22
|
+
@complicatedDude = Individual.new("block {sample int(3) sample bool(false) block {sample float(0.0)}}")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should require a Batch as a first parameter" do
|
26
|
+
lambda{@rs.generate()}.should raise_error(ArgumentError)
|
27
|
+
lambda{@rs.generate(Batch.new)}.should_not raise_error(ArgumentError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should raise an ArgumentError if the array parameter isn't all Individuals" do
|
31
|
+
lambda{@rs.generate([88])}.should raise_error(ArgumentError)
|
32
|
+
lambda{@rs.generate([@intDude])}.should_not raise_error(ArgumentError)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should by default produce one (1) resampled mutant for each input" do
|
36
|
+
@rs.generate([@intDude]).length.should == 1
|
37
|
+
@rs.generate([@intDude, @intDude]).length.should == 2
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should call #random_value for each line in each individual that is a 'sample'" do
|
41
|
+
IntType.should_receive(:random_value).and_return(777)
|
42
|
+
newGuys = @rs.generate([@intDude])
|
43
|
+
BoolType.should_receive(:random_value).and_return(false)
|
44
|
+
newGuys = @rs.generate([@boolDude])
|
45
|
+
FloatType.should_receive(:random_value).and_return(9.999)
|
46
|
+
newGuys = @rs.generate([@floatDude])
|
47
|
+
IntType.should_receive(:random_value).and_return(777)
|
48
|
+
BoolType.should_receive(:random_value).and_return(false)
|
49
|
+
FloatType.should_receive(:random_value).and_return(9.999)
|
50
|
+
newGuys = @rs.generate([@complicatedDude])
|
51
|
+
|
52
|
+
IntType.should_receive(:random_value).and_return(1,2)
|
53
|
+
BoolType.should_receive(:random_value).and_return(false,true)
|
54
|
+
FloatType.should_receive(:random_value).and_return(1.0,2.0)
|
55
|
+
newGuys = @rs.generate([@intDude,@boolDude,@floatDude,@complicatedDude],1)
|
56
|
+
newGuys[0].genome.should include "1"
|
57
|
+
newGuys[1].genome.should include "false"
|
58
|
+
newGuys[2].genome.should include "1.0"
|
59
|
+
newGuys[3].genome.should include "2.0"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should be possible to pass in a higher integer, and get that many variants for each input" do
|
63
|
+
IntType.should_receive(:random_value).and_return(11,22,33)
|
64
|
+
newGuys = @rs.generate([@intDude],3)
|
65
|
+
newGuys[0].genome.should include("11")
|
66
|
+
newGuys[1].genome.should include("22")
|
67
|
+
newGuys[2].genome.should include("33")
|
68
|
+
|
69
|
+
IntType.should_receive(:random_value).and_return(4,5,6,7)
|
70
|
+
newGuys = @rs.generate([@intDude, @intDude],2)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should be using the Operator's saved parameters as a default behavior" do
|
74
|
+
wholeLottaParams = {
|
75
|
+
:randomIntegerLowerBound => 1000,
|
76
|
+
:randomIntegerUpperBound => 1005,
|
77
|
+
:randomBooleanTruthProb => 0.2,
|
78
|
+
:randomFloatLowerBound => 112.0,
|
79
|
+
:randomFloatUpperBound => 112.5}
|
80
|
+
|
81
|
+
resampleLimited = ResampleValuesOperator.new(wholeLottaParams)
|
82
|
+
|
83
|
+
IntType.should_receive(:random_value).with(wholeLottaParams)
|
84
|
+
newGuys = resampleLimited.generate([@intDude])
|
85
|
+
|
86
|
+
BoolType.should_receive(:random_value).with(wholeLottaParams)
|
87
|
+
newGuys = resampleLimited.generate([@boolDude])
|
88
|
+
|
89
|
+
FloatType.should_receive(:random_value).with(wholeLottaParams)
|
90
|
+
newGuys = resampleLimited.generate([@floatDude])
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return Individuals who (probably) differ from the originals passed in" do
|
94
|
+
outOfRangeParams = {
|
95
|
+
:randomIntegerLowerBound => 1000,
|
96
|
+
:randomIntegerUpperBound => 1005,
|
97
|
+
:randomBooleanTruthProb => 1.0,
|
98
|
+
:randomFloatLowerBound => 112.0,
|
99
|
+
:randomFloatUpperBound => 112.5}
|
100
|
+
resampleFarAway = ResampleValuesOperator.new(outOfRangeParams)
|
101
|
+
newGuys = resampleFarAway.generate([@intDude])
|
102
|
+
newGuys[0].genome.should =~ /100[0-5]/
|
103
|
+
newGuys = resampleFarAway.generate([@boolDude])
|
104
|
+
newGuys[0].genome.should =~ /true/
|
105
|
+
newGuys = resampleFarAway.generate([@floatDude])
|
106
|
+
newGuys[0].genome.should =~ /112\.[0-5]/
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should be possible to temporarily override some or all of the preset @params" do
|
110
|
+
bigInt = {:randomIntegerLowerBound => 90000,:randomIntegerUpperBound => 91000}
|
111
|
+
toBeOverridden = ResampleValuesOperator.new(bigInt)
|
112
|
+
defaults = toBeOverridden.generate([@intDude],5)
|
113
|
+
defaults.each {|dude| dude.genome.should =~ /9\d\d\d\d/}
|
114
|
+
|
115
|
+
littler = toBeOverridden.generate([@intDude],5,
|
116
|
+
:randomIntegerLowerBound => -19, :randomIntegerUpperBound => -10)
|
117
|
+
littler.each {|dude| dude.genome.should =~ /-1\d/}
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should increment the #progress of every clone" do
|
121
|
+
@complicatedDude.progress = 192
|
122
|
+
@rs.generate([@complicatedDude],5).each {|clone| clone.progress.should == 193}
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
describe "UniformBackboneCrossoverOperator" do
|
5
|
+
before(:each) do
|
6
|
+
@newDudes = []
|
7
|
+
@params = {:points => 3, :instructions => [IntAddInstruction], :types => [IntType]}
|
8
|
+
@myXover = UniformBackboneCrossoverOperator.new
|
9
|
+
@myGuesser = RandomGuessOperator.new(@params)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be a kind of SearchOperator" do
|
13
|
+
@myXover.should be_a_kind_of(SearchOperator)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should produce a Batch of Individuals when it receives #generate" do
|
17
|
+
@newDudes = @myXover.generate(@myGuesser.generate(2))
|
18
|
+
@newDudes.should be_a_kind_of(Batch)
|
19
|
+
@newDudes.each {|dude| dude.should be_a_kind_of(Individual)}
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should produce the same number of Individuals it gets as a default" do
|
23
|
+
@newDudes = @myXover.generate(@myGuesser.generate(6))
|
24
|
+
@newDudes.length.should == 6
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have an optional parameter that specifies the number of offspring to produce" do
|
28
|
+
@newDudes = @myXover.generate(@myGuesser.generate(2),5)
|
29
|
+
@newDudes.length.should == 5
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should only include backbone points from one of the parents in the offsprings' genomes" do
|
33
|
+
rents = @myGuesser.generate(2)
|
34
|
+
@newDudes = @myXover.generate(rents,1)
|
35
|
+
@newDudes.length.should == 1
|
36
|
+
allParentalPoints = rents[0].program.contents + rents[1].program.contents
|
37
|
+
allTidied = allParentalPoints.collect {|pt| pt.tidy}
|
38
|
+
@newDudes[0].program.contents.each {|pt| allTidied.should include(pt.tidy)}
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return an identical individual if given only one parent" do
|
42
|
+
rent = @myGuesser.generate(1)
|
43
|
+
@newDudes = @myXover.generate(rent,3)
|
44
|
+
@newDudes.each {|kid| kid.program.tidy.should == rent[0].program.tidy}
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
it "should not affect the original parents set in any way" do
|
49
|
+
rents = @myGuesser.generate(2)
|
50
|
+
originalMom = rents[0].object_id
|
51
|
+
@newDudes = @myXover.generate(rents,1)
|
52
|
+
rents[0].object_id.should == originalMom
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return offspring with #progress values incremented from the largest parent value" do
|
56
|
+
rents = @myGuesser.generate(2)
|
57
|
+
rents[0].progress = 12
|
58
|
+
rents[1].progress = 33
|
59
|
+
@newDudes = @myXover.generate(rents,20)
|
60
|
+
@newDudes.each {|baby| [13, 34].should include(baby.progress)}
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,496 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
describe "Station" do
|
5
|
+
before(:each) do
|
6
|
+
Station.cleanup
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
describe "class methods" do
|
11
|
+
describe "#stations" do
|
12
|
+
it "should be a Hash" do
|
13
|
+
Station.stations.should be_a_kind_of(Hash)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should always include :DEAD" do
|
17
|
+
Station.stations.should include(:DEAD)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
describe "names" do
|
24
|
+
it "should have a name" do
|
25
|
+
loc1 = Station.new("candy_mountain")
|
26
|
+
loc1.name.should == "candy_mountain"
|
27
|
+
end
|
28
|
+
it "needs to have a name" do
|
29
|
+
lambda{loc1 = Station.new}.should raise_error
|
30
|
+
end
|
31
|
+
it "needs to be a unique name" do
|
32
|
+
loc1 = Station.new("california")
|
33
|
+
lambda{loc2 = Station.new("california")}.should raise_error
|
34
|
+
end
|
35
|
+
it "should register its name in Station#stations upon creation" do
|
36
|
+
loc1 = Station.new("neverland")
|
37
|
+
Station.stations["neverland"].should == loc1
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should collect all created stations" do
|
41
|
+
Station.stations.length.should == 1
|
42
|
+
alpha = Station.new("alpha")
|
43
|
+
Station.stations.length.should == 2
|
44
|
+
beta = Station.new("beta")
|
45
|
+
Station.stations.length.should == 3
|
46
|
+
Station.stations.keys.should == [:DEAD,"alpha", "beta"]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
describe "capacity" do
|
52
|
+
it "should have a #capacity parameter that defaults to 100 individuals" do
|
53
|
+
loc1 = Station.new("candy_mountain")
|
54
|
+
loc1.capacity.should == 100
|
55
|
+
end
|
56
|
+
it "should be settable as a second parameter" do
|
57
|
+
loc1 = Station.new("germany", capacity:912)
|
58
|
+
loc1.capacity.should == 912
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
describe "settings" do
|
64
|
+
it "should have a #settings attribute, where active instructions, variable names and types are listed" do
|
65
|
+
loc1 = Station.new("place")
|
66
|
+
loc1.settings.should_not == nil
|
67
|
+
loc1.settings.should be_a_kind_of(InterpreterSettings)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should default to all defined Instructions" do
|
71
|
+
Station.new("place").settings.instructions.should == Instruction.all_instructions
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should default to no variables defined" do
|
75
|
+
Station.new("place").settings.references.should == []
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should default to the Push types (not all types)" do
|
79
|
+
Station.new("place").settings.types.should == NudgeType.push_types
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should be possible to pass in initial Array of active Instructions" do
|
83
|
+
loc = Station.new("p1", instructions: [IntAddInstruction])
|
84
|
+
loc.settings.instructions.should == [IntAddInstruction]
|
85
|
+
Station.new("p2", capacity: 4, :types => [IntType]).settings.types.should == [IntType]
|
86
|
+
Station.new("p3", capacity: 4, :references => ["x1"]).settings.references.should == ["x1"]
|
87
|
+
lambda{Station.new("p4", capacity: 4, :random_crap => ["whatever"])}.should_not raise_error
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
describe "network" do
|
93
|
+
it "should have a #flows_into method that adds a #downstream link" do
|
94
|
+
loc1 = Station.new("bree")
|
95
|
+
loc2 = Station.new("rivendell")
|
96
|
+
loc1.flows_into(loc2)
|
97
|
+
loc1.downstream.should be_a_kind_of(Set)
|
98
|
+
loc1.downstream.should include("rivendell")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
describe "population" do
|
104
|
+
it "should be an Array that's empty initially" do
|
105
|
+
loc1 = Station.new("spain")
|
106
|
+
loc1.population.should == []
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "persistent store (database)" do
|
111
|
+
it "should have a URL for a couchDB (with name)" do
|
112
|
+
loc1 = Station.new("spain", database:"http://localhost:5984")
|
113
|
+
loc1.database.should == "http://localhost:5984/spain"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "breeding pool" do
|
118
|
+
it "should include every Individual in the Station and all downstream stations" do
|
119
|
+
loc1 = Station.new("bree")
|
120
|
+
loc2 = Station.new("rivendell")
|
121
|
+
dude1 = Individual.new("block {}")
|
122
|
+
dude2 = Individual.new("ref x")
|
123
|
+
loc1.population << dude1
|
124
|
+
loc2.population << dude2
|
125
|
+
loc1.breeding_pool.should include(dude1)
|
126
|
+
loc1.breeding_pool.should_not include(dude2)
|
127
|
+
loc1.flows_into(loc2)
|
128
|
+
loc1.breeding_pool.should include(dude1)
|
129
|
+
loc1.breeding_pool.should include(dude2)
|
130
|
+
loc2.breeding_pool.should_not include(dude1)
|
131
|
+
loc2.breeding_pool.should include(dude2)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
describe "add_individual" do
|
137
|
+
it "should set the station of the Individual being added to the population to the Station name" do
|
138
|
+
loc1 = Station.new("mordor")
|
139
|
+
dude1 = Individual.new("ref f")
|
140
|
+
loc1.add_individual dude1
|
141
|
+
dude1.station.should == loc1
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should be a private method"
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
describe "transfer" do
|
149
|
+
before(:each) do
|
150
|
+
@loc1 = Station.new("bree")
|
151
|
+
@loc2 = Station.new("rivendell")
|
152
|
+
@dude1 = Individual.new("block {}")
|
153
|
+
@loc1.add_individual @dude1
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should send an Individual from self.population to a different Station" do
|
157
|
+
@loc1.transfer(0,"rivendell")
|
158
|
+
@loc1.population.length.should == 0
|
159
|
+
@loc2.population.should include(@dude1)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should change the #station attribute of the moved Individual" do
|
163
|
+
@dude1.station.should == @loc1
|
164
|
+
@loc1.transfer(0,"rivendell")
|
165
|
+
@dude1.station.should == @loc2
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should bounds check the popIndex parameter and raise an error if impossible" do
|
169
|
+
lambda{@loc1.transfer(-20,"rivendell")}.should raise_error(ArgumentError,
|
170
|
+
"self#transfer called with index -20")
|
171
|
+
lambda{@loc1.transfer(8,"rivendell")}.should raise_error(ArgumentError)
|
172
|
+
lambda{@loc1.transfer(1,"rivendell")}.should_not raise_error(ArgumentError)
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should name-check the station parameter" do
|
176
|
+
lambda{@loc1.transfer(1,"nowhere")}.should raise_error(ArgumentError,
|
177
|
+
'self#transfer called with nonexistent station "nowhere"')
|
178
|
+
lambda{@loc1.transfer(1,"rivendell")}.should_not raise_error(ArgumentError)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
describe "promote" do
|
184
|
+
describe "to a specific station" do
|
185
|
+
before(:each) do
|
186
|
+
@loc1 = Station.new("bree")
|
187
|
+
@loc2 = Station.new("rivendell")
|
188
|
+
@loc3 = Station.new("numenor")
|
189
|
+
@loc4 = Station.new("washington")
|
190
|
+
@loc1.flows_into(@loc2)
|
191
|
+
@loc2.flows_into(@loc3)
|
192
|
+
@loc2.flows_into(@loc4)
|
193
|
+
@dude1 = Individual.new("block {}")
|
194
|
+
@loc1.add_individual @dude1
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should raise an exception if the new station isn't immediately downstream" do
|
198
|
+
lambda{@loc1.promote(0,"numenor")}.should raise_error(ArgumentError,
|
199
|
+
'"bree" is not connected to "numenor"')
|
200
|
+
lambda{@loc1.promote(0,"rivendell")}.should_not raise_error(ArgumentError)
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should select a random downstream destination if none is specified" do
|
204
|
+
@loc1.promote(0)
|
205
|
+
@loc2.population.should include(@dude1)
|
206
|
+
@loc2.promote(0)
|
207
|
+
(@loc3.population + @loc4.population).should include(@dude1)
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should fail silently if there are no downstream stations" do
|
211
|
+
dude2 = Individual.new("do int_add")
|
212
|
+
@loc4.add_individual(dude2)
|
213
|
+
lambda{@loc4.promote(0)}.should_not raise_error
|
214
|
+
@loc4.promote(0)
|
215
|
+
@loc4.population.length.should == 1
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe "promotion_rule" do
|
221
|
+
it "should default to false"
|
222
|
+
it "should be settable via a parameter with that name"
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
describe "promote?" do
|
227
|
+
before(:each) do
|
228
|
+
@loc1 = Station.new("bree")
|
229
|
+
@loc2 = Station.new("rivendell")
|
230
|
+
@loc3 = Station.new("numenor")
|
231
|
+
@loc4 = Station.new("washington")
|
232
|
+
@loc1.flows_into(@loc2)
|
233
|
+
@loc2.flows_into(@loc3)
|
234
|
+
@loc2.flows_into(@loc4)
|
235
|
+
@dude1 = Individual.new("block {}")
|
236
|
+
@loc1.add_individual @dude1
|
237
|
+
end
|
238
|
+
|
239
|
+
it "should default to 'false'" do
|
240
|
+
@loc1.promote?(@loc1.population[0]).should == false
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should refer to self.promotion_rule to make the decision" do
|
244
|
+
@loc1.promotion_rule.stub(:call).and_return(999)
|
245
|
+
@loc1.promote?(@loc1.population[0]).should == 999
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
|
250
|
+
describe "review_and_promote" do
|
251
|
+
before(:each) do
|
252
|
+
@loc1 = Station.new("bree")
|
253
|
+
@loc2 = Station.new("rivendell")
|
254
|
+
@loc1.flows_into(@loc2)
|
255
|
+
@dude1 = Individual.new("block {}")
|
256
|
+
@loc1.add_individual @dude1
|
257
|
+
end
|
258
|
+
|
259
|
+
it "should apply self.promote? to all members of the population" do
|
260
|
+
@loc1.should_receive(:promote?).once
|
261
|
+
@loc1.review_and_promote
|
262
|
+
|
263
|
+
@loc1.add_individual @dude1 # again! Don't actually ever do this...
|
264
|
+
@loc1.should_receive(:promote?).twice
|
265
|
+
@loc1.review_and_promote
|
266
|
+
end
|
267
|
+
|
268
|
+
it "should only send the ones for whom #promote? is true" do
|
269
|
+
@loc1.should_not_receive(:promote)
|
270
|
+
@loc1.review_and_promote
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should however actually lose the ones for whom #promote? is true" do
|
274
|
+
@loc2.population.length.should == 0
|
275
|
+
theGuy = @loc1.population[0]
|
276
|
+
@loc1.promotion_rule = Proc.new {|dude| true}
|
277
|
+
@loc1.review_and_promote
|
278
|
+
@loc2.population.length.should == 1
|
279
|
+
@loc2.population.should include(theGuy)
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should only move the ones for whom #promote? is true" do
|
283
|
+
dude2 = Individual.new("do something")
|
284
|
+
@loc1.add_individual dude2
|
285
|
+
@loc1.promotion_rule = Proc.new {|dude| dude.genome.include?("something")}
|
286
|
+
@loc1.review_and_promote
|
287
|
+
|
288
|
+
@loc1.population.length.should == 1
|
289
|
+
@loc2.population.length.should == 1
|
290
|
+
@loc2.population.should_not include(@dude1)
|
291
|
+
@loc1.population.should include(@dude1)
|
292
|
+
@loc2.population.should include(dude2)
|
293
|
+
@loc1.population.should_not include(dude2)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
|
298
|
+
describe "cull_check" do
|
299
|
+
it "should default to 'is population.length > capacity'?" do
|
300
|
+
loc1 = Station.new("here", capacity: 1)
|
301
|
+
dude1 = Individual.new("block {}")
|
302
|
+
loc1.add_individual dude1
|
303
|
+
loc1.population.length.should == 1
|
304
|
+
loc1.cull_check.call.should == false
|
305
|
+
loc1.add_individual dude1
|
306
|
+
loc1.population.length.should == 2
|
307
|
+
loc1.cull_check.call.should == true
|
308
|
+
end
|
309
|
+
|
310
|
+
it "should be settable to some other Proc" do
|
311
|
+
loc1 = Station.new("here", cull_check: Proc.new {77})
|
312
|
+
loc1.cull_check.call.should == 77
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
|
317
|
+
describe "cull?" do
|
318
|
+
it "should be a method that returns a boolean" do
|
319
|
+
loc1 = Station.new("bree")
|
320
|
+
[true,false].should include(loc1.cull?)
|
321
|
+
end
|
322
|
+
|
323
|
+
it "should invoke self#cull_check" do
|
324
|
+
loc1 = Station.new("amondul", capacity:1)
|
325
|
+
loc1.cull_check.should_receive(:call)
|
326
|
+
loc1.cull?
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
|
331
|
+
describe "cull" do
|
332
|
+
it "should invoke the cull_rule if cull? is true"
|
333
|
+
|
334
|
+
it "should not invoke cull_rule if cull? is false"
|
335
|
+
|
336
|
+
it "should invoke cull_rule repeatedly until cull? is false"
|
337
|
+
|
338
|
+
it "should return an Array with the Individuals from self#population in it" do
|
339
|
+
pending
|
340
|
+
loc1 = Station.new("amondul", capacity:1)
|
341
|
+
loc1.add_individual Individual.new("block {}")
|
342
|
+
loc1.add_individual Individual.new("ref x")
|
343
|
+
loc1.cull_order.should be_a_kind_of(Array)
|
344
|
+
loc1.cull_order[0].should be_a_kind_of(Individual)
|
345
|
+
loc1.cull_order.length.should == loc1.population.length
|
346
|
+
end
|
347
|
+
|
348
|
+
it "should default to random shuffle order" do
|
349
|
+
pending
|
350
|
+
loc1 = Station.new("amondul", capacity:1) # default rule
|
351
|
+
loc1.add_individual Individual.new("block {}")
|
352
|
+
loc1.add_individual Individual.new("ref x")
|
353
|
+
loc1.population.should_receive(:shuffle)
|
354
|
+
loc1.cull_order
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
|
359
|
+
describe "actual culling" do
|
360
|
+
it "should eventually satisfy the cull? condition" do
|
361
|
+
loc1 = Station.new("amondul",capacity:1) # will have a default cull_order
|
362
|
+
lDead = Station.stations[:DEAD]
|
363
|
+
loc1.add_individual Individual.new("block {}")
|
364
|
+
loc1.cull?.should == false
|
365
|
+
loc1.add_individual Individual.new("ref x")
|
366
|
+
loc1.cull?.should == true
|
367
|
+
|
368
|
+
pending "This needs rewriting"
|
369
|
+
loc1.review_and_cull
|
370
|
+
loc1.cull?.should == false
|
371
|
+
lDead.population.length.should == 1
|
372
|
+
end
|
373
|
+
|
374
|
+
it "should not fire unless self#cull? is true" do
|
375
|
+
loc1 = Station.new("amondul",capacity:1) # will have a default cull_order
|
376
|
+
lDead = Station.stations[:DEAD]
|
377
|
+
loc1.add_individual Individual.new("block {}")
|
378
|
+
loc1.cull?.should == false
|
379
|
+
loc1.review_and_cull
|
380
|
+
loc1.population.length.should == 1
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
|
385
|
+
describe "Station#generate" do
|
386
|
+
before(:each) do
|
387
|
+
@loc1 = Station.new("here",capacity:1)
|
388
|
+
end
|
389
|
+
|
390
|
+
it "should access the breeding_pool when called" do
|
391
|
+
@loc1.should_receive(:breeding_pool).and_return(["mock filler"])
|
392
|
+
@loc1.generate()
|
393
|
+
end
|
394
|
+
|
395
|
+
it "should invoke #generate_rule" do
|
396
|
+
@loc1.generate_rule.should_receive(:call).and_return(["some dude"])
|
397
|
+
@loc1.generate
|
398
|
+
end
|
399
|
+
|
400
|
+
it "should end up with the results of generate_rule merged into its population" do
|
401
|
+
@loc1.generate_rule.should_receive(:call).and_return(["some dude"])
|
402
|
+
@loc1.generate
|
403
|
+
@loc1.population.should include("some dude")
|
404
|
+
|
405
|
+
@loc1.generate_rule.should_receive(:call).and_return(["other dude"])
|
406
|
+
@loc1.generate
|
407
|
+
@loc1.population.length.should == 2
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
|
412
|
+
describe "generate_rule" do
|
413
|
+
before(:each) do
|
414
|
+
@loc1 = Station.new("here",capacity:1)
|
415
|
+
@loc1.settings.types = [IntType]
|
416
|
+
end
|
417
|
+
|
418
|
+
it "should be possible to override the default by passing a param"
|
419
|
+
|
420
|
+
it "should take one parameter" do
|
421
|
+
@loc1.generate_rule.arity.should == 1
|
422
|
+
end
|
423
|
+
|
424
|
+
# detailed validation of inputs and output is a postponed story
|
425
|
+
|
426
|
+
it "should return an array of individuals" do
|
427
|
+
newDudes = @loc1.generate_rule.call
|
428
|
+
newDudes.should be_a_kind_of(Array)
|
429
|
+
newDudes.each {|i| i.should be_a_kind_of(Individual)}
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
|
434
|
+
describe "core_cycle" do
|
435
|
+
before(:each) do
|
436
|
+
@loc1 = Station.new("here",capacity:1)
|
437
|
+
@loc2 = Station.new("there",capacity:1)
|
438
|
+
@loc1.flows_into(@loc2)
|
439
|
+
@loc1.settings.types = [IntType]
|
440
|
+
@loc2.settings.types = [IntType]
|
441
|
+
end
|
442
|
+
|
443
|
+
it "should invoke #generate once" do
|
444
|
+
@loc1.should_receive(:generate)
|
445
|
+
@loc1.core_cycle
|
446
|
+
end
|
447
|
+
|
448
|
+
it "should invoke #review_and_promote" do
|
449
|
+
@loc1.should_receive(:review_and_promote)
|
450
|
+
@loc1.core_cycle
|
451
|
+
end
|
452
|
+
|
453
|
+
it "should invoke #cull once" do
|
454
|
+
@loc1.should_receive(:review_and_cull).once
|
455
|
+
@loc1.core_cycle
|
456
|
+
# there is one random guy here with the default generate rule
|
457
|
+
end
|
458
|
+
|
459
|
+
it "should cull only enough to make the cull_trigger false" do
|
460
|
+
@loc1.add_individual(Individual.new("do die"))
|
461
|
+
@loc1.population.length.should == 1
|
462
|
+
|
463
|
+
pending "This needs rewriting"
|
464
|
+
@loc1.core_cycle #this adds a new random dude AND CULLS HIM (capacity = 1)
|
465
|
+
@loc1.population.length.should == 1
|
466
|
+
Station.stations[:DEAD].population.length.should == 1
|
467
|
+
|
468
|
+
@loc1.capacity = 2
|
469
|
+
@loc1.core_cycle #this adds a new random dude AND HE'S FINE (capacity = 2)
|
470
|
+
@loc1.population.length.should == 2
|
471
|
+
Station.stations[:DEAD].population.length.should == 1
|
472
|
+
|
473
|
+
@loc1.cull_check.should_receive(:call).and_return(true, true, false)
|
474
|
+
@loc1.should_receive(:cull_order).and_return(@loc1.population)
|
475
|
+
@loc1.core_cycle #now we have three dudes, two of which will die
|
476
|
+
@loc1.population.length.should == 1
|
477
|
+
Station.stations[:DEAD].population.length.should == 3
|
478
|
+
end
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
describe "DeadStation" do
|
486
|
+
it "should always exist" do
|
487
|
+
Station.cleanup
|
488
|
+
Station.stations.should include(:DEAD)
|
489
|
+
Station.stations[:DEAD].should be_a_kind_of(Station)
|
490
|
+
Station.stations[:DEAD].should be_a_kind_of(DeadStation)
|
491
|
+
end
|
492
|
+
|
493
|
+
it "should have no capacity" do
|
494
|
+
Station.stations[:DEAD].capacity.should == nil
|
495
|
+
end
|
496
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
$: << File.join(File.dirname(__FILE__), "/../lib")
|
2
|
+
|
3
|
+
require 'spec'
|
4
|
+
require 'pp'
|
5
|
+
require 'nudge'
|
6
|
+
require 'erb'
|
7
|
+
|
8
|
+
def fixture(name, data = binding)
|
9
|
+
text = File.read(File.join(File.dirname(__FILE__), "/fixtures/#{name}.example"))
|
10
|
+
ERB.new(text).result(data)
|
11
|
+
end
|