|
@@ -35,24 +35,49 @@ def eval_prog(args):
|
35
|
35
|
steps = args.steps
|
36
|
36
|
else:
|
37
|
37
|
steps = args.steps - int((args.steps / 1.5) // (args.repeat_eval - trynum))
|
38
|
|
- for step in range(steps):
|
39
|
|
- for turmit in turmits:
|
40
|
|
- turmit()
|
|
38
|
+
|
|
39
|
+ if not steps: # 0 or None
|
|
40
|
+ pfdim = 0
|
|
41
|
+ dfdim = 1
|
|
42
|
+ steps = 0
|
|
43
|
+ lim_reach = 0
|
|
44
|
+ retry_lim = 0
|
|
45
|
+ while lim_reach < 2:
|
|
46
|
+ for _ in range(3000):
|
|
47
|
+ for turmit in turmits:
|
|
48
|
+ turmit()
|
|
49
|
+ steps += 0x1000
|
|
50
|
+ cfdim = w.fractdim() # delta fdim on not targeted dim
|
|
51
|
+ dfdim = cfdim - pfdim
|
|
52
|
+ pfdim = cfdim
|
|
53
|
+ if abs(dfdim) < 0.001:
|
|
54
|
+ lim_reach += 1
|
|
55
|
+ else:
|
|
56
|
+ retry_lim += 1
|
|
57
|
+ if retry_lim < 3:
|
|
58
|
+ lim_reach = 0
|
|
59
|
+ else:
|
|
60
|
+ for step in range(steps):
|
|
61
|
+ for turmit in turmits:
|
|
62
|
+ turmit()
|
41
|
63
|
stop = time.time()
|
42
|
64
|
|
43
|
65
|
score_dir = sum([t.dirvar() for t in turmits]) / len(turmits)
|
44
|
66
|
score_deter = sum([t.determinist() for t in turmits]) / len(turmits)
|
45
|
|
- score_fract = w.fractdim()
|
|
67
|
+ score_fract, raw_fract = w.fractdim_target(args.target)
|
46
|
68
|
score = (score_dir * score_fract) * (score_deter * 0.2 + 0.8)
|
47
|
69
|
sinfo = {'F':score_fract, 'D':score_dir}
|
48
|
70
|
#score = sum([score_fract] + [score_dir] * 4) / 5
|
49
|
71
|
if not args.quiet:
|
50
|
72
|
tall = time.time() - startall
|
51
|
|
- msg = 'G%d P%d R%d: %d steps scores %.3f:(D:%.3f,F:%.3f,Dtr:%.3f) in %.3fs (%dus per step)\t%s'
|
|
73
|
+ msg = 'G%d P%d R%d: %d steps scores %.3f:(D:%.3f,F:%.3f,'
|
52
|
74
|
msg %= (generation, progid, trynum, steps, score, score_dir,
|
53
|
|
- score_fract, score_deter, tall,
|
54
|
|
- ((stop - start)*1000000)//steps//len(turmits),
|
55
|
|
- str(prog))
|
|
75
|
+ score_fract)
|
|
76
|
+ if args.target:
|
|
77
|
+ msg += 'RawF:%.3f,' % raw_fract
|
|
78
|
+ msg += 'Dtr:%.3f) in %.3fs (%dus per step)\t%s'
|
|
79
|
+ msg %= (score_deter, tall,
|
|
80
|
+ ((stop - start)*1000000)//steps//len(turmits), str(prog))
|
56
|
81
|
logger.info(msg)
|
57
|
82
|
return progid, score, sinfo
|
58
|
83
|
|
|
@@ -100,6 +125,16 @@ class World(object):
|
100
|
125
|
''' @brief Save as an image '''
|
101
|
126
|
scipy.misc.imsave(filename, self._val)
|
102
|
127
|
|
|
128
|
+ def fractdim_target(self, target, threshold=None):
|
|
129
|
+ res = self.fractdim(threshold)
|
|
130
|
+ if target:
|
|
131
|
+ ret = (2.0 - (abs(target - res))*5)
|
|
132
|
+ if ret < 0:
|
|
133
|
+ ret = 0.0
|
|
134
|
+ return (ret, res)
|
|
135
|
+ else:
|
|
136
|
+ return (res, res)
|
|
137
|
+
|
103
|
138
|
def fractdim(self, threshold=None):
|
104
|
139
|
''' @return Minkowski–Bouligand dimension (computed) '''
|
105
|
140
|
if not self._gray:
|