/* Duelling cowboys. See http://hakank.org/webppl/duelling_cowboys.wppl Here I try to recover the probability that A survives when A and B starts with equal probability. The test of [0.3, 0.7] should return 0.24683544303797486 * Here's a (not exactly correct) solution in generation 29: [program = A / (A + B) * ((2 / 2 - (B - 1 - A)) / 2),res = 0.24,count = 9] --> A (2 + A - B) Out[1]= ------------- 2 (A + B) * With approx = 0.05: [program = A / (B * (-1 / -9 + (B - A)) + A + B),res = 0.220949263502455,count = 1] * With stop_criteria=generations num_gens=1800 gen = 1098 (time: 81.569s) results_best = [[0.535431442166878,A * 7.999999999999988 / (3.700000000000002 * B * (A + 3.600000000000002))],[0.550399873633033,A * (2.800000000000001 / (0.0 + B)) / (4.799999999999999 + A)] gen = 559 (time: 40.918s) results_best = [[0.546472016516566,A / (1.8 * (B - A * A / (B - 8.399999999999986)))]] My JGAP SymbolicRegression program give a nice solution: http://hakank.org/jgap/duelling_cowboys.conf A / (A + (((B - A) * (B - (B - (B / (2.0 - B))))) + B)) [1] 0.3 0.7 Result: 0.2468354430379747 In[2]:= A / (A + (((B - A) * (B - (B - (B / (2.0 - B))))) + B)) // FullSimplify # 0.5 A (-2. + B) Out[2]= ------------------ A (-1. + B) - 1. B */ import util. data(duelling_cowboys,Data,Vars,Unknown,Ops,Constants,MaxSize,Params) :- Data = [ [[X,Y], Z] : [X,Y,Z] in chunks_of([ % a b prob(A survives) 0.1,0.1,0.5, 0.1,0.2,0.32142857142857095, 0.1,0.3,0.22972972972972974, 0.1,0.4,0.17391304347826053, 0.1,0.5,0.13636363636363646, 0.1,0.6,0.10937499999999976, 0.1,0.7,0.08904109589041062, 0.1,0.8,0.07317073170731696, 0.1,0.9,0.0604395604395603, 0.2,0.2,0.5, 0.2,0.3,0.38636363636363663, 0.2,0.4,0.3076923076923075, 0.2,0.5,0.24999999999999978, 0.2,0.6,0.20588235294117652, 0.2,0.7,0.17105263157894735, 0.2,0.8,0.1428571428571429, 0.2,0.9,0.11956521739130402, 0.3,0.3,0.5, 0.3,0.4,0.4137931034482764, 0.3,0.5,0.34615384615384626, 0.3,0.6,0.29166666666666646, 0.3,0.7,0.24683544303797486, 0.3,0.8,0.20930232558139525, 0.3,0.9,0.17741935483870974, 0.4,0.4,0.5, 0.4,0.5,0.4285714285714287, 0.4,0.6,0.3684210526315791, 0.4,0.7,0.3170731707317074, 0.4,0.8,0.27272727272727276, 0.4,0.9,0.2340425531914893, 0.5,0.5,0.5, 0.5,0.6,0.4374999999999997, 0.5,0.7,0.38235294117647045, 0.5,0.8,0.33333333333333326, 0.5,0.9,0.2894736842105264, 0.6,0.6,0.5, 0.6,0.7,0.4431818181818181, 0.6,0.8,0.39130434782608736, 0.6,0.9,0.34375000000000006, 0.7,0.7,0.5, 0.7,0.8,0.4468085106382979, 0.7,0.9,0.3969072164948454, 0.8,0.8,0.5, 0.8,0.9,0.44897959183673464, 0.9,0.9,0.5 ],3)], Vars = ['A','B'], Unknown = [0.3,0.7], % expected answer: 0.3,0.7,0.24683544303797486, Ops = [+,*,/,-], % RandomFloats = [frand(0,10) : I in 1..10], RandomInts = [random(-10,10) : I in 1..10], Constants = 0.0..0.1..10.0, % [0.5,1,2,3,4,5,6,7,8,9,10], Params = new_map([approx = 0.01, % total_approx=1, num_gens=1800, init_size=500, % show_only_improvements=false, % mutate_rate=0.3, % crossover_rate=0.8, debug=false, stop_criteria=generations, % , stop_criteria=loops % pick_from_pct=0.2, show_best=10, remove_dups=true % , random_seed=1 % keep_programs_pct=0.1 ]), MaxSize = 31.