Example #1
0
        public void InventorySpaceUpperBound_ConstantInjectWithdrawRate_EqualsNextPeriodInventoryPlusMaxWithdrawalRateAdjustedForLoss()
        {
            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 = 320.0;
            const double nextPeriodMaxInventory = 620.0;
            double       thisPeriodMaxInventory = stepInjectWithdrawConstraint.InventorySpaceUpperBound(nextPeriodMinInventory, nextPeriodMaxInventory, minInventory, maxInventory, inventoryPercentLoss);

            const double expectedThisPeriodMaxInventory = (nextPeriodMaxInventory + maxWithdrawalRate) / (1 - inventoryPercentLoss);

            Assert.Equal(expectedThisPeriodMaxInventory, thisPeriodMaxInventory, 12);
        }
Example #2
0
        public void InventorySpaceUpperBound_InventoryDependentInjectWithdrawRate_ConsistentWithGetInjectWithdrawRange()
        {
            const double inventoryPercentLoss = 0.03;
            const double minInventory         = 0.0;
            const double maxInventory         = 1000.0;

            const double nextPeriodMinInventory = 320.0;
            const double nextPeriodMaxInventory = 590.5;
            double       thisPeriodMaxInventory = _stepConstraint.InventorySpaceUpperBound(nextPeriodMinInventory, nextPeriodMaxInventory, minInventory, maxInventory, inventoryPercentLoss);
            double       thisPeriodMaxWithdrawalRateAtInventory = _stepConstraint.GetInjectWithdrawRange(thisPeriodMaxInventory).MinInjectWithdrawRate;

            double derivedNextPeriodMaxInventory = thisPeriodMaxInventory * (1 - inventoryPercentLoss) + thisPeriodMaxWithdrawalRateAtInventory;

            Assert.Equal(nextPeriodMaxInventory, derivedNextPeriodMaxInventory, 12);
        }