Skip to content

Commit e10f1c5

Browse files
committed
Separated build process to support NetLogo version 6. Added separate demo models and test models for NetLogo 5 & 6. Updated documentation.
1 parent c6fb3d8 commit e10f1c5

10 files changed

Lines changed: 1647 additions & 25 deletions

File tree

README.md

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ extensions [dbscan]
2525
2626
; Cluster agents by variable "wealth", with at least 3 members to constitute a cluster, and a maximum value difference of 3
2727
let clusters dbscan:cluster-by-variable agents "wealth" 3 3
28+
```
29+
30+
You can then use the cluster information to modify the output, e.g. by colouring and labelling the turtles.
2831

32+
Example (NetLogo 5):
33+
34+
```
2935
; Colour and label the agents by cluster
3036
let ctr 1
3137
(foreach clusters (n-of (length clusters) base-colors)
@@ -38,6 +44,21 @@ let ctr 1
3844
set ctr (ctr + 1) ])
3945
```
4046

47+
The same example in NetLogo 6:
48+
49+
```
50+
; Colour and label the agents by cluster
51+
let ctr 1
52+
(foreach clusters (n-of (length clusters) base-colors)
53+
[ [ x y ] -> let aset turtles with [ member? self x ]
54+
ask aset
55+
[ set color y
56+
set label (word "ID: " who ", Cluster: " ctr ", Wealth: " wealth) ]
57+
; Print agent sets
58+
output-print (word "Cluster " ctr ": " aset)
59+
set ctr (ctr + 1) ])
60+
```
61+
4162
### Clustering by location
4263

4364
Syntax: `cluster-by-location` *agentset-to-be-clustered* *minimum-members* *maximum-distance*
@@ -56,35 +77,36 @@ extensions [dbscan]
5677
5778
; Cluster agents by location, with at least 3 members to constitute a cluster, and a maximum distance of 3
5879
let clusters dbscan:cluster-by-location agents 3 3
59-
60-
; Colour and label individual agents by cluster
61-
let ctr 1
62-
(foreach clusters (n-of (length clusters) base-colors)
63-
[ let aset turtles with [member? self ?1 ]
64-
ask aset
65-
[ set color ?2
66-
set label (word "ID: " who ", Cluster: " ctr) ]
67-
; Print agent sets
68-
output-print (word "Cluster " ctr ": " aset)
69-
set ctr (ctr + 1) ])
7080
```
7181

82+
The clusters can then be used as shown in the previous section.
83+
7284
## Demo
7385

74-
For more comprehensive examples for both reporters, try out the demo under `demo/dbscan-clustering-demo.nlogo`
86+
For more comprehensive examples for both reporters, try out the demo that corresponds to your NetLogo version.
87+
88+
* For NetLogo 5, use `demo/dbscan-clustering-demo-v5.nlogo`
89+
90+
* For NetLogo 6, use `demo/dbscan-clustering-demo-v6.nlogo`
7591

76-
Clustering agents by location should produce the following output.
92+
Clustering agents by location should produce the following output (irrespective of NetLogo version).
7793

7894
![Location-based clustering demo output](https://github.com/chrfrantz/NetLogo-Extension-DBSCAN/raw/master/doc/ExampleLocationBasedClusteringOutput.png)
7995

8096
## Deployment
8197

8298
### Variant 1: Downloading jar files
8399

84-
To install the extension, download the zip file containing the latest version from the releases page. It contains a folder `dbscan` that contains all relevant jar files. Unzip it to the `NetLogo/extensions` folder of your NetLogo installation (the final structure should be `NetLogo/extensions/dbscan/<jar files>`).
100+
To install the extension, download the zip file containing the latest version from the releases page for your NetLogo version (5 or 6). It contains a folder `dbscan` that contains all relevant jar files. Unzip it to the `NetLogo/extensions` folder of your NetLogo installation (the final structure should correspond to `NetLogo x.x.x/app/extensions/dbscan/<jar files>`, with `x.x.x` being the installed NetLogo version).
85101

86102
### Variant 2: Building from source
87103

88-
You can build the extension from scratch using maven by running `mvn package` after cloning the repository. In addition, you will need to do the same for the [DBSCAN repository](https://github.com/chrfrantz/DBSCAN.git) which contains the underlying DBSCAN algorithm. Place both jar files in the extensions subfolder `dbscan` (following the structure described under Variant 1).
104+
You can build the extension from scratch using maven after cloning the repository.
105+
106+
* For NetLogo version 5, run `mvn package -f pom-v5.xml`
107+
108+
* For NetLogo version 6, run `mvn package -f pom-v6.xml`
109+
110+
In addition, you will need to build the [DBSCAN repository](https://github.com/chrfrantz/DBSCAN.git) (Command: `mvn package`) which contains the underlying DBSCAN algorithm. Place both jar files in the extensions subfolder `dbscan` (following the structure described under Variant 1).
89111

90112

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ globals [
66
max-wealth
77
]
88

9-
breed [ agents agent ]
9+
breed [ agents agt ]
1010

1111
agents-own [
1212
wealth

0 commit comments

Comments
 (0)