-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
382 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# because multiprocessing Pool cannot run in interactive mode, we put it in a file | ||
|
||
from multiprocessing import Pool | ||
from starter import Agent | ||
import numpy as np | ||
|
||
def make_and_run(init_w): | ||
d = 8 | ||
w = np.full((3,d,d), init_w) | ||
a = Agent(side_size=d, weights=w) | ||
for e in range(50): | ||
a.episode() | ||
return a.escape_times | ||
|
||
def main(): | ||
p = Pool(6) | ||
# init_w -- 12 examples of each | ||
# agents = [0] * 12 | ||
agents = [0] * 12 | ||
results = [] | ||
|
||
for res in p.map(make_and_run, agents): | ||
results.append(res) | ||
|
||
print(results) | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# because multiprocessing Pool cannot run in interactive mode, we put it in a file | ||
|
||
from multiprocessing import Pool | ||
from starter import Agent | ||
import numpy as np | ||
|
||
def make_and_run(tau): | ||
a = Agent(tau=tau) | ||
for e in range(50): | ||
a.episode() | ||
return a.escape_times | ||
|
||
def main(): | ||
p = Pool(6) | ||
# tau -- 12 examples of each | ||
agents = [0.0] * 12 | ||
results = [] | ||
|
||
for res in p.map(make_and_run, agents): | ||
results.append(res) | ||
|
||
print(results) | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# because multiprocessing Pool cannot run in interactive mode, we put it in a file | ||
|
||
from multiprocessing import Pool | ||
from starter import Agent | ||
|
||
def make_and_run(size): | ||
a = Agent(side_size=size) | ||
for e in range(60): | ||
a.episode() | ||
# if 5 times in a row we escape in less than 150 steps | ||
if e > 5 and sum(a.escape_times[-5:]) / 5 < 150: | ||
break | ||
return [size, e] | ||
|
||
def main(): | ||
p = Pool(6) | ||
episodes_per_size = [] | ||
|
||
# 5 agents of each size from 6 -> 11 | ||
for res in p.map(make_and_run, sorted(list(range(7,12)) * 5)): | ||
episodes_per_size.append(res) | ||
|
||
print(episodes_per_size) | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|