#!/usr/bin/gawk -f BEGIN { FS=OFS=","; Repeats=10; Top=10; Era=100; Seed=1; Increase=1; OFMT="%10.10g" } END { seeded(); step(); } function step() { print a=x_a(),b=x_b(),c=x_c(),d=x_d(),e=x_e(),score=(a^2/sin(sqrt(b)))*c*sin(d)*e; return score; } function x_a() {return real(1,100)} function x_b() {return radian() } function x_c() {return real(1,100)} function x_d() {return radian() } function x_e() {return real(1,100)} function radian() { return rand()*2* 1068966896/ 340262731 } function keepTests( i, s, best,cache,score,maximize) { maximize=1; best[0]=0; for(i=1;i<=100;i++) { delete cache score=rand(); print score | "sort -n | tail -5" for(s in Spied) cache[s]=s keep(3,best,score ,maximize,cache) } saya("best",best) } function run(ignore1,ignore2,ignore3,ignore4,ignore5) { return run1(Era,Repeats,Top,Seed,Maximize); } function seeded() { srand(Seed ? Seed : 1) } function run1(era,repeats,top,seed,maximize, e,score) { seeded(); while(repeats--) { for(e=1;e<=era;e++) { Cache[0]=e score=step() keep(top,score,maximize); guess() } newGuesses(best); } } function newGuesses() { # adjust the guesses return 1 } function keep(top,sscore,maximize) { return 1 # is "s" score better than "top" n, keep it and lose one old item } function guess() { # set some subset of the cache values return 1 } function between(min,max) { if (max==min) {return min} else {return min+ ((max-min)*rand())}} function real(min,max) { return between(min,max)} function integer(min,max) { return round(between(min,max))} function round(x) { return int(x+0.5) } function within(min,max,bias) { return min + (max - min)*rand()^bias # if bias >= 1 then mean = (max+min)*B is towards to "min" end # BIAS mean # ---- ---- # 1 0.5 # 2 0.33 # 3 0.25 # 4 0.2 # 5 0.17 # 6 0.14 # 7 0.13 # 8 0.11 # 9 0.10 # 10 0.09 # 0.5 0.67 # 0.33 0.75 # 0.25 0.8 # 0.2 0.83 # 0.167 0.86 # 0.14 0.87 # 0.125 0.89 # 0.11 0.9 # 0.10 0.91 } function saya(s,a,q1,q2,eol, com,i,j,n,tmp,str,sep) { com="sort #" rand(); q1= q1 ? "\"" : ""; q2= q2 ? "\"" : ""; for(i in a) { sep=""; str= s"["; n=split(i,tmp,SUBSEP); for(j=1;j<=n;j++) { str=str sep q1 tmp[j] q1; sep=","; } print str "] = " q2 a[i] q2 eol | com; }; close(com); }