Skip to content

Commit 3f491dc

Browse files
committed
Added preliminary experiment results and updated README
1 parent f0fd5ed commit 3f491dc

26 files changed

+223
-28
lines changed

ExperimentLogs.md

+105-15
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ Train without noise and denoiser. Evaluate without noise and denoiser.
1515
* Input Model: [`base/model1`](./SBAgent/models/base/model1.zip)
1616

1717
#### Evaluation Results
18-
*TBD*
18+
19+
| Metric | Value |
20+
|----------------------------|---------|
21+
| Success Rate | 73.50% |
22+
| Collision Rate | 26.50% |
23+
| Mean Incompletion Distance | N/A |
24+
| Mean Reward | -20.25 |
25+
| Mean Episode Length | 261.744 |
1926

2027
---
2128
## [Experiment 2A](./experimentConfigs/experiment2a.json)
@@ -33,7 +40,14 @@ Train without noise and denoiser. Evaluate with noise (0.01) but no denoiser.
3340
* Input Model: [`base/model1`](./SBAgent/models/base/model1.zip)
3441

3542
#### Evaluation Results
36-
*TBD*
43+
44+
| Metric | Value |
45+
|----------------------------|---------|
46+
| Success Rate | 69.90% |
47+
| Collision Rate | 30.10% |
48+
| Mean Incompletion Distance | N/A |
49+
| Mean Reward | -86.17 |
50+
| Mean Episode Length | 257.42 |
3751

3852
---
3953
## [Experiment 2B](./experimentConfigs/experiment2b.json)
@@ -51,7 +65,14 @@ Train without noise and denoiser. Evaluate with noise (0.05) but no denoiser.
5165
* Input Model: [`base/model1`](./SBAgent/models/base/model1.zip)
5266

5367
#### Evaluation Results
54-
*TBD*
68+
69+
| Metric | Value |
70+
|----------------------------|---------|
71+
| Success Rate | 71.30% |
72+
| Collision Rate | 28.70% |
73+
| Mean Incompletion Distance | N/A |
74+
| Mean Reward | -65.85 |
75+
| Mean Episode Length | 262.001 |
5576

5677
---
5778
## [Experiment 2C](./experimentConfigs/experiment2c.json)
@@ -69,7 +90,14 @@ Train without noise and denoiser. Evaluate with noise (0.1) but no denoiser.
6990
* Input Model: [`base/model1`](./SBAgent/models/base/model1.zip)
7091

7192
#### Evaluation Results
72-
*TBD*
93+
94+
| Metric | Value |
95+
|----------------------------|---------|
96+
| Success Rate | 71.00% |
97+
| Collision Rate | 29.00% |
98+
| Mean Incompletion Distance | N/A |
99+
| Mean Reward | -66.10 |
100+
| Mean Episode Length | 258.97 |
73101

74102
---
75103

@@ -88,11 +116,18 @@ Train without noise and denoiser. Evaluate with both noise (0.01) and denoiser(L
88116
* Input Model: [`base/model1`](./SBAgent/models/base/model1.zip)
89117

90118
#### Evaluation Results
91-
*TBD*
119+
120+
| Metric | Value |
121+
|----------------------------|---------|
122+
| Success Rate | 67.70% |
123+
| Collision Rate | 32.30% |
124+
| Mean Incompletion Distance | N/A |
125+
| Mean Reward | -133.16 |
126+
| Mean Episode Length | 257.793 |
92127

93128
---
94129

95-
## Ex[periment 3B](./experimentConfigs/experiment3b.json)
130+
## [Experiment 3B](./experimentConfigs/experiment3b.json)
96131

97132
Train without noise and denoiser. Evaluate with both noise (0.05) and denoiser (LPF).
98133
### Train Parameters
@@ -107,7 +142,14 @@ Train without noise and denoiser. Evaluate with both noise (0.05) and denoiser (
107142
* Input Model: [`base/model1`](./SBAgent/models/base/model1.zip)
108143

109144
#### Evaluation Results
110-
*TBD*
145+
146+
| Metric | Value |
147+
|----------------------------|---------|
148+
| Success Rate | 70.80% |
149+
| Collision Rate | 29.20% |
150+
| Mean Incompletion Distance | N/A |
151+
| Mean Reward | -74.76 |
152+
| Mean Episode Length | 260.713 |
111153

112154
---
113155

@@ -126,7 +168,14 @@ Train without noise and denoiser. Evaluate with both noise (0.1) and denoiser (L
126168
* Input Model: [`base/model1`](./SBAgent/models/base/model1.zip)
127169

128170
#### Evaluation Results
129-
*TBD*
171+
172+
| Metric | Value |
173+
|----------------------------|---------|
174+
| Success Rate | 69.90% |
175+
| Collision Rate | 30.10% |
176+
| Mean Incompletion Distance | N/A |
177+
| Mean Reward | -95.42 |
178+
| Mean Episode Length | 262.544 |
130179

131180
---
132181

@@ -145,7 +194,14 @@ Train without noise and denoiser. Evaluate with both noise (0.01) and denoiser (
145194
* Input Model: [`base/model1`](./SBAgent/models/base/model1.zip)
146195

147196
#### Evaluation Results
148-
*TBD*
197+
198+
| Metric | Value |
199+
|----------------------------|---------|
200+
| Success Rate | 71.40% |
201+
| Collision Rate | 28.60% |
202+
| Mean Incompletion Distance | N/A |
203+
| Mean Reward | -63.36 |
204+
| Mean Episode Length | 262.162 |
149205

150206
---
151207

@@ -164,7 +220,14 @@ Train without noise and denoiser. Evaluate with both noise (0.05) and denoiser (
164220
* Input Model: [`base/model1`](./SBAgent/models/base/model1.zip)
165221

166222
#### Evaluation Results
167-
*TBD*
223+
224+
| Metric | Value |
225+
|----------------------------|---------|
226+
| Success Rate | 70.10% |
227+
| Collision Rate | 29.90% |
228+
| Mean Incompletion Distance | N/A |
229+
| Mean Reward | -79.07 |
230+
| Mean Episode Length | 256.643 |
168231

169232
---
170233

@@ -183,7 +246,14 @@ Train without noise and denoiser. Evaluate with both noise (0.1) and denoiser (K
183246
* Input Model: [`base/model1`](./SBAgent/models/base/model1.zip)
184247

185248
#### Evaluation Results
186-
*TBD*
249+
250+
| Metric | Value |
251+
|----------------------------|---------|
252+
| Success Rate | 68.60% |
253+
| Collision Rate | 31.40% |
254+
| Mean Incompletion Distance | N/A |
255+
| Mean Reward | -108.65 |
256+
| Mean Episode Length | 254.936 |
187257

188258
---
189259

@@ -202,7 +272,14 @@ Train with noise (0.01) but no denoiser. Evaluate with noise (0.01) but no denoi
202272
* Input Model: [`base/model2_0.01`](./SBAgent/models/base/model2_0.01.zip)
203273

204274
#### Evaluation Results
205-
*TBD*
275+
276+
| Metric | Value |
277+
|----------------------------|---------|
278+
| Success Rate | 68.80% |
279+
| Collision Rate | 31.20% |
280+
| Mean Incompletion Distance | N/A |
281+
| Mean Reward | -114.47 |
282+
| Mean Episode Length | 258.475 |
206283

207284
---
208285

@@ -221,7 +298,14 @@ Train with noise (0.05) but no denoiser. Evaluate with noise (0.05) but no denoi
221298
* Input Model: [`base/model2_0.05`](./SBAgent/models/base/model2_0.05.zip)
222299

223300
#### Evaluation Results
224-
*TBD*
301+
302+
| Metric | Value |
303+
|----------------------------|---------|
304+
| Success Rate | 69.90% |
305+
| Collision Rate | 30.10% |
306+
| Mean Incompletion Distance | N/A |
307+
| Mean Reward | -120.60 |
308+
| Mean Episode Length | 278.681 |
225309

226310
---
227311

@@ -239,8 +323,14 @@ Train with noise (0.1) but no denoiser. Evaluate with noise (0.1) but no denoise
239323
* Environment Config: [`v2_0.1.json`](./configs/v2_0.1.json)
240324
* Input Model: [`base/model2_0.1`](./SBAgent/models/base/model2_0.1.zip)
241325

242-
#### Evaluation Results
243-
*TBD*
326+
327+
| Metric | Value |
328+
|----------------------------|---------|
329+
| Success Rate | 67.20% |
330+
| Collision Rate | 32.80% |
331+
| Mean Incompletion Distance | N/A |
332+
| Mean Reward | -183.71 |
333+
| Mean Episode Length | 284.602 |
244334

245335
---
246336

README.md

+67-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Check out [experiment1.json](./experimentConfigs/experiment1.json) for reference
5757

5858
From here, you do one of two things:
5959

60-
1. Train Step: Run `TrainDispatcher.py` to the model on the given environment. The script is written to dispatch a batch job on IIIT-H's HPC cluster, so modify it to run on your machine as needed.
60+
1. Train Step: Run `TrainDispatcher.py` to the model on the given environment. The script is written to dispatch a batch job on IIIT-H's HPC cluster, or on your local machine with the `--local` flag.
6161

6262
2. Evaluation Step: Run `SBAgent/EvaluateExperiment.py` to evaluate the model in the given environment.
6363

@@ -141,4 +141,69 @@ To use a Kalman Filter as the Denoise Engine, set `"denoiseEngine"` to the follo
141141
}
142142
```
143143

144-
* `processNoise`: Standard Deviation of the process noise.
144+
* `processNoise`: Standard Deviation of the process noise.
145+
146+
147+
## The Scripts
148+
149+
### `TrainDispatcher.py`
150+
151+
Used to perform the train phase of a given experiment. To run it, run:
152+
153+
```bash
154+
python TrainDispatcher.py [-h] [-s STEPS] [--local] experimentConfigFile
155+
```
156+
157+
* `experimentConfigFile` is path to the experiment configuration file.
158+
* `-s` to specify the number of timesteps to train for. Defaults to 2,000,000.
159+
* Add the `--local` flag to run the training on your local machine. If this flag is omitted, the script generates a batch job configuration and dispatches it on one of the nodes on IIIT-H's HPC.
160+
161+
### `SBAgent/EvaluateExperiment.py`
162+
163+
Used to perform the evaluation phase of a given experiment. To run it, run:
164+
165+
```bash
166+
cd SBAgent
167+
python EvaluateExperiment.py [-h] [-t TRIALS] [--gui] [--no-gui] experimentConfigFile
168+
```
169+
170+
* `experimentConfigFile` is path to the experiment configuration file
171+
* `-t` to specify the number of episodes used for evaluation. Defaults to 10.
172+
* `--gui` or `--no-gui` to specify whether or not to render the simulation. If no flag is provided, then GUI is NOT launched by default.
173+
174+
### `SBAgent/EvaluateModel.py`
175+
176+
Used to evaluate a given model on a given environment. Allows flexibility outside of a defined experiment. To run it, run:
177+
178+
```bash
179+
cd SBAgent
180+
python EvaluateModel.py [-h] [-t TRIALS] [--gui] [--no-gui] configFileName inputModelPath
181+
```
182+
* `configFileName` is the name of the environment configuration file inside the `config` directory.
183+
* `inputModelPath` is the path to the model to be evaluated.
184+
* `-t` to specify the number of episodes used for evaluation. Defaults to 10.
185+
* `--gui` or `--no-gui` to specify whether or not to render the simulation. If no flag is provided, then GUI is NOT launched by default.
186+
187+
### `SBAgent/TrainModel.py`
188+
189+
Used to train a model on a given environment. Allows flexibity outside of a defined experiment. Used internally by `TrainDispatcher.py`.
190+
191+
192+
```bash
193+
cd SBAgent
194+
python TrainModel.py [-h] [-s STEPS] configFileName outputModelName
195+
```
196+
197+
* `configFileName` is the name of the environment configuration file inside the `config` directory.
198+
* `outputModelName` is the name to save the output model as. This must begin with either `base/` or `finetuned/` (for the current script it is should ideally always be `base/`) followed by the name of the model. The trained model is then saved in `SBAgent/models/<outputModelName>`.
199+
* `-s` to specify the number of timesteps to train for. Default is 2,000,000.
200+
201+
## Evironment Configurations
202+
203+
Check out [ConfigLogs.md](./configs/ConfigLogs.md) for the description for every environement.
204+
205+
## Models
206+
207+
Check out [base/ModelLogs.md](./SBAgent/models/base/ModelLogs.md) for the description of every model trained from scratch.
208+
209+
Check out [finetuned/ModelLogs.md](./SBAgent/models/finetuned/ModelLogs.md) for the description of every model finetuned from an existing model.

SBAgent/EvaluateExperiment.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,29 @@
1818
parser.add_argument('--no-gui', action='store_false', dest='gui', help='Disable GUI')
1919
args = parser.parse_args()
2020

21-
2221
np.random.seed(42)
2322
random.seed(42)
2423

2524
with open(args.experimentConfigFile, 'r') as f:
2625
experimentConfig = json.load(f)
2726

2827
experimentName = experimentConfig["name"]
29-
configFileName = experimentConfig["trainParameters"]["config"]
30-
modelName = experimentConfig["trainParameters"]["outputModelName"]
28+
trainEnvConfig = experimentConfig["trainParameters"]["config"]
29+
evaluationEnvConfig = experimentConfig["evaluationParameters"]["config"]
30+
modelName = experimentConfig["evaluationParameters"]["inputModelName"]
3131

3232
print(f"Running Evaluation on {experimentName}")
3333

34-
env = EnvBuilder.buildEnvFromConfig(os.path.join('..', 'configs', configFileName), gui=args.gui)
34+
trainEnv = EnvBuilder.buildEnvFromConfig(os.path.join('..', 'configs', trainEnvConfig), gui=False)
35+
print("Model trained on")
36+
print(trainEnv)
37+
trainEnv.close()
38+
del trainEnv
39+
40+
print("Evaluating Model on")
41+
env = EnvBuilder.buildEnvFromConfig(os.path.join('..', 'configs', evaluationEnvConfig), gui=args.gui)
42+
print(env)
43+
3544
agent = PPO.load(os.path.join('models', modelName, 'best_model'))
3645

3746
totalTrials = args.trials
@@ -73,4 +82,5 @@
7382
}
7483

7584
evaluationTable = [[k, v] for k,v in evaluationResults.items()]
85+
print()
7686
print(tabulate(evaluationTable, headers=["Metric", "Value"], tablefmt='github'))

SBAgent/TrainModel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828

2929
agent = PPO("MlpPolicy", env, verbose=1, tensorboard_log=os.path.join('logs', modelName))
3030
agent.learn(n_steps, callback=eval_callback, tb_log_name="train_logs")
31-
31+
agent.save(os.path.join('models', modelName, 'final_model'))
3232

138 KB
Binary file not shown.
138 KB
Binary file not shown.
138 KB
Binary file not shown.
138 KB
Binary file not shown.
138 KB
Binary file not shown.

SBAgent/models/finetuned/ModelLogs.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Model Logs
4.19 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

envs/ObstacleAviary.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,4 +387,4 @@ def _randomizeDroneSpawnLocation(self):
387387
(self.geoFence.ymin + self.geoFence.ymax) + np.random.uniform(-y_scale/2 + ObstacleAviary.COLLISION_BOUND_RADIUS*2, y_scale/2 - ObstacleAviary.COLLISION_BOUND_RADIUS*2),
388388
(self.geoFence.zmin + self.geoFence.zmax)/2])
389389

390-
self.INIT_XYZS = np.array([self.initPos])
390+
self.INIT_XYZS = np.array([self.initPos])
-16 Bytes
Binary file not shown.

envs/utils/DenoiseEngines.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ class LPFDenoiseEngine:
88
def __init__(self, order:int, criticalFreq:float, ftype:str, freq:float) -> None:
99

1010
self.order = order
11-
self.b, self.a = scipy.signal.iirfilter(order, criticalFreq, fs=freq, btype="low", ftype=ftype)
11+
self.criticalFreq = criticalFreq
12+
self.ftype = ftype
13+
self.b, self.a = scipy.signal.iirfilter(self.order, self.criticalFreq, fs=freq, btype="low", ftype=self.ftype)
1214

1315
self._xs = deque([], maxlen=len(self.b))
1416
self._ys = deque([], maxlen=len(self.a)-1)
@@ -42,11 +44,17 @@ def reset(self, _:np.ndarray) -> None:
4244
self.observedHistory.clear()
4345
self.denoisedHistory.clear()
4446

47+
def __str__(self) -> str:
48+
49+
return f"LPFDenoiseEngine({self.order}, {self.criticalFreq}, {self.ftype})"
50+
4551
class KFDenoiseEngine:
4652

4753
def __init__(self, measurementNoise:float, dt:float, fixedAltitude:bool, initPos:np.ndarray, processNoise:float=0) -> None:
4854

4955
self.fixedAltitude = fixedAltitude
56+
self.processNoise = processNoise
57+
5058
if self.fixedAltitude:
5159

5260
# state = [x, y, vx, vy]
@@ -138,6 +146,8 @@ def reset(self, initPos) -> None:
138146
x0 = np.array([initPos[0], initPos[1], initPos[2], 0, 0, 0])
139147

140148
self.initFilter(A, C, x0, P0, Q, R)
141-
149+
150+
def __str__(self) -> str:
151+
return f"KFDenoiseEngine({self.processNoise})"
142152

143153

0 commit comments

Comments
 (0)