MilesCranmer commited on
Commit
b13cd33
1 Parent(s): 41cab3e

Fix bug with no vectorization

Browse files
Files changed (2) hide show
  1. benchmarktimes.txt +1 -1
  2. eureqa.jl +8 -4
benchmarktimes.txt CHANGED
@@ -1,2 +1,2 @@
1
  The median time is TrialEstimate(3.136 s)
2
- The median time is TrialEstimate(611.157 ms)
 
1
  The median time is TrialEstimate(3.136 s)
2
+ The median time is TrialEstimate(435.125 ms)
eureqa.jl CHANGED
@@ -224,7 +224,7 @@ end
224
  function evalTreeArray(
225
  tree::Node,
226
  x::Array{Float32, 2})::Array{Float32, 1}
227
- len = ones(size(x))[2]
228
  if tree.degree == 0
229
  if tree.constant
230
  return ones(Float32, len) .* tree.val
@@ -232,9 +232,9 @@ function evalTreeArray(
232
  return ones(Float32, len) .* x[:, tree.val]
233
  end
234
  elseif tree.degree == 1
235
- return tree.op.(evalTree(tree.l, x))
236
  else
237
- return tree.op.(evalTree(tree.l, x), evalTree(tree.r, x))
238
  end
239
  end
240
 
@@ -257,7 +257,11 @@ function scoreFunc(
257
  try
258
  return MSE(evalTreeArray(tree, X), y) + countNodes(tree)*parsimony
259
  catch error
260
- return 1f9
 
 
 
 
261
  end
262
  end
263
 
 
224
  function evalTreeArray(
225
  tree::Node,
226
  x::Array{Float32, 2})::Array{Float32, 1}
227
+ len = size(x)[1]
228
  if tree.degree == 0
229
  if tree.constant
230
  return ones(Float32, len) .* tree.val
 
232
  return ones(Float32, len) .* x[:, tree.val]
233
  end
234
  elseif tree.degree == 1
235
+ return tree.op.(evalTreeArray(tree.l, x))
236
  else
237
+ return tree.op.(evalTreeArray(tree.l, x), evalTreeArray(tree.r, x))
238
  end
239
  end
240
 
 
257
  try
258
  return MSE(evalTreeArray(tree, X), y) + countNodes(tree)*parsimony
259
  catch error
260
+ if isa(error, DomainError)
261
+ return 1f9
262
+ else
263
+ throw(error)
264
+ end
265
  end
266
  end
267