-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathAgentSystem.js
More file actions
38 lines (30 loc) · 833 Bytes
/
AgentSystem.js
File metadata and controls
38 lines (30 loc) · 833 Bytes
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
export default class AgentSystem {
constructor(args = {}) {
if (args.algovivo == null) throw new Error("algovivo required");
this.algovivo = args.algovivo;
if (args.system == null) throw new Error("system required");
this.system = args.system;
this.policy = null;
}
get numVertices() {
return this.system.numVertices;
}
set(args = {}) {
const mesh = args.mesh;
const policy = args.policy;
if (mesh == null) throw new Error("mesh required");
this.dispose();
this.system.set(mesh);
if (policy != null) {
this.policy = new this.algovivo.nn.MLPPolicy({ system: this.system });
this.policy.loadData(policy);
}
}
dispose() {
if (this.policy != null) {
this.policy.dispose();
this.policy = null;
}
this.system.dispose();
}
}