forked from quaquel/pyNetLogo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.py
75 lines (54 loc) · 1.81 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'''
'''
import logging
import os
import sys
from multiprocessing import Process
import pyNetLogo
# Created on 1 Nov 2016
#
# .. codeauthor::jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl>
__all__ = []
# logging
root = logging.getLogger()
root.setLevel(logging.DEBUG)
ch = logging.StreamHandler(sys.stderr)
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter(' %(levelname)s - %(message)s')
ch.setFormatter(formatter)
root.addHandler(ch)
# on mac there is a stupid issue with getting the default jvm path
# this is related to some mac bug in java 8
# jvm_home = '/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre/lib/server/libjvm.dylib'
# link = pyNetLogo.NetLogoLink(jvm_home=jvm_home)
def run_61():
print("trying 6.1")
link = pyNetLogo.NetLogoLink()
model_file = os.path.join(link.netlogo_home,
'models/Sample Models/Biology/Wolf Sheep Predation.nlogo')
print(os.path.exists(model_file))
link.load_model(model_file)
def run_60():
print("trying 6.0")
link = pyNetLogo.NetLogoLink(netlogo_home='/Applications/Netlogo 6.0.4')
model_file = os.path.join(link.netlogo_home,
'models/Sample Models/Biology/Wolf Sheep Predation.nlogo')
print(os.path.exists(model_file))
link.load_model(model_file)
def run_53():
print("trying 5.3")
link = pyNetLogo.NetLogoLink(netlogo_home='/Applications/Netlogo 5.3.1')
model_file = os.path.join(link.netlogo_home,
'models/Sample Models/Biology/Wolf Sheep Predation.nlogo')
print(os.path.exists(model_file))
link.load_model(model_file)
if __name__ == '__main__':
p = Process(target=run_61)
p.start()
p.join()
p = Process(target=run_60)
p.start()
p.join()
p = Process(target=run_53)
p.start()
p.join()