File size: 8,676 Bytes
03df314
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# Fleet Utilization Benchmarks

This directory contains tools for analyzing fleet utilization metrics for the metro train scheduling system.

## Overview

Fleet utilization analysis provides critical data for the **Results** section of your research paper, specifically:

1. **Minimum Fleet Size**: Calculate the minimum number of trains required to maintain service frequency
2. **Coverage Efficiency**: Measure percentage of peak vs. off-peak demand covered
3. **Train Utilization Rate**: Analyze average operational hours per train vs. idle time

## Components

### 1. `fleet_analyzer.py`
Core analysis module with the `FleetUtilizationAnalyzer` class.

**Key Features:**
- Calculate minimum fleet size based on headway requirements
- Analyze demand coverage (peak vs. off-peak)
- Compute train utilization rates
- Generate efficiency scores
- Find optimal fleet configurations

**Key Classes:**
- `FleetUtilizationAnalyzer`: Main analysis engine
- `FleetUtilizationMetrics`: Data class for results

### 2. `benchmark_fleet_utilization.py`
Comprehensive benchmarking script for research paper data collection.

**Features:**
- Test multiple fleet sizes
- Comparative analysis
- Statistical summaries
- JSON and text report generation

## Usage

### Quick Start

```bash
# Run comprehensive benchmark
python benchmark_fleet_utilization.py
```

This will:
- Analyze fleet sizes from 10-40 trains
- Calculate minimum requirements
- Measure coverage efficiency
- Compute utilization rates
- Generate JSON data and text report

### Custom Analysis

```python
from fleet_analyzer import FleetUtilizationAnalyzer

analyzer = FleetUtilizationAnalyzer()

# Analyze specific fleet size
metrics = analyzer.analyze_fleet_configuration(
    total_fleet=25,
    trains_in_maintenance=2
)

print(f"Coverage: {metrics.overall_coverage_percent:.1f}%")
print(f"Utilization: {metrics.utilization_rate_percent:.1f}%")

# Find optimal fleet size
optimal_size, optimal_metrics = analyzer.find_optimal_fleet_size(
    min_coverage_required=95.0
)
print(f"Optimal Fleet: {optimal_size} trains")
```

### Programmatic Benchmark

```python
from benchmark_fleet_utilization import FleetUtilizationBenchmark

benchmark = FleetUtilizationBenchmark()

# Run custom analysis
benchmark.run_comprehensive_analysis(
    fleet_sizes=[15, 20, 25, 30, 35],
    maintenance_rate=0.1
)

# Save results
benchmark.save_results("my_results.json")
benchmark.generate_report("my_report.txt")
```

## Kochi Metro Configuration

The analyzer uses real Kochi Metro parameters:

- **Route Length**: 25.612 km
- **Average Speed**: 35 km/h (operating speed)
- **Service Hours**: 5:00 AM - 11:00 PM (18 hours)
- **Peak Hours**: 
  - Morning: 7:00-10:00 AM
  - Evening: 5:00-8:00 PM
- **Target Headways**:
  - Peak: 5 minutes
  - Off-Peak: 10 minutes
- **Turnaround Time**: 10 minutes

## Output Files

### JSON Results (`fleet_utilization_benchmark_*.json`)
Complete data structure with:
- Metadata and configuration
- Detailed metrics for each fleet size
- Comparative statistics
- Optimal fleet configuration

### Text Report (`fleet_utilization_report_*.txt`)
Human-readable report with:
- Executive summary
- Optimal fleet configuration
- Comparative analysis
- Detailed results for each fleet size

## Metrics Explained

### 1. Minimum Fleet Size
**Formula**: `(Round Trip Time / Headway) + Buffer + Maintenance Reserve`

- Accounts for route travel time
- Includes operational buffers
- Considers maintenance requirements

**Research Paper Usage:**
> "Analysis revealed that a minimum fleet of 18 trains is required to maintain the target 5-minute headway during peak hours on the 25.612 km route."

### 2. Coverage Efficiency

**Metrics:**
- Peak demand coverage (%)
- Off-peak demand coverage (%)
- Overall weighted coverage (%)

**Research Paper Usage:**
> "A fleet of 25 trains achieved 100% peak demand coverage and 98.5% overall coverage across the 18-hour service period."

### 3. Train Utilization Rate

**Metrics:**
- Average operational hours per train
- Average idle hours per train
- Utilization rate percentage

**Formula**: `Utilization % = (Operational Hours / 24) × 100`

**Research Paper Usage:**
> "Fleet utilization analysis demonstrated an average of 16.2 operational hours per train (67.5% utilization rate), with 7.8 hours of scheduled idle time for charging and maintenance."

## Example Results

### Minimum Fleet Size Analysis
```
Fleet Size: 25 trains
Minimum Required: 18 trains
Excess Capacity: 7 trains (38.9%)

Peak Service: 15 trains
Off-Peak Service: 8 trains
Standby: 3 trains
Maintenance: 2 trains
```

### Coverage Efficiency
```
Peak Demand Coverage: 100.0%
Off-Peak Demand Coverage: 100.0%
Overall Coverage: 100.0%
```

### Utilization Rates
```
Avg Operational Hours/Train: 16.20 hours/day
Avg Idle Hours/Train: 7.80 hours/day
Utilization Rate: 67.5%
```

## Visualization Tips for Paper

### Suggested Graphs/Tables

1. **Fleet Size vs. Coverage Graph**
   - X-axis: Fleet Size (10-40 trains)
   - Y-axis: Coverage Percentage
   - Show peak and off-peak separately

2. **Utilization Rate Table**
   ```
   Fleet Size | Operational Hours | Idle Hours | Utilization %
   10         | 16.2             | 7.8        | 67.5%
   15         | 16.2             | 7.8        | 67.5%
   ...
   ```

3. **Efficiency Score Comparison**
   - Bar chart showing fleet efficiency vs. cost efficiency
   - Compare different fleet sizes

4. **Optimal Fleet Configuration Diagram**
   - Visual breakdown of train allocation
   - Service / Standby / Maintenance distribution

## Advanced Usage

### Sensitivity Analysis

```python
analyzer = FleetUtilizationAnalyzer()

# Test different maintenance rates
for maintenance_rate in [0.05, 0.10, 0.15, 0.20]:
    metrics = analyzer.analyze_fleet_configuration(
        total_fleet=25,
        trains_in_maintenance=int(25 * maintenance_rate)
    )
    print(f"Maintenance {maintenance_rate*100}%: Coverage {metrics.overall_coverage_percent:.1f}%")
```

### Peak Hour Variations

```python
# Modify peak hours
analyzer.peak_periods = [
    (time(6, 0), time(9, 0)),   # Earlier morning peak
    (time(16, 0), time(19, 0)),  # Earlier evening peak
]

metrics = analyzer.analyze_fleet_configuration(25, 2)
```

## Integration with Other Benchmarks

Combine with schedule generation benchmarks:

```python
from benchmark_schedule_performance import SchedulePerformanceBenchmark
from benchmark_fleet_utilization import FleetUtilizationBenchmark

# Performance benchmark
perf_benchmark = SchedulePerformanceBenchmark()
perf_results = perf_benchmark.run_comprehensive_benchmark(
    fleet_sizes=[15, 20, 25, 30],
    num_runs=5
)

# Fleet utilization benchmark
fleet_benchmark = FleetUtilizationBenchmark()
fleet_benchmark.run_comprehensive_analysis(
    fleet_sizes=[15, 20, 25, 30]
)

# Cross-reference results for comprehensive analysis
```

## Research Paper Templates

### Results Section Template

```markdown
### Fleet Utilization Results

#### Minimum Fleet Size
Analysis of the Kochi Metro route (25.612 km, 22 stations) revealed that a 
minimum fleet of [X] trains is required to maintain target service frequencies. 
This accounts for a [Y]-minute round-trip time, including [Z] minutes of 
turnaround at terminal stations.

#### Coverage Efficiency
Fleet configuration testing demonstrated that:
- Peak demand (7-10 AM, 5-8 PM) requires [N] trains for 5-minute headways
- Off-peak periods require [M] trains for 10-minute headways
- A fleet of [K] trains achieves [P]% overall coverage

#### Train Utilization Rate
Utilization analysis across fleet sizes from 10-40 trains showed:
- Average operational hours: [H] hours per train per day
- Average idle time: [I] hours per train per day  
- Overall utilization rate: [U]%

These metrics indicate [interpretation of efficiency/optimization].
```

## Troubleshooting

### Common Issues

1. **Import Errors**: Ensure you're running from the correct directory
   ```bash
   cd /path/to/mlservice
   python benchmarks/fleet_utilization/benchmark_fleet_utilization.py
   ```

2. **Path Issues**: The benchmark automatically handles paths, but if needed:
   ```python
   sys.path.insert(0, '/path/to/mlservice')
   ```

## References

- Kochi Metro operational parameters
- Transit scheduling best practices
- Fleet optimization literature

## Future Enhancements

- [ ] Integration with real-time passenger data
- [ ] Dynamic headway adjustment
- [ ] Multi-line analysis
- [ ] Energy consumption correlation
- [ ] Cost-benefit analysis with operational costs

## Support

For questions or issues, refer to the main project documentation or examine the example usage in `__main__` blocks of each module.