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,133 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
|
5
|
+
describe TestCase do
|
6
|
+
describe "bindings" do
|
7
|
+
it "should have a Hash of independent variable names and assigned values" do
|
8
|
+
TestCase.new.should respond_to(:bindings)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "expectations" do
|
13
|
+
it "should have a Hash of dependent variable names and expected values" do
|
14
|
+
TestCase.new.should respond_to(:expectations)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "gauges" do
|
19
|
+
it "should have a Hash of Proc objects that measure the observed values" do
|
20
|
+
TestCase.new.should respond_to(:gauges)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have one gauge for every expectation" do
|
24
|
+
lambda{TestCase.new(
|
25
|
+
:expectations => {"y1"=>31},
|
26
|
+
:gauges => {"h"=>Proc.new {} } )}.should raise_error
|
27
|
+
lambda{TestCase.new(
|
28
|
+
:expectations => {"y1"=>31},
|
29
|
+
:gauges => {"y1"=>Proc.new {} } )}.should_not raise_error
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
describe TestCaseEvaluator do
|
39
|
+
describe "initialize" do
|
40
|
+
it "should have a name" do
|
41
|
+
lambda{TestCaseEvaluator.new()}.should raise_error(ArgumentError)
|
42
|
+
lambda{TestCaseEvaluator.new(name:"boolean_multiplexer_SSE")}.should_not raise_error
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have all the info it needs to set up an Interpreter"
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "evaluate" do
|
49
|
+
before(:each) do
|
50
|
+
@tce = TestCaseEvaluator.new(name:"error")
|
51
|
+
@dudes = Batch[
|
52
|
+
Individual.new("sample int(12)"),
|
53
|
+
Individual.new("sample int(-9912)"),
|
54
|
+
Individual.new("sample bool(false)"),
|
55
|
+
Individual.new("block { sample int(99) sample int(12)}")
|
56
|
+
]
|
57
|
+
@cases = [
|
58
|
+
TestCase.new(:bindings => {"x" => LiteralPoint.new("int",77)},
|
59
|
+
:expectations => {"y" => 12},
|
60
|
+
:gauges => {"y" => Proc.new {|interp| interp.stacks[:int].peek}}
|
61
|
+
),
|
62
|
+
TestCase.new(:bindings => {"x" => LiteralPoint.new("int",78)},
|
63
|
+
:expectations => {"y" => 13},
|
64
|
+
:gauges => {"y" => Proc.new {|interp| interp.stacks[:int].peek}}
|
65
|
+
)
|
66
|
+
]
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should raise an exception if the batch argument isn't a Batch" do
|
70
|
+
lambda{@tce.evaluate()}.should raise_error(ArgumentError)
|
71
|
+
lambda{@tce.evaluate(@dudes)}.should_not raise_error(ArgumentError)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should raise an exception if it can't evaluate an Individual" do
|
75
|
+
lambda{@tce.evaluate(Batch[Individual.new("blah_de_blah")])}.should raise_error(ArgumentError)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should assign a numeric score to all the Individuals in the Batch" do
|
79
|
+
@dudes.each {|dude| dude.scores["error"].should == nil}
|
80
|
+
@tce.evaluate(@dudes, @cases)
|
81
|
+
@dudes.each {|dude| dude.scores["error"].kind_of?(Numeric).should == true}
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should create an Interpreter for each run" do
|
85
|
+
myI = Interpreter.new
|
86
|
+
Interpreter.should_receive(:new).exactly(8).times.and_return(myI)
|
87
|
+
@tce.evaluate(@dudes, @cases)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should be reset each time before running them" do
|
91
|
+
myI = Interpreter.new
|
92
|
+
Interpreter.stub!(:new).and_return(myI)
|
93
|
+
myI.should_receive(:reset).exactly(8).times
|
94
|
+
@tce.evaluate(@dudes, @cases)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should set up bindings before running them" do
|
98
|
+
myI = Interpreter.new
|
99
|
+
Interpreter.stub!(:new).and_return(myI)
|
100
|
+
myI.should_receive(:bind_variable).exactly(8).times
|
101
|
+
@tce.evaluate(@dudes, @cases)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should run each TestCase for each individual in the Batch" do
|
105
|
+
myI = Interpreter.new
|
106
|
+
Interpreter.stub!(:new).and_return(myI)
|
107
|
+
myI.should_receive(:run).exactly(8).times
|
108
|
+
@tce.evaluate(@dudes, @cases)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "after running a TestCase using an Individual, all the gauges should be called" do
|
112
|
+
myI = Interpreter.new
|
113
|
+
Interpreter.stub!(:new).and_return(myI)
|
114
|
+
myI.should_receive(:run).exactly(8).times
|
115
|
+
@tce.evaluate(@dudes, @cases)
|
116
|
+
|
117
|
+
myI.should_receive(:run).exactly(4).times
|
118
|
+
@tce.evaluate(@dudes, [TestCase.new(:gauges => {"a" => Proc.new {|interp|}})])
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should synthesize the gauge readings into a single numerical score"
|
122
|
+
|
123
|
+
it "should loop over the test cases to collect the error" do
|
124
|
+
@dudes.each {|dude| dude.scores["error"].should == nil}
|
125
|
+
|
126
|
+
@tce.evaluate(@dudes, @cases)
|
127
|
+
equal12or13error = @dudes.collect {|dude| dude.scores["error"]}
|
128
|
+
expectedScores = [1, 19849, 200000, 1]
|
129
|
+
(0..3).each {|i| equal12or13error[i].should be_close(expectedScores[i].to_f / 2, 0.0001)}
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
describe "domination_classes" do
|
7
|
+
before(:each) do
|
8
|
+
@dq = Sampler.new
|
9
|
+
|
10
|
+
@dudes = Batch[Individual.new("block {}"), Individual.new("do int_add")]
|
11
|
+
@dudes[0].scores["first"] = 120
|
12
|
+
@dudes[1].scores["first"] = 2
|
13
|
+
@dudes[0].scores["second"] = 2
|
14
|
+
@dudes[1].scores["second"] = 120
|
15
|
+
@dudes[0].scores["third"] = 20
|
16
|
+
@dudes[1].scores["third"] = 1200
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should take a Batch as an argument" do
|
20
|
+
lambda{@dq.domination_classes()}.should raise_error(ArgumentError)
|
21
|
+
lambda{@dq.domination_classes(@dudes)}.should_not raise_error(ArgumentError)
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
it "can take a template of objective names to use" do
|
26
|
+
lambda{@dq.domination_classes(@dudes, ["first"])}.should_not raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return a Hash" do
|
30
|
+
@dq.domination_classes(@dudes, ["first"]).should be_a_kind_of(Hash)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should use the count of dominating Individuals as the key" do
|
34
|
+
@dq.domination_classes(@dudes, ["second"]).keys.should == [0,1]
|
35
|
+
@dq.domination_classes(@dudes).keys.should == [0]
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have an Array of the Individuals in that class as the value" do
|
40
|
+
@dq.domination_classes(@dudes, ["first"])[0].length.should == 1
|
41
|
+
@dq.domination_classes(@dudes, ["first"])[0][0].should == @dudes[1]
|
42
|
+
@dq.domination_classes(@dudes, ["second"])[0].length.should == 1
|
43
|
+
@dq.domination_classes(@dudes, ["second"])[0][0].should == @dudes[0]
|
44
|
+
@dq.domination_classes(@dudes, ["second", "third"])[0].length.should == 1
|
45
|
+
@dq.domination_classes(@dudes, ["second", "third"])[0][0].should == @dudes[0]
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
describe MostDominatedSubsetSampler do
|
5
|
+
before(:each) do
|
6
|
+
@md = MostDominatedSubsetSampler.new
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
describe "#generate" do
|
11
|
+
before(:each) do
|
12
|
+
@dudes = Batch[Individual.new("block {}"), Individual.new("block {}"), Individual.new("block {}")]
|
13
|
+
@dudes[0].scores = Hash["first", 2, "second", 20, "third", 200]
|
14
|
+
@dudes[1].scores = Hash["first", 20, "second", 200, "third", 2]
|
15
|
+
@dudes[2].scores = Hash["first", 200, "second", 2, "third", 20]
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should take a Batch as a first parameter" do
|
19
|
+
lambda{@md.generate()}.should raise_error(ArgumentError)
|
20
|
+
lambda{@md.generate(@dudes)}.should_not raise_error(ArgumentError)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return a Batch" do
|
24
|
+
@md.generate(@dudes).should be_a_kind_of(Batch)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return a Batch containing references to individuals in the original Batch" do
|
28
|
+
half = @md.generate(@dudes)
|
29
|
+
half.length.should be > 0
|
30
|
+
half.each {|dude| @dudes.should include(dude)}
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should always return at least one, even when everybody is nondominated" do
|
34
|
+
some = @md.generate(@dudes)
|
35
|
+
some.length.should == 3
|
36
|
+
some.each {|dude| @dudes.should include(dude)}
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
it "should take a template of objectives to use in sorting" do
|
41
|
+
@md.generate(@dudes,["first"]).should include(@dudes[2])
|
42
|
+
@md.generate(@dudes,["second"]).should include(@dudes[1])
|
43
|
+
@md.generate(@dudes,["second", "third"]).should include(@dudes[0])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
describe "nondominated_subset operator" do
|
5
|
+
before(:each) do
|
6
|
+
@myNondominatedScreener = NondominatedSubsetSelector.new
|
7
|
+
@params = {:points => 3, :instructions => [IntAddInstruction], :types => [IntType]}
|
8
|
+
@myGuesser = RandomGuessOperator.new(@params)
|
9
|
+
@twoGuys = @myGuesser.generate(2)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be a kind of SearchOperator" do
|
13
|
+
@myNondominatedScreener.should be_a_kind_of(SearchOperator)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "the #all_known_scores method should return an Array with the union of all scores keys in the crowd" do
|
17
|
+
@twoGuys[0].scores = {"x2" => 612, "y2" => 77, "x3" => 712}
|
18
|
+
@twoGuys[1].scores = {"y1" => 2, "x1" => 3, "x2" => 4}
|
19
|
+
@myNondominatedScreener.all_known_scores(@twoGuys).sort.should == ["x1","x2", "x3", "y1", "y2"].sort
|
20
|
+
end
|
21
|
+
|
22
|
+
it "the #all_shared_scores method should return an Array of the keys of the #scores hashes in the crowd" do
|
23
|
+
twoGuys = @myGuesser.generate(2)
|
24
|
+
twoGuys[0].scores = {"x2" => 612, "x1" => 77, "x3" => 712}
|
25
|
+
twoGuys[1].scores = {"x2" => 2, "x1" => 3, "x3" => 4}
|
26
|
+
@myNondominatedScreener.all_shared_scores(twoGuys).sort.should == ["x1","x2", "x3"].sort
|
27
|
+
|
28
|
+
twoGuys[0].scores = {"x3" => 712, "something_else" => 88}
|
29
|
+
twoGuys[1].scores = {"x2" => 2, "x1" => 3, "x3" => 4}
|
30
|
+
@myNondominatedScreener.all_shared_scores(twoGuys).sort.should == ["x3"].sort
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should produce a Batch of Individual objects when it receives #generate; at least one" do
|
34
|
+
twoGuys = @myGuesser.generate(2)
|
35
|
+
twoGuys[0].scores = {"x2" => 612, "x1" => 77, "x3" => 712}
|
36
|
+
twoGuys[1].scores = {"x2" => 2, "x1" => 3, "x3" => 4}
|
37
|
+
@myNondominatedScreener.generate(twoGuys).should be_a_kind_of(Batch)
|
38
|
+
@myNondominatedScreener.generate(twoGuys)[0].should be_a_kind_of(Individual)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should work, passing along references not clones to the original guys" do
|
42
|
+
twoGuys = @myGuesser.generate(2)
|
43
|
+
twoGuys[0].scores = {"x2" => 612, "x1" => 77, "x3" => 712}
|
44
|
+
twoGuys[1].scores = {"x2" => 2, "x1" => 3, "x3" => 4}
|
45
|
+
@myNondominatedScreener.generate(twoGuys).should include(twoGuys[1])
|
46
|
+
|
47
|
+
twoGuys[0].scores = {"x2" => 1, "x1" => 2, "x3" => 3}
|
48
|
+
twoGuys[1].scores = {"x2" => 2, "x1" => 1, "x3" => 3}
|
49
|
+
@myNondominatedScreener.generate(twoGuys).length.should == 2
|
50
|
+
@myNondominatedScreener.generate(twoGuys).should include(twoGuys[0])
|
51
|
+
@myNondominatedScreener.generate(twoGuys).should include(twoGuys[1])
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should work the same no matter what the scores hash order" do
|
55
|
+
twoGuys = @myGuesser.generate(2)
|
56
|
+
twoGuys[0].scores = {"x1" => 77, "x3" => 712,"x2" => 612}
|
57
|
+
twoGuys[1].scores = {"x2" => 2, "x1" => 3, "x3" => 4}
|
58
|
+
@myNondominatedScreener.generate(twoGuys).should include(twoGuys[1])
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
it "can use the 'template' parameter to compare individuals by a specified vector of scores" do
|
63
|
+
threeGuys = @myGuesser.generate(3)
|
64
|
+
threeGuys[0].scores = {"x1" => 1, "x2" => 2, "x3" => 3}
|
65
|
+
threeGuys[1].scores = {"x1" => 2, "x2" => 1, "x3" => 1}
|
66
|
+
threeGuys[2].scores = {"x1" => 4, "x2" => 0, "x3" => 2}
|
67
|
+
@myNondominatedScreener.generate(threeGuys).length.should == 3
|
68
|
+
@myNondominatedScreener.generate(threeGuys,["x1"]).length.should == 1
|
69
|
+
@myNondominatedScreener.generate(threeGuys,["x1"]).should include(threeGuys[0])
|
70
|
+
@myNondominatedScreener.generate(threeGuys,["x2"]).length.should == 1
|
71
|
+
@myNondominatedScreener.generate(threeGuys,["x2"]).should include(threeGuys[2])
|
72
|
+
@myNondominatedScreener.generate(threeGuys,["x3"]).length.should == 1
|
73
|
+
@myNondominatedScreener.generate(threeGuys,["x3"]).should include(threeGuys[1])
|
74
|
+
@myNondominatedScreener.generate(threeGuys,["x1","x3"]).length.should == 2
|
75
|
+
@myNondominatedScreener.generate(threeGuys,["x1","x2"]).length.should == 3
|
76
|
+
@myNondominatedScreener.generate(threeGuys,["x2","x3"]).length.should == 2
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
it "should use a default 'template' parameter that's the intersection of scores keys in the crowd" do
|
81
|
+
twoGuys = @myGuesser.generate(2)
|
82
|
+
twoGuys[0].scores = {"x1" => 1, "x2" => 2, "x3" => 3}
|
83
|
+
twoGuys[1].scores = { "x2" => 1, "x4" => 3}
|
84
|
+
@myNondominatedScreener.generate(twoGuys).length.should == 1
|
85
|
+
@myNondominatedScreener.generate(twoGuys).should include twoGuys[1]
|
86
|
+
@myNondominatedScreener.generate(twoGuys,["x1"]).length.should == 2 # neither dominates on an objectve not shared
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return Individuals that belonged to crowd passed in" do
|
90
|
+
twoGuys = @myGuesser.generate(2)
|
91
|
+
orig_IDs = twoGuys.collect {|dude| dude.object_id}
|
92
|
+
twoGuys[0].scores = {"x1" => 1, "x2" => 2, "x3" => 3}
|
93
|
+
twoGuys[1].scores = { "x2" => 1, "x4" => 3}
|
94
|
+
@myNondominatedScreener.generate(twoGuys).length.should == 1
|
95
|
+
@myNondominatedScreener.generate(twoGuys).each {|newDude| orig_IDs.should include(newDude.object_id)}
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
describe "PointCrossoverOperator" do
|
5
|
+
before(:each) do
|
6
|
+
@myXover = PointCrossoverOperator.new
|
7
|
+
@dude1 = Individual.new("block{do a \n do b\n do c}")
|
8
|
+
@dude2 = Individual.new("block{ref x \n ref y\n ref z}")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be a kind of SearchOperator" do
|
12
|
+
@myXover.should be_a_kind_of(SearchOperator)
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
describe "generate" do
|
17
|
+
|
18
|
+
it "should take as a param a set of one or more Individuals" do
|
19
|
+
lambda{@myXover.generate()}.should raise_error(ArgumentError)
|
20
|
+
lambda{@myXover.generate(331)}.should raise_error(ArgumentError)
|
21
|
+
lambda{@myXover.generate([])}.should raise_error(ArgumentError)
|
22
|
+
lambda{@myXover.generate([11])}.should raise_error(ArgumentError)
|
23
|
+
|
24
|
+
lambda{@myXover.generate([@dude1])}.should_not raise_error(ArgumentError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should produce the same number of Individuals it gets as a default" do
|
28
|
+
babies = @myXover.generate([@dude1])
|
29
|
+
babies.length.should == 1
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have an optional parameter that specifies the number of offspring to produce per parent" do
|
33
|
+
babies = @myXover.generate(Batch.[](@dude1, @dude2))
|
34
|
+
babies.length.should == 2
|
35
|
+
babies = @myXover.generate([@dude1, @dude2],4)
|
36
|
+
babies.length.should == 8
|
37
|
+
end
|
38
|
+
it "should only include points from one of the parents in the offspring genomes" do
|
39
|
+
babies = @myXover.generate([@dude1, @dude2])
|
40
|
+
bothGenomes = @dude1.program.listing + @dude2.program.listing
|
41
|
+
babies.each do |baby|
|
42
|
+
baby.program.listing.each_line do |line|
|
43
|
+
bothGenomes.match(line.strip.delete("}")).should_not == nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should increment the offspring's progress from the max parents' progress" do
|
49
|
+
@dude1.progress = 7
|
50
|
+
@dude2.progress = 11
|
51
|
+
babies = @myXover.generate([@dude1, @dude2],10)
|
52
|
+
babies.each {|baby| [8,12].should include(baby.progress)}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
describe "PointDeleteOperator search operator" do
|
5
|
+
describe "generate" do
|
6
|
+
before(:each) do
|
7
|
+
@zapper = PointDeleteOperator.new()
|
8
|
+
@dude1 = Individual.new("block { do thing1 \n do thing2 \n do thing3}")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should accept a Batch as a param" do
|
12
|
+
lambda{@zapper.generate()}.should raise_error(ArgumentError)
|
13
|
+
lambda{@zapper.generate(812)}.should raise_error(ArgumentError)
|
14
|
+
lambda{@zapper.generate(Batch.new)}.should_not raise_error(ArgumentError)
|
15
|
+
lambda{@zapper.generate(Batch[@dude1])}.should_not raise_error(ArgumentError)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should raise an Argument error if all contents of the crowd aren't Individuals" do
|
19
|
+
lambda{@zapper.generate([])}.should_not raise_error(ArgumentError)
|
20
|
+
lambda{@zapper.generate([ 77 ])}.should raise_error(ArgumentError)
|
21
|
+
lambda{@zapper.generate([ @dude1, 77 ])}.should raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return a Batch as a result" do
|
25
|
+
@zapper.generate([@dude1]).should be_a_kind_of(Batch)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should use Individual#delete_point to produce the variants" do
|
29
|
+
@dude1.should_receive(:delete_point).and_return("do parseable")
|
30
|
+
@zapper.generate([@dude1])
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should produce one result per individual in the wildtype crowd as a default" do
|
34
|
+
@zapper.generate([@dude1]).length.should == 1
|
35
|
+
@zapper.generate([@dude1, @dude1]).length.should == 2
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should produce more if passed the optional howManyCopies parameter > 1" do
|
39
|
+
@zapper.generate([@dude1],2).length.should == 2
|
40
|
+
@zapper.generate([@dude1, @dude1],3).length.should == 6
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should produce individuals from which a random point (and its subpoints) is deleted" do
|
44
|
+
@zapper.generate([@dude1],5).each {|baby| baby.points.should < @dude1.points}
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should produce 'block {}' whenever a root is deleted" do
|
48
|
+
@zapper.should_receive(:rand).with(4).and_return(0)
|
49
|
+
@zapper.generate([@dude1])[0].genome.should == "block {}"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should increment the progress of the offspring" do
|
53
|
+
@dude1.progress = 195
|
54
|
+
@zapper.generate([@dude1])[0].progress.should == 196
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
describe "PointMutationOperator" do
|
5
|
+
describe "initialization" do
|
6
|
+
it "should have a params attribute when created that sets basic values for code generation" do
|
7
|
+
PointMutationOperator.new.params.should == {}
|
8
|
+
mutator = PointMutationOperator.new(:points => 3, :blocks => 1)
|
9
|
+
mutator.params.should_not == {}
|
10
|
+
mutator.params[:points].should == 3
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "generate" do
|
15
|
+
before(:each) do
|
16
|
+
@gammaray = PointMutationOperator.new(:points => 3, :types => [IntType])
|
17
|
+
@dude1 = Individual.new("block { do x1 \n do x2 \n do x3}")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should accept an Array of one or more Individuals as a param" do
|
21
|
+
lambda{@gammaray.generate()}.should raise_error(ArgumentError)
|
22
|
+
lambda{@gammaray.generate(99)}.should raise_error(ArgumentError)
|
23
|
+
lambda{@gammaray.generate([])}.should raise_error(ArgumentError)
|
24
|
+
lambda{@gammaray.generate([99])}.should raise_error(ArgumentError)
|
25
|
+
|
26
|
+
lambda{@gammaray.generate([@dude1])}.should_not raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return a Batch as a result" do
|
30
|
+
@gammaray.generate([@dude1]).should be_a_kind_of(Batch)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should use Individual#replace_point to produce the variants" do
|
34
|
+
@dude1.should_receive(:replace_point).and_return("do anything")
|
35
|
+
@gammaray.generate([@dude1])
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should produce one result per individual in the wildtype crowd as a default" do
|
39
|
+
@gammaray.generate([@dude1]).length.should == 1
|
40
|
+
@gammaray.generate([@dude1,@dude1]).length.should == 2
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should produce more if passed the optional howManyCopies parameter > 1" do
|
44
|
+
@gammaray.generate([@dude1],3).length.should == 3
|
45
|
+
@gammaray.generate([@dude1,@dude1],2).length.should == 4
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should produce individuals from which a random point (and all subpoints) is replaced" do
|
49
|
+
@gammaray.should_receive(:rand).and_return(0)
|
50
|
+
@gammaray.generate([@dude1])[0].points.should == 3 # totally replaced with 3-pt code
|
51
|
+
@gammaray.should_receive(:rand).and_return(1)
|
52
|
+
@gammaray.generate([@dude1])[0].points.should == 6 #replace point 2 with 3-pt code
|
53
|
+
@gammaray.should_receive(:rand).and_return(2)
|
54
|
+
@gammaray.generate([@dude1])[0].points.should == 6 #replace point 3 with 3-pt code
|
55
|
+
@gammaray.should_receive(:rand).and_return(3)
|
56
|
+
@gammaray.generate([@dude1])[0].points.should == 6 #replace point 4 with 3-pt code
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should accept temporarily overriding params to pass into CodeType.random_value" do
|
60
|
+
@gammaray.should_receive(:rand).and_return(0)
|
61
|
+
@gammaray.generate([@dude1])[0].points.should == 3 # totally replaced with 3-pt code
|
62
|
+
@gammaray.should_receive(:rand).and_return(0)
|
63
|
+
@gammaray.generate([@dude1],1,:points => 10)[0].points.should == 10
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should increment the #progress of the offspring" do
|
67
|
+
@dude1.progress = 888
|
68
|
+
@gammaray.generate([@dude1],13).each {|baby| baby.progress.should == 889}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
describe "random_guess operator" do
|
5
|
+
before(:each) do
|
6
|
+
@myGuesser = RandomGuessOperator.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be a kind of SearchOperator" do
|
10
|
+
@myGuesser.should be_a_kind_of(SearchOperator)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have a params attribute when created that sets basic values for code generation" do
|
14
|
+
RandomGuessOperator.new.params.should == {}
|
15
|
+
thisGuesser = RandomGuessOperator.new(:points => 3, :blocks => 1, :types => [IntType])
|
16
|
+
thisGuesser.params.should_not == {}
|
17
|
+
thisGuesser.params[:points].should == 3
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should produce a Batch of Individuals when it receives #generate" do
|
21
|
+
newDudes = @myGuesser.generate
|
22
|
+
newDudes.should be_a_kind_of(Batch)
|
23
|
+
newDudes[0].should be_a_kind_of(Individual)
|
24
|
+
newDudes[0].genome.should_not == nil
|
25
|
+
newDudes[0].program.should_not == nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should produce one as a default, more if a higher number is passed in" do
|
29
|
+
@myGuesser.generate.length.should == 1
|
30
|
+
@myGuesser.generate(4).length.should == 4
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have a parsed genome as its #program attribute" do
|
34
|
+
newDudes = @myGuesser.generate
|
35
|
+
newDudes[0].program.should be_a_kind_of(CodeBlock)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should accept temporarily overriding params to pass into CodeType.random_value" do
|
39
|
+
@myNewGuesser = RandomGuessOperator.new(
|
40
|
+
:points => 7, :instructions => [IntAddInstruction, IntSubtractInstruction],
|
41
|
+
:references => ["x1", "x2", "x3"])
|
42
|
+
lambda{@myNewGuesser.generate(3,:points => 12, :references => ["y1"])}.should_not raise_error
|
43
|
+
@myNewGuesser.generate(3,:points => 12)[0].program.points.should_not == 7
|
44
|
+
@myNewGuesser.generate(3,:points => 12)[0].program.points.should == 12
|
45
|
+
@myNewGuesser.generate(1,:points => 6, :blocks => 0, :types => [], :instructions => [], :references => ["y1"])[0].genome.should include("y1")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should produce a Batch that contains Individuals with progress=0 only" do
|
49
|
+
@myGuesser.generate(12).each {|dude| dude.progress.should == 0}
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "./../../spec_helper")
|
2
|
+
include Nudge
|
3
|
+
|
4
|
+
describe "resample_and_clone operator" do
|
5
|
+
before(:each) do
|
6
|
+
@myGuesser = RandomGuessOperator.new(:types => [IntType], :instructions => [IntAddInstruction])
|
7
|
+
@mySampler = ResampleAndCloneOperator.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be a kind of SearchOperator" do
|
11
|
+
@mySampler.should be_a_kind_of(SearchOperator)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should produce a list of Individuals when it receives #generate" do
|
15
|
+
newDudes = @mySampler.generate(@myGuesser.generate(3))
|
16
|
+
newDudes.should be_a_kind_of(Batch)
|
17
|
+
newDudes[0].should be_a_kind_of(Individual)
|
18
|
+
newDudes[0].genome.should_not == nil
|
19
|
+
newDudes[0].program.should_not == nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should produce one Individual with a genome identical to one of the passed in crowd's" do
|
23
|
+
pop = @myGuesser.generate(1)
|
24
|
+
newDudes = @mySampler.generate(pop)
|
25
|
+
newDudes[0].genome.should == pop[0].genome
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return more than one individual when asked to, resampling as needed" do
|
29
|
+
newDudes = @mySampler.generate(@myGuesser.generate(10))
|
30
|
+
newDudes.length.should == 1
|
31
|
+
newDudes = @mySampler.generate(@myGuesser.generate(3),2)
|
32
|
+
newDudes.length.should == 2
|
33
|
+
newDudes = @mySampler.generate(@myGuesser.generate(1),2)
|
34
|
+
newDudes.length.should == 2
|
35
|
+
newDudes[0].genome.should == newDudes[1].genome
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have a parsed genome as its #program attribute" do
|
39
|
+
pop = @myGuesser.generate(3)
|
40
|
+
newDudes = @mySampler.generate(pop)
|
41
|
+
newDudes[0].program.should be_a_kind_of(CodeBlock)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should increment the #progress of each clone" do
|
45
|
+
pop = @myGuesser.generate(3)
|
46
|
+
pop.each {|donor| donor.progress = 12}
|
47
|
+
newDudes = @mySampler.generate(pop)
|
48
|
+
newDudes.each {|kid| kid.progress.should == 13}
|
49
|
+
end
|
50
|
+
end
|