- (prePeek + bottomPeek + Math.max((initFire - 2), 0) * pop);
- initItemsNeeded;
    private int calculateRemaining() {        // the number of times this filter fires in the initialization        // schedule        int initFire = initMult;        // if this is not a twostage, fake it by adding to initFire,        // so we always think the preWork is called        // if (!(filter instanceof SIRTwoStageFilter))        if (!filter.isTwoStage())            initFire++;        // see my thesis for an explanation of this calculation        if (initFire - 1 > 0) {            bottomPeek = Math.max(0, peek - (prePeek - prePop));        } else            bottomPeek = 0;        // don't call initItemsReceived() here it        // may cause an infinite loop because it creates filter infos        int initItemsRec = 0;        if (traceNode.getPrevious().isFilterTrace()) {            FilterContent filterC = ((FilterTraceNode) traceNode.getPrevious())                .getFilter();            initItemsRec = filterC.getPushInt() * filterC.getInitMult();            if (filterC.isTwoStage()) {                initItemsRec -= filterC.getPushInt();                initItemsRec += filterC.getInitPush();            }        } else { // previous is an input trace            InputTraceNode in = (InputTraceNode) traceNode.getPrevious();            // add all the upstream filters items that reach this filter            for (int i = 0; i < in.getWeights().length; i++) {                Edge incoming = in.getSources()[i];                FilterContent filterC = ((FilterTraceNode) incoming.getSrc()                                         .getPrevious()).getFilter();                // calculate the init items sent by the upstream filter                int upstreamInitItems = 0;                upstreamInitItems = filterC.getPushInt()                    * filterC.getInitMult();                if (filterC.isTwoStage()) {                    upstreamInitItems -= filterC.getPushInt();                    upstreamInitItems += filterC.getInitPush();                }                initItemsRec += (int) ((double) upstreamInitItems * incoming                                       .getSrc().ratio(incoming));            }        }        remaining = initItemsRec            - (prePeek + bottomPeek + Math.max((initFire - 2), 0) * pop);        assert remaining >= 0 : filter.getName()            + ": Error calculating remaining " + initItemsRec + " < "            + (prePeek + bottomPeek + Math.max((initFire - 2), 0) * pop);        return remaining;    }