示例#1
0
        public void InventorySpaceLowerBound_ConstantInjectWithdrawRate_EqualsNextPeriodInventoryMinusMaxInjectRateAdjustedForLoss()
        {
            const double maxInjectionRate  = 56.8;
            const double maxWithdrawalRate = 47.12;

            var injectWithdrawRange = new InjectWithdrawRange(-maxWithdrawalRate, maxInjectionRate);

            const double inventoryPercentLoss = 0.03;
            const double minInventory         = 0.0;
            const double maxInventory         = 1000.0;

            var injectWithdrawalRanges = new List <InjectWithdrawRangeByInventory>
            {
                (inventory : 0.0, injectWithdrawRange),
                (inventory : 100.0, injectWithdrawRange),
                (inventory : 300.0, injectWithdrawRange),
                (inventory : 600.0, injectWithdrawRange),
                (inventory : 800.0, injectWithdrawRange),
                (inventory : 1000.0, injectWithdrawRange),
            };

            var stepInjectWithdrawConstraint = new StepInjectWithdrawConstraint(injectWithdrawalRanges);

            const double nextPeriodMinInventory = 620.0;
            const double nextPeriodMaxInventory = 870.0;
            double       thisPeriodMinInventory = stepInjectWithdrawConstraint.InventorySpaceLowerBound(nextPeriodMinInventory, nextPeriodMaxInventory, minInventory, maxInventory, inventoryPercentLoss);

            const double expectedThisPeriodMinInventory = (nextPeriodMinInventory - maxInjectionRate) / (1 - inventoryPercentLoss);

            Assert.Equal(expectedThisPeriodMinInventory, thisPeriodMinInventory, 12);
        }
示例#2
0
        public void InventorySpaceLowerBound_InventoryDependentInjectWithdrawRate_ConsistentWithGetInjectWithdrawRange()
        {
            const double inventoryPercentLoss = 0.03;
            const double minInventory         = 0.0;
            const double maxInventory         = 1000.0;

            const double nextPeriodMinInventory             = 552.0;
            const double nextPeriodMaxInventory             = 734.0;
            double       thisPeriodMinInventory             = _stepConstraint.InventorySpaceLowerBound(nextPeriodMinInventory, nextPeriodMaxInventory, minInventory, maxInventory, inventoryPercentLoss);
            double       thisPeriodMaxInjectRateAtInventory = _stepConstraint.GetInjectWithdrawRange(thisPeriodMinInventory).MaxInjectWithdrawRate;

            double derivedNextPeriodMinInventory = thisPeriodMinInventory * (1 - inventoryPercentLoss) + thisPeriodMaxInjectRateAtInventory;

            Assert.Equal(nextPeriodMinInventory, derivedNextPeriodMinInventory, 12);
        }