MilesCranmer commited on
Commit
9254d92
1 Parent(s): c253783

Remove unused evalTree and popRandomOp

Browse files
Files changed (1) hide show
  1. julia/sr.jl +0 -44
julia/sr.jl CHANGED
@@ -78,21 +78,6 @@ function copyNode(tree::Node)::Node
78
  end
79
  end
80
 
81
- # Evaluate a symbolic equation:
82
- function evalTree(tree::Node, x::Array{Float32, 1}=Float32[])::Float32
83
- if tree.degree == 0
84
- if tree.constant
85
- return tree.val
86
- else
87
- return x[tree.val]
88
- end
89
- elseif tree.degree == 1
90
- return unaops[tree.op](evalTree(tree.l, x))
91
- else
92
- return binops[tree.op](evalTree(tree.l, x), evalTree(tree.r, x))
93
- end
94
- end
95
-
96
  # Count the operators, constants, variables in an equation
97
  function countNodes(tree::Node)::Integer
98
  if tree.degree == 0
@@ -332,35 +317,6 @@ function appendRandomOp(tree::Node)::Node
332
  return tree
333
  end
334
 
335
- # Add random node to the top of a tree
336
- function popRandomOp(tree::Node)::Node
337
- node = tree
338
- choice = rand()
339
- makeNewBinOp = choice < nbin/nops
340
- left = tree
341
-
342
- if makeNewBinOp
343
- right = randomConstantNode()
344
- newnode = Node(
345
- rand(1:length(binops)),
346
- left,
347
- right
348
- )
349
- else
350
- newnode = Node(
351
- rand(1:length(unaops)),
352
- left
353
- )
354
- end
355
- node.l = newnode.l
356
- node.r = newnode.r
357
- node.op = newnode.op
358
- node.degree = newnode.degree
359
- node.val = newnode.val
360
- node.constant = newnode.constant
361
- return node
362
- end
363
-
364
  # Insert random node
365
  function insertRandomOp(tree::Node)::Node
366
  node = randomNode(tree)
 
78
  end
79
  end
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  # Count the operators, constants, variables in an equation
82
  function countNodes(tree::Node)::Integer
83
  if tree.degree == 0
 
317
  return tree
318
  end
319
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  # Insert random node
321
  function insertRandomOp(tree::Node)::Node
322
  node = randomNode(tree)