if (horizon >= transitionTime)  { predictedBenefit = predictedBenefit + startStateProb*(transitionTime*intermediateStateBenefit + (horizon-transitionTime)*endStateBenefit - horizon*startStateBenefit); predictedCost = predictedCost + startStateProb*(transitionTime * aggregateCost(oneTimeCost, memorySize, bandwidthSize) + (horizon-transitionTime)*aggregateCost(continuingCost, memorySize, bandwidthSize)); } else  { predictedBenefit = predictedBenefit + startStateProb*(horizon*intermediateStateBenefit - horizon*startStateBenefit); predictedCost = predictedCost + startStateProb*(horizon*aggregateCost(oneTimeCost, memorySize, bandwidthSize)); } maxTransitionTime = Math.max(maxTransitionTime, transitionTime);
   private VariantEvaluation createVariantEvaluation            (AssetID assetID, AssetStateDimension asd, StateDimensionEstimation currentStateDimensionEstimation, ActionDescription thisVariantDescription, CostBenefitKnob knob) {        double memorySize = 1000.0; // FIX _ needs to be dynamic        double bandwidthSize = 1000.0; // FIX -needs to be dynamic        double predictedCost = 0.0;        double predictedBenefit = 0.0;        long maxTransitionTime = 0L;        long horizon = knob.getHorizon();        Vector startStateVector = asd.getPossibleStates();        Iterator startStateIterator = startStateVector.iterator();        while (startStateIterator.hasNext()) {            String startStateName = ((AssetState) startStateIterator.next()).getName();            double startStateProb;            double startStateBenefit;            double intermediateStateBenefit;            double endStateBenefit;            long transitionTime;            ActionCost oneTimeCost;            ActionCost continuingCost;            try {                startStateProb = currentStateDimensionEstimation.getProbability(startStateName);                AssetTransitionWithCost atwc = thisVariantDescription.getTransitionForState(startStateName);                startStateBenefit = computeStateBenefit(atwc.getStartValue(), knob);                intermediateStateBenefit = computeStateBenefit(atwc.getIntermediateValue(), knob);                endStateBenefit = computeStateBenefit(atwc.getEndValue(), knob);                transitionTime = atwc.getOneTimeCost().getTimeCost(); // assume for now that 1-time costs are all expressed in terms of time (and maybe other factors also)                oneTimeCost = atwc.getOneTimeCost();                continuingCost = atwc.getContinuingCost();                }            catch (BelievabilityException e) {                // Should be impossible to get here if the ActionDescription is correctly populated                throw new RuntimeException("Could not find an AssetState that the ActionDescription said it had");                }            if (horizon >= transitionTime)  { // the normal case                predictedBenefit = predictedBenefit + startStateProb*(transitionTime*intermediateStateBenefit + (horizon-transitionTime)*endStateBenefit - horizon*startStateBenefit);                predictedCost = predictedCost + startStateProb*(transitionTime                        * aggregateCost(oneTimeCost, memorySize, bandwidthSize) + (horizon-transitionTime)*aggregateCost(continuingCost, memorySize, bandwidthSize));            }            else  { // transition takes longer than the planning horizon, so action transition will not complete                predictedBenefit = predictedBenefit + startStateProb*(horizon*intermediateStateBenefit - horizon*startStateBenefit);                predictedCost = predictedCost + startStateProb*(horizon*aggregateCost(oneTimeCost, memorySize, bandwidthSize));            }            maxTransitionTime = Math.max(maxTransitionTime, transitionTime);        }        return new VariantEvaluation(thisVariantDescription, predictedCost, predictedBenefit, maxTransitionTime);    }}