HighwaySource source1 = Highway.getSourceByDate(TRAFFIC_DATA_DIR,
    new GregorianCalendar(1993, 3, 11).getTime(), 'S', 16600, (short)1, 0.1f);
source1.setCloseMode(Source.AUTOMATIC_CLOSE);
HighwaySource source2 = Highway.getSourceByDate(TRAFFIC_DATA_DIR,
    new GregorianCalendar(1993, 3, 11).getTime(), 'S', 16600, (short)2, 0.1f);
source2.setCloseMode(Source.AUTOMATIC_CLOSE);
HighwaySource source3 = Highway.getSourceByDate(TRAFFIC_DATA_DIR,
    new GregorianCalendar(1993, 3, 11).getTime(), 'S', 16600, (short)3, 0.1f);
source3.setCloseMode(Source.AUTOMATIC_CLOSE);
HighwaySource source4 = Highway.getSourceByDate(TRAFFIC_DATA_DIR,
    new GregorianCalendar(1993, 3, 11).getTime(), 'S', 16600, (short)4, 0.1f);
source4.setCloseMode(Source.AUTOMATIC_CLOSE);
HighwaySource source5 = Highway.getSourceByDate(TRAFFIC_DATA_DIR,
    new GregorianCalendar(1993, 3, 11).getTime(), 'S', 16600, (short)5, 0.1f);
source5.setCloseMode(Source.AUTOMATIC_CLOSE);

sources = new HighwaySource[]{source1, source2, source3, source4, source5};
final int[] sourceIDs = new int[]{0, 1, 2, 3, 4};

// size of a vehicle instance: 31 bytes
final BufferPipe[] bps = new BufferPipe[5];
for (int i = 0; i < sources.length; i++) {
	bps[i] = new BufferPipe(sources[i], sourceIDs[i], new MemoryManageableListQueue(objectSize), 1, objectSize, 0);
	bps[i].setMetaDataFactory(new MetaDataFactory(bps[i], DEFAULT_METADATA));
}

Union union = new Union(bps);

final BufferPipe bp = new BufferPipe(union, 0,  new MemoryManageableListQueue(objectSize), 1, objectSize, 0);
bp.setMetaDataFactory(new MetaDataFactory(bps[i], DEFAULT_METADATA));
Filter filter = new Filter(bp, new Predicate() {

protected Vehicle v;
protected double length, speed;

public boolean invoke(Object o) {
    v = (Vehicle)o;
    length = v.getLength();
    speed = v.getSpeed();
    if (length < 1d || length > 50d) return false;
    if (speed < 0d || speed > 100d) return false;
    return true;
}
});

// scheduler settings

// MTIQ Strategy
proc = new StrategyProcessor(
    new ComparatorStrategy( // MTIQ-Strategy
        new Controllable[] {bps[0], bps[1], bps[2], bps[3], bps[4], bp}, 
        new InverseComparator(new MemSizeComparator())
    ), 
    0, 
    1000
);
proc.start();

// Round-Robin Strategy
//              proc = new StrategyProcessor(
//                      new RoundRobinStrategy(
//                              new Controllable[] {bps[0], bps[1], bps[2], bps[3], bps[4], bp} 
//                      ), 
//                      0, 
//                      1000
//              );
//              proc.start();


scheduler = new TimeSliceScheduler();
scheduler.schedule(proc);
scheduler.schedule(source1.getProcessor());
scheduler.schedule(source2.getProcessor());
scheduler.schedule(source3.getProcessor());
scheduler.schedule(source4.getProcessor());
scheduler.schedule(source5.getProcessor());


// memory manager settings

final int globalMemSize = 4096;
// objectSize is 31 bytes, so 132 elements can be stored at all.

GlobalMemoryManager m = new GlobalMemoryManager(
    new UniformStrategy(
            globalMemSize, 
            new MemoryManageable[] {bps[0], bps[1], bps[2], bps[3], bps[4], bp}   
    )
);


sink = new SWTSink(filter, "SWTSink", true, tf, SWT.MIN);


monitors[0] = new SWTPerformanceMonitor((CompositeMetaData)bps[0].getMetaData(), tf, SWT.NONE);
monitors[1] = new SWTPerformanceMonitor((CompositeMetaData)bps[1].getMetaData(), tf, SWT.NONE);
monitors[2] = new SWTPerformanceMonitor((CompositeMetaData)bps[2].getMetaData(), tf, SWT.NONE);
monitors[3] = new SWTPerformanceMonitor((CompositeMetaData)bps[3].getMetaData(), tf, SWT.NONE);
monitors[4] = new SWTPerformanceMonitor((CompositeMetaData)bps[4].getMetaData(), tf, SWT.NONE);
monitors[5] = new SWTPerformanceMonitor((CompositeMetaData)bp.getMetaData(), tf, SWT.NONE);
