Esempio n. 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);
        }
Esempio n. 2
0
 public StepInjectWithdrawConstraintTest()
 {
     _injectWithdrawRanges = new List <InjectWithdrawRangeByInventory>
     {
         (inventory : 0.0, (minInjectWithdrawRate : -44.85, maxInjectWithdrawRate : 56.8)),
         (inventory : 100.0, (minInjectWithdrawRate : -45.01, maxInjectWithdrawRate : 54.5)),
         (inventory : 300.0, (minInjectWithdrawRate : -45.78, maxInjectWithdrawRate : 52.01)),
         (inventory : 600.0, (minInjectWithdrawRate : -46.17, maxInjectWithdrawRate : 51.9)),
         (inventory : 800.0, (minInjectWithdrawRate : -46.99, maxInjectWithdrawRate : 50.8)),
         (inventory : 1000.0, (minInjectWithdrawRate : -46.99, maxInjectWithdrawRate : 50.8))
     };
     _stepConstraint = new StepInjectWithdrawConstraint(_injectWithdrawRanges);
 }