Spaces:
Sleeping
Sleeping
Commit
·
515c017
1
Parent(s):
65bc891
Refactored run
Browse files- julia/optimization.jl +0 -0
- julia/run.jl +28 -0
- julia/sr.jl +2 -29
julia/optimization.jl
ADDED
|
File without changes
|
julia/run.jl
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Cycle through regularized evolution many times,
|
| 2 |
+
# printing the fittest equation every 10% through
|
| 3 |
+
function run(
|
| 4 |
+
pop::Population,
|
| 5 |
+
ncycles::Integer,
|
| 6 |
+
curmaxsize::Integer,
|
| 7 |
+
frequencyComplexity::Array{Float32, 1};
|
| 8 |
+
verbosity::Integer=0
|
| 9 |
+
)::Population
|
| 10 |
+
|
| 11 |
+
allT = LinRange(1.0f0, 0.0f0, ncycles)
|
| 12 |
+
for iT in 1:size(allT)[1]
|
| 13 |
+
if annealing
|
| 14 |
+
pop = regEvolCycle(pop, allT[iT], curmaxsize, frequencyComplexity)
|
| 15 |
+
else
|
| 16 |
+
pop = regEvolCycle(pop, 1.0f0, curmaxsize, frequencyComplexity)
|
| 17 |
+
end
|
| 18 |
+
|
| 19 |
+
if verbosity > 0 && (iT % verbosity == 0)
|
| 20 |
+
bestPops = bestSubPop(pop)
|
| 21 |
+
bestCurScoreIdx = argmin([bestPops.members[member].score for member=1:bestPops.n])
|
| 22 |
+
bestCurScore = bestPops.members[bestCurScoreIdx].score
|
| 23 |
+
debug(verbosity, bestCurScore, " is the score for ", stringTree(bestPops.members[bestCurScoreIdx].tree))
|
| 24 |
+
end
|
| 25 |
+
end
|
| 26 |
+
|
| 27 |
+
return pop
|
| 28 |
+
end
|
julia/sr.jl
CHANGED
|
@@ -39,36 +39,9 @@ include("Population.jl")
|
|
| 39 |
|
| 40 |
include("regEvolCycle.jl")
|
| 41 |
|
| 42 |
-
|
| 43 |
-
# printing the fittest equation every 10% through
|
| 44 |
-
function run(
|
| 45 |
-
pop::Population,
|
| 46 |
-
ncycles::Integer,
|
| 47 |
-
curmaxsize::Integer,
|
| 48 |
-
frequencyComplexity::Array{Float32, 1};
|
| 49 |
-
verbosity::Integer=0
|
| 50 |
-
)::Population
|
| 51 |
-
|
| 52 |
-
allT = LinRange(1.0f0, 0.0f0, ncycles)
|
| 53 |
-
for iT in 1:size(allT)[1]
|
| 54 |
-
if annealing
|
| 55 |
-
pop = regEvolCycle(pop, allT[iT], curmaxsize, frequencyComplexity)
|
| 56 |
-
else
|
| 57 |
-
pop = regEvolCycle(pop, 1.0f0, curmaxsize, frequencyComplexity)
|
| 58 |
-
end
|
| 59 |
-
|
| 60 |
-
if verbosity > 0 && (iT % verbosity == 0)
|
| 61 |
-
bestPops = bestSubPop(pop)
|
| 62 |
-
bestCurScoreIdx = argmin([bestPops.members[member].score for member=1:bestPops.n])
|
| 63 |
-
bestCurScore = bestPops.members[bestCurScoreIdx].score
|
| 64 |
-
debug(verbosity, bestCurScore, " is the score for ", stringTree(bestPops.members[bestCurScoreIdx].tree))
|
| 65 |
-
end
|
| 66 |
-
end
|
| 67 |
-
|
| 68 |
-
return pop
|
| 69 |
-
end
|
| 70 |
-
|
| 71 |
|
|
|
|
| 72 |
# Proxy function for optimization
|
| 73 |
function optFunc(x::Array{Float32, 1}, tree::Node)::Float32
|
| 74 |
setConstants(tree, x)
|
|
|
|
| 39 |
|
| 40 |
include("regEvolCycle.jl")
|
| 41 |
|
| 42 |
+
include("run.jl")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
include("optimization.jl")
|
| 45 |
# Proxy function for optimization
|
| 46 |
function optFunc(x::Array{Float32, 1}, tree::Node)::Float32
|
| 47 |
setConstants(tree, x)
|