Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
8ff33c6
1
Parent(s):
5dffe92
More documentation
Browse files- README.md +30 -4
- paralleleureqa.jl +1 -1
README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
For now, just modify the script to your liking:
|
4 |
|
5 |
-
`julia paralleleureqa.jl`
|
6 |
|
7 |
## Modification
|
8 |
|
@@ -11,6 +11,10 @@ You can change the binary and unary operators in `eureqa.jl` here:
|
|
11 |
const binops = [plus, mult]
|
12 |
const unaops = [sin, cos, exp];
|
13 |
```
|
|
|
|
|
|
|
|
|
14 |
|
15 |
You can change the dataset here:
|
16 |
```
|
@@ -19,12 +23,34 @@ const X = rand(100, nvar);
|
|
19 |
# Here is the function we want to learn (x2^2 + cos(x3) + 5)
|
20 |
const y = ((cx,)->cx^2).(X[:, 2]) + cos.(X[:, 3]) .+ 5.0;
|
21 |
```
|
22 |
-
|
23 |
-
The default number of processes is 10; this is set with
|
24 |
-
`addprocs(10)` in `paralleleureqa.jl`.
|
25 |
|
26 |
### Hyperparameters
|
27 |
|
28 |
Turn on annealing by setting the following in `paralleleureqa.jl`:
|
29 |
|
30 |
`const annealing = true`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
For now, just modify the script to your liking:
|
4 |
|
5 |
+
`JULIA_NUM_THREADS=8 julia paralleleureqa.jl`
|
6 |
|
7 |
## Modification
|
8 |
|
|
|
11 |
const binops = [plus, mult]
|
12 |
const unaops = [sin, cos, exp];
|
13 |
```
|
14 |
+
E.g., you can add another binary function with:
|
15 |
+
```
|
16 |
+
const binops = [plus, mult, (x, y)->x^2*y]
|
17 |
+
```
|
18 |
|
19 |
You can change the dataset here:
|
20 |
```
|
|
|
23 |
# Here is the function we want to learn (x2^2 + cos(x3) + 5)
|
24 |
const y = ((cx,)->cx^2).(X[:, 2]) + cos.(X[:, 3]) .+ 5.0;
|
25 |
```
|
26 |
+
by either loading in a dataset, or modifying the definition of `y`.
|
|
|
|
|
27 |
|
28 |
### Hyperparameters
|
29 |
|
30 |
Turn on annealing by setting the following in `paralleleureqa.jl`:
|
31 |
|
32 |
`const annealing = true`
|
33 |
+
|
34 |
+
Annealing allows each evolutionary cycle to turn down the exploration
|
35 |
+
rate over time: at the end (temperature 0), it will only select solutions
|
36 |
+
better than existing solutions.
|
37 |
+
|
38 |
+
The following parameter, parsimony, is how much to punish complex solutions:
|
39 |
+
`
|
40 |
+
const parsimony = 0.01
|
41 |
+
`
|
42 |
+
|
43 |
+
Finally, the following
|
44 |
+
determins how much to scale temperature by (T between 0 and 1).
|
45 |
+
`
|
46 |
+
const alpha = 10.0
|
47 |
+
`
|
48 |
+
Larger alpha means more exploration.
|
49 |
+
|
50 |
+
One can also adjust the relative probabilities of each mutation here:
|
51 |
+
```
|
52 |
+
weights = [8, 1, 1, 1]
|
53 |
+
```
|
54 |
+
(for: 1. perturb constant, 2. mutate operator,
|
55 |
+
3. append a node, 4. delete a subtree).
|
56 |
+
|
paralleleureqa.jl
CHANGED
@@ -29,7 +29,7 @@ for k=1:niterations
|
|
29 |
# Migration
|
30 |
for j=1:nthreads
|
31 |
for k in rand(1:npop, 50)
|
32 |
-
# Copy in case one gets
|
33 |
allPops[j].members[k] = deepcopy(bestPops.members[rand(1:size(bestPops.members)[1])])
|
34 |
end
|
35 |
end
|
|
|
29 |
# Migration
|
30 |
for j=1:nthreads
|
31 |
for k in rand(1:npop, 50)
|
32 |
+
# Copy in case one gets used twice
|
33 |
allPops[j].members[k] = deepcopy(bestPops.members[rand(1:size(bestPops.members)[1])])
|
34 |
end
|
35 |
end
|