Search in sources :

Example 1 with CashStateMulti

use of sdp.cash.multiItem.CashStateMulti in project Stochastic-Inventory by RobinChen121.

the class MultiItemCashLookPolicy method main.

public static void main(String[] args) {
    double[] price = { 10, 5 };
    // higher margin vs lower margin
    double[] variCost = { 4, 2 };
    // initial cash
    double iniCash = 25;
    // initial inventory
    int iniInventory1 = 0;
    int iniInventory2 = 0;
    // higher average demand vs lower average demand
    double[][] demand = { { 6, 6 }, { 8, 8 } };
    // higher variance vs lower variance
    double[] coe = { 0.5, 0.25 };
    double[] salPrice = { 2, 1 };
    // horizon length
    int T = demand[0].length;
    double truncationQuantile = 0.999;
    int stepSize = 1;
    double minCashState = 0;
    double maxCashState = 10000;
    int minInventoryState = 0;
    int maxInventoryState = 200;
    int Qbound = 100;
    double discountFactor = 1;
    double Rmin = 25;
    double Rmax = 80;
    int incre = 2;
    int rowNum = (int) ((Rmax - Rmin) / incre) + 2;
    int row = 0;
    double[][] optResults = new double[rowNum][5];
    for (iniCash = Rmin; iniCash <= Rmax; iniCash = iniCash + incre) {
        // get demand possibilities for each period
        Distribution[][] distributions = new Distribution[demand.length][T];
        for (int t = 0; t < T; t++) {
            for (int i = 0; i < demand.length; i++) {
                distributions[t][i] = new PoissonDist(demand[i][t]);
            }
        }
        double[][][] pmf = new GetPmf(distributions, truncationQuantile, stepSize).getpmfMulti();
        // build action list for two items
        Function<CashStateMulti, ArrayList<Actions>> buildActionList = s -> {
            ArrayList<Actions> actions = new ArrayList<>();
            for (int i = 0; i < Qbound; i++) for (int j = 0; j < Qbound; j++) {
                if (variCost[0] * i + variCost[1] * j < s.getIniCash() + 0.1) {
                    Actions thisAction = new Actions(i, j);
                    actions.add(thisAction);
                }
            }
            return actions;
        };
        // Immediate Value Function
        ImmediateValueFunction<CashStateMulti, Actions, Demands, Double> immediateValue = (IniState, Actions, RandomDemands) -> {
            double action1 = Actions.getFirstAction();
            double action2 = Actions.getSecondAction();
            double demand1 = RandomDemands.getFirstDemand();
            double demand2 = RandomDemands.getSecondDemand();
            double endInventory1 = Math.max(0, IniState.getIniInventory1() + action1 - demand1);
            double endInventory2 = Math.max(0, IniState.getIniInventory2() + action2 - demand2);
            double revenue = price[0] * (IniState.getIniInventory1() + action1 - endInventory1) + price[1] * (IniState.getIniInventory2() + action2 - endInventory2);
            double orderingCosts = variCost[0] * action1 + variCost[1] * action2;
            double salValue = 0;
            if (IniState.getPeriod() == T - 1) {
                salValue = salPrice[0] * endInventory1 + salPrice[1] * endInventory2;
            }
            return revenue - orderingCosts + salValue;
        };
        // State Transition Function
        StateTransitionFunction<CashStateMulti, Actions, Demands, CashStateMulti> stateTransition = (IniState, Actions, RandomDemands) -> {
            double endInventory1 = IniState.getIniInventory1() + Actions.getFirstAction() - RandomDemands.getFirstDemand();
            endInventory1 = Math.max(0, endInventory1);
            double endInventory2 = IniState.getIniInventory2() + Actions.getSecondAction() - RandomDemands.getSecondDemand();
            endInventory2 = Math.max(0, endInventory2);
            double nextCash = IniState.getIniCash() + immediateValue.apply(IniState, Actions, RandomDemands);
            nextCash = nextCash > maxCashState ? maxCashState : nextCash;
            nextCash = nextCash < minCashState ? minCashState : nextCash;
            endInventory1 = endInventory1 > maxInventoryState ? maxInventoryState : endInventory1;
            endInventory2 = endInventory2 < minInventoryState ? minInventoryState : endInventory2;
            // rounding states to save computing time
            nextCash = (int) nextCash;
            endInventory1 = (int) endInventory1;
            endInventory2 = (int) endInventory2;
            return new CashStateMulti(IniState.getPeriod() + 1, endInventory1, endInventory2, nextCash);
        };
        /**
         *****************************************************************
         * Solve
         */
        CashRecursionMulti recursion = new CashRecursionMulti(discountFactor, pmf, buildActionList, stateTransition, immediateValue, T);
        int period = 1;
        CashStateMulti iniState = new CashStateMulti(period, iniInventory1, iniInventory2, iniCash);
        long currTime = System.currentTimeMillis();
        double finalValue = iniCash + recursion.getExpectedValueMulti(iniState);
        System.out.println("final optimal cash  is " + finalValue);
        System.out.println("optimal order quantity in the first priod is :  Q1 = " + recursion.getAction(iniState).getFirstAction() + ", Q2 = " + recursion.getAction(iniState).getSecondAction());
        double time = (System.currentTimeMillis() - currTime) / 1000;
        System.out.println("running time is " + time + "s");
        /**
         *****************************************************************
         * Simulating sdp results
         *
         * simulating results a little lower than SDP
         */
        int sampleNum = 10000;
        CashSimulationMulti simuation = new CashSimulationMulti(sampleNum, distributions, discountFactor, recursion, stateTransition, immediateValue);
        double simFinalValue = simuation.simulateSDPGivenSamplNumMulti(iniState);
        System.out.println(simFinalValue);
        /**
         *****************************************************************
         * try to find some ordering patters from optTable
         *
         * output results to excel
         */
        double Q1 = recursion.getAction(iniState).getFirstAction();
        double Q2 = recursion.getAction(iniState).getSecondAction();
        System.out.println("");
        optResults[row][0] = iniInventory1;
        optResults[row][1] = iniInventory2;
        optResults[row][2] = iniCash;
        optResults[row][3] = Q1;
        optResults[row][4] = Q2;
        row++;
    }
    System.out.println("**************************************************");
    WriteToExcel wr = new WriteToExcel();
    String fileName = "optTable2.xls";
    String headString = "x1" + "\t" + "x2" + "\t" + "R" + "\t" + "Q1" + "\t" + "Q2";
    wr.writeArrayToExcel(optResults, fileName, headString);
}
Also used : ImmediateValueFunction(sdp.inventory.ImmediateValue.ImmediateValueFunction) Demands(sdp.cash.multiItem.Demands) CashRecursionMulti(sdp.cash.multiItem.CashRecursionMulti) Actions(sdp.cash.multiItem.Actions) Function(java.util.function.Function) StateTransitionFunction(sdp.inventory.StateTransition.StateTransitionFunction) ArrayList(java.util.ArrayList) GetPmf(sdp.inventory.GetPmf) GetPmfMulti(sdp.cash.multiItem.GetPmfMulti) BiNormalDist(umontreal.ssj.probdistmulti.BiNormalDist) WriteToExcel(sdp.write.WriteToExcel) CashSimulationMulti(sdp.cash.multiItem.CashSimulationMulti) CashStateMulti(sdp.cash.multiItem.CashStateMulti) PoissonDist(umontreal.ssj.probdist.PoissonDist) Distribution(umontreal.ssj.probdist.Distribution) PoissonDist(umontreal.ssj.probdist.PoissonDist) Actions(sdp.cash.multiItem.Actions) Demands(sdp.cash.multiItem.Demands) ArrayList(java.util.ArrayList) CashStateMulti(sdp.cash.multiItem.CashStateMulti) CashSimulationMulti(sdp.cash.multiItem.CashSimulationMulti) WriteToExcel(sdp.write.WriteToExcel) Distribution(umontreal.ssj.probdist.Distribution) GetPmf(sdp.inventory.GetPmf) CashRecursionMulti(sdp.cash.multiItem.CashRecursionMulti)

Example 2 with CashStateMulti

use of sdp.cash.multiItem.CashStateMulti in project Stochastic-Inventory by RobinChen121.

the class MultiItemYR method main.

public static void main(String[] args) {
    double[] price = { 2, 10 };
    // higher margin vs lower margin
    double[] variCost = { 1, 2 };
    double depositeRate = 0;
    // initial cash
    double iniCash = 10;
    // initial inventory
    int iniInventory1 = 0;
    int iniInventory2 = 0;
    // gamma distribution:mean demand is shape / beta and variance is shape / beta^2
    // beta = 1 / scale
    // shape = demand * beta
    // variance = demand / beta
    // gamma in ssj: alpha is alpha, and lambda is beta(beta)
    // horizon length
    int T = 4;
    double[] meanDemands = new double[] { 10, 3 };
    // higher average demand vs lower average demand
    double[][] demand = new double[2][T];
    // higher variance vs lower variance
    double[] beta = { 10, 1 };
    double d1 = meanDemands[0];
    double d2 = meanDemands[1];
    double v1 = variCost[0];
    double v2 = variCost[1];
    double p1 = price[0];
    double p2 = price[1];
    for (int t = 0; t < T; t++) {
        demand[0][t] = d1;
        demand[1][t] = d2;
    }
    double[] salPrice = Arrays.stream(variCost).map(a -> a * 0.5).toArray();
    // number of products
    int m = demand.length;
    // for (int index = 5; index <= 10; index++) {
    // price[1] = index;
    // may affect poisson results
    double truncationQuantile = 0.9999;
    int stepSize = 1;
    double minCashState = 0;
    double maxCashState = 10000;
    int minInventoryState = 0;
    int maxInventoryState = 200;
    int Qbound = 20;
    double discountFactor = 1;
    // get demand possibilities for each period
    Distribution[][] distributions = new GammaDist[m][T];
    // Distribution[][] distributions =  new NormalDist[m][T];
    for (int i = 0; i < m; i++) for (int t = 0; t < T; t++) {
        distributions[i][t] = new GammaDist(demand[i][t] * beta[i], beta[i]);
    // distributions[i][t] = new PoissonDist(demand[i][t]);
    // distributions[i][t]= new NormalDist(demand[i][t], 0.1 * demand[i][t]);
    }
    // build action list (y1, y2) for pai(y1, y2, R)
    Function<CashStateMultiYR, ArrayList<double[]>> buildActionListPai = s -> {
        ArrayList<double[]> actions = new ArrayList<>();
        double Ybound = Qbound;
        for (double i = 0; i < Ybound; i = i + 1) for (double j = 0; j < Ybound; j = j + 1) {
            double[] thisActions = { i, j };
            actions.add(thisActions);
        }
        return actions;
    };
    // build action list (y1, y2) for V(x1, x2, w)
    Function<CashStateMulti, ArrayList<double[]>> buildActionListV = s -> {
        ArrayList<double[]> actions = new ArrayList<>();
        int miny1 = (int) s.getIniInventory1();
        int miny2 = (int) s.getIniInventory2();
        double iniR = s.getIniCash() + v1 * s.getIniInventory1() + v2 * s.getIniInventory2();
        for (double i = miny1; i < miny1 + Qbound; i = i + 1) for (double j = miny2; j < miny2 + Qbound; j = j + 1) {
            if (v1 * i + v2 * j < iniR + 0.1) {
                double[] thisActions = { i, j };
                actions.add(thisActions);
            }
        }
        return actions;
    };
    BoundaryFuncton<CashStateMulti, Double> boundFinalCash = (IniState) -> {
        return IniState.getIniCash() + salPrice[0] * IniState.getIniInventory1() + salPrice[1] * IniState.getIniInventory2();
    };
    // State Transition Function: from pai^n(y1, y2, R) to V^{n+1}(x1, x2, w)
    StateTransitionFunctionV<CashStateMultiYR, double[], CashStateMulti> stateTransition = (IniState, RandomDemands) -> {
        double endInventory1 = IniState.getIniInventory1() - RandomDemands[0];
        endInventory1 = Math.max(0, endInventory1);
        double endInventory2 = IniState.getIniInventory2() - RandomDemands[1];
        endInventory2 = Math.max(0, endInventory2);
        double revenue1 = p1 * Math.min(IniState.getIniInventory1(), RandomDemands[0]);
        double revenue2 = p2 * Math.min(IniState.getIniInventory2(), RandomDemands[1]);
        double nextW = revenue1 + revenue2 + (1 + depositeRate) * (IniState.getIniR() - v1 * IniState.getIniInventory1() - // revise
        v2 * IniState.getIniInventory2());
        endInventory1 = Math.round(endInventory1 * 10) / 10;
        endInventory2 = Math.round(endInventory2 * 10) / 10;
        nextW = Math.round(nextW * 10) / 10;
        nextW = nextW > maxCashState ? maxCashState : nextW;
        nextW = nextW < minCashState ? minCashState : nextW;
        endInventory1 = endInventory1 > maxInventoryState ? maxInventoryState : endInventory1;
        endInventory2 = endInventory2 < minInventoryState ? minInventoryState : endInventory2;
        return new CashStateMulti(IniState.getPeriod() + 1, endInventory1, endInventory2, nextW);
    };
    GetPmfMulti PmfMulti = new GetPmfMulti(distributions, truncationQuantile, stepSize);
    /**
     *****************************************************************
     * Solve
     */
    CashRecursionV recursion = new CashRecursionV(discountFactor, PmfMulti, buildActionListV, buildActionListPai, stateTransition, boundFinalCash, T, variCost);
    int period = 1;
    CashStateMulti iniState = new CashStateMulti(period, iniInventory1, iniInventory2, iniCash);
    long currTime = System.currentTimeMillis();
    double finalValue = recursion.getExpectedValueV(iniState);
    System.out.println("final optimal cash  is " + finalValue);
    System.out.println("optimal order quantity in the first priod is :  y1 = " + recursion.getAction(iniState)[0] + ", y2 = " + recursion.getAction(iniState)[1]);
    double time = (System.currentTimeMillis() - currTime) / 1000.0;
    System.out.println("running time is " + time + "s");
    CashStateR iniState2 = new CashStateR(period, iniCash);
    double[] optY = recursion.getYStar(iniState2);
    System.out.println("optimal order quantity y* in the first priod is : " + Arrays.toString(optY));
    /**
     *****************************************************************
     * Simulate
     *
     * basically, this simulation is testing for Theorem 1:
     * optimal ordering decisions depend on y*(R)
     */
    int sampleNum = 10000;
    currTime = System.currentTimeMillis();
    CashSimulationY simulation = new CashSimulationY(sampleNum, distributions, discountFactor, recursion, stateTransition);
    double simFinalValue = simulation.simulateSDPGivenSamplNum(iniState, variCost);
    double gap = (simFinalValue - finalValue) / finalValue;
    System.out.printf("optimality gap for this policy y* is %.2f%%\n", gap * 100);
    time = (System.currentTimeMillis() - currTime) / 1000.0;
    System.out.println("running time is " + time + "s");
// 
// /*******************************************************************
// * Compute a1* and a2*
// *
// * and simulate their results to test Theorem 2
// *
// */
// double[][][] pmf1 = new GetPmf(distributions[0], truncationQuantile, stepSize).getpmf();
// Distribution[] distributions1 = distributions[0];
// double[][][] pmf2 = new GetPmf(distributions[1], truncationQuantile, stepSize).getpmf();
// Distribution[] distributions2 = distributions[1];
// RecursionG recursionG1 = new RecursionG(pmf1, distributions1, price[0], variCost[0], 0, salPrice[0]);
// RecursionG recursionG2 = new RecursionG(pmf2, distributions2, price[1], variCost[1], 0, salPrice[1]);
// double[] opta1 = recursionG1.getOptY();
// double[] opta2 = recursionG2.getOptY();
// System.out.println("a1* in each period:");
// DecimalFormat df = new DecimalFormat("0.00");
// Arrays.stream(opta1).forEach(e -> System.out.print(df.format(e) + " " ));
// System.out.println("");
// System.out.println("a2* in each period:");
// Arrays.stream(opta2).forEach(e -> System.out.print(df.format(e) + " " ));
// double simFinalValue2 = simulation.simulateSDPGivenSamplNuma1a2(iniState, variCost, opta1, opta2);
// double gap2 = (simFinalValue2 - finalValue) / finalValue;
// System.out.printf("optimality gap for this policy a* is %.2f%%\n", gap2 * 100);
// 
// double[] mean = new double[] {demand[0][0], demand[1][0]};
// double[] variance = new double[] {demand[0][0] / beta[0], demand[1][0] / beta[1]};
// double[][] optTable = recursion.getOptTableDetail2(mean, variance, price, opta1, opta2);
// 
// double[] gaps = new double[] {gap, gap2};
// WriteToExcel wr = new WriteToExcel();
// String fileName = "run" + ".xls";
// String headString =
// "meanD1" + "\t" + "meanD2" + "\t" + "variance1" + "\t" + "variance2" + "\t" +
// "period" + "\t" + "x1" + "\t" + "x2" + "\t" + "w" + "\t" +
// "p1" + "\t" + "p2" + "\t" +
// "c1" + "\t" + "c2" + "\t" + "R" + "\t" + "y1*"+ "\t" + "y2*" + "\t" +
// "cashSituation" + "\t" + "alpha" + "\t" + "yHead1"  + "\t" + "yHead2"  + "\t" + "a1*"  + "\t" + "a2*" +
// "\t" + "Theorem1Gap" + "Theorem2Gap";
// wr.writeArrayToExcel2(optTable, fileName, headString, gaps);
// System.out.println("alpha in the first period: " + optTable[0][10]);
// System.out.println("*******************************");
}
Also used : RecursionG(sdp.cash.RecursionG) Arrays(java.util.Arrays) ReadExcel(sdp.write.ReadExcel) CashRecursionV(sdp.cash.multiItem.CashRecursionV) GammaDist(umontreal.ssj.probdist.GammaDist) DecimalFormat(java.text.DecimalFormat) NormalDist(umontreal.ssj.probdist.NormalDist) CashStateMultiYR(sdp.cash.multiItem.CashStateMultiYR) Function(java.util.function.Function) CashSimulationMultiXR(sdp.cash.multiItem.CashSimulationMultiXR) ImmediateValueFunctionV(sdp.inventory.ImmediateValue.ImmediateValueFunctionV) ArrayList(java.util.ArrayList) StateTransitionFunctionV(sdp.inventory.StateTransition.StateTransitionFunctionV) GetPmf(sdp.inventory.GetPmf) CashStateR(sdp.cash.multiItem.CashStateR) GetPmfMulti(sdp.cash.multiItem.GetPmfMulti) WriteToExcel(sdp.write.WriteToExcel) CashStateMulti(sdp.cash.multiItem.CashStateMulti) PoissonDist(umontreal.ssj.probdist.PoissonDist) BoundaryFuncton(sdp.inventory.FinalCash.BoundaryFuncton) Distribution(umontreal.ssj.probdist.Distribution) CashSimulationY(sdp.cash.multiItem.CashSimulationY) GammaDist(umontreal.ssj.probdist.GammaDist) ArrayList(java.util.ArrayList) CashRecursionV(sdp.cash.multiItem.CashRecursionV) CashStateMulti(sdp.cash.multiItem.CashStateMulti) CashSimulationY(sdp.cash.multiItem.CashSimulationY) CashStateMultiYR(sdp.cash.multiItem.CashStateMultiYR) GetPmfMulti(sdp.cash.multiItem.GetPmfMulti) CashStateR(sdp.cash.multiItem.CashStateR)

Example 3 with CashStateMulti

use of sdp.cash.multiItem.CashStateMulti in project Stochastic-Inventory by RobinChen121.

the class MultiItemCash method main.

public static void main(String[] args) {
    double[] price = { 4, 50 };
    // higher margin vs lower margin
    double[] variCost = { 2, 4 };
    // initial cash
    double iniCash = 100;
    // initial inventory
    int iniInventory1 = 0;
    int iniInventory2 = 0;
    // higher average demand vs lower average demand
    double[][] demand = { { 5, 6 }, { 5, 6 } };
    // higher variance vs lower variance
    double[] coe = { 0.25, 0.25 };
    double[] salPrice = { 1, 1 };
    // horizon length
    int T = demand[0].length;
    double truncationQuantile = 0.999;
    int stepSize = 1;
    double minCashState = 0;
    double maxCashState = 10000;
    int minInventoryState = 0;
    int maxInventoryState = 200;
    int Qbound = 100;
    double discountFactor = 1;
    // get demand possibilities for each period
    BiNormalDist[] distributions = new BiNormalDist[T];
    for (int t = 0; t < T; t++) distributions[t] = new BiNormalDist(demand[0][t], coe[0] * demand[0][t], demand[1][t], coe[1] * demand[1][t], 0);
    // build action list for two items
    Function<CashStateMulti, ArrayList<Actions>> buildActionList = s -> {
        ArrayList<Actions> actions = new ArrayList<>();
        for (int i = 0; i < Qbound; i++) for (int j = 0; j < Qbound; j++) {
            if (variCost[0] * i + variCost[1] * j < s.getIniCash() + 0.1) {
                Actions thisAction = new Actions(i, j);
                actions.add(thisAction);
            }
        }
        return actions;
    };
    // Immediate Value Function
    ImmediateValueFunction<CashStateMulti, Actions, Demands, Double> immediateValue = (IniState, Actions, RandomDemands) -> {
        double action1 = Actions.getFirstAction();
        double action2 = Actions.getSecondAction();
        double demand1 = RandomDemands.getFirstDemand();
        double demand2 = RandomDemands.getSecondDemand();
        double endInventory1 = Math.max(0, IniState.getIniInventory1() + action1 - demand1);
        double endInventory2 = Math.max(0, IniState.getIniInventory2() + action2 - demand2);
        double revenue1 = price[0] * (IniState.getIniInventory1() + action1 - endInventory1);
        double revenue2 = price[1] * (IniState.getIniInventory2() + action2 - endInventory2);
        double revenue = revenue1 + revenue2;
        double orderingCost1 = variCost[0] * action1;
        double orderingCost2 = variCost[1] * action2;
        double orderingCosts = orderingCost1 + orderingCost2;
        double salValue = 0;
        if (IniState.getPeriod() == T) {
            salValue = salPrice[0] * endInventory1 + salPrice[1] * endInventory2;
        }
        return revenue - orderingCosts + salValue;
    };
    // State Transition Function
    StateTransitionFunction<CashStateMulti, Actions, Demands, CashStateMulti> stateTransition = (IniState, Actions, RandomDemands) -> {
        double endInventory1 = IniState.getIniInventory1() + Actions.getFirstAction() - RandomDemands.getFirstDemand();
        endInventory1 = Math.max(0, endInventory1);
        double endInventory2 = IniState.getIniInventory2() + Actions.getSecondAction() - RandomDemands.getSecondDemand();
        endInventory2 = Math.max(0, endInventory2);
        double nextCash = IniState.getIniCash() + immediateValue.apply(IniState, Actions, RandomDemands);
        nextCash = nextCash > maxCashState ? maxCashState : nextCash;
        nextCash = nextCash < minCashState ? minCashState : nextCash;
        endInventory1 = endInventory1 > maxInventoryState ? maxInventoryState : endInventory1;
        endInventory2 = endInventory2 < minInventoryState ? minInventoryState : endInventory2;
        // rounding states to save computing time
        nextCash = (int) nextCash;
        endInventory1 = (int) endInventory1;
        endInventory2 = (int) endInventory2;
        return new CashStateMulti(IniState.getPeriod() + 1, endInventory1, endInventory2, nextCash);
    };
// GetPmfMulti pmfMulti = new GetPmfMulti(distributions, truncationQuantile, stepSize);
// 
// /*******************************************************************
// * Solve
// */
// CashRecursionMulti recursion = new CashRecursionMulti(discountFactor, pmfMulti, buildActionList,
// stateTransition, immediateValue, T);
// int period = 1;
// CashStateMulti iniState = new CashStateMulti(period, iniInventory1, iniInventory2, iniCash);
// long currTime = System.currentTimeMillis();
// double finalValue = iniCash + recursion.getExpectedValue(iniState);
// System.out.println("final optimal cash  is " + finalValue);
// System.out.println("optimal order quantity in the first priod is :  Q1 = " + recursion.getAction(iniState).getFirstAction()
// + ", Q2 = " + recursion.getAction(iniState).getSecondAction());
// double time = (System.currentTimeMillis() - currTime) / 1000;
// System.out.println("running time is " + time + "s");
// 
// 
// 
// /*******************************************************************
// * Simulating sdp results
// *
// * simulating results a little lower than SDP
// */
// int sampleNum = 10000;
// CashSimulationMulti simuation = new CashSimulationMulti(sampleNum, distributions, discountFactor,
// recursion, stateTransition, immediateValue);
// double simFinalValue = simuation.simulateSDPGivenSamplNum(iniState);
// System.out.println(simFinalValue);
/**
 *****************************************************************
 * try to find some ordering patters from optTable
 *
 * output results to excel
 */
// System.out.println("");
// double[][] optTable = recursion.getOptTable(variCost);
// WriteToExcel wr = new WriteToExcel();
// String fileName = "optTable" + "_c1=" + variCost[0] + "c2=" + variCost[1] + ".xls";
// String headString =  "period" + "\t" + "x1" + "\t" + "x2" + "\t" + "w"+ "\t" + "R" + "\t" + "is limited cash and both ordering" + "\t" + "alpha"
// + "\t" + "Q1"+ "\t" + "Q2" + "\t" + "c1" + "\t" + "c2";
// wr.writeArrayToExcel(optTable, fileName, headString);
// 
}
Also used : ImmediateValueFunction(sdp.inventory.ImmediateValue.ImmediateValueFunction) Demands(sdp.cash.multiItem.Demands) CashRecursionMulti(sdp.cash.multiItem.CashRecursionMulti) GetPmfMulti(sdp.cash.multiItem.GetPmfMulti) Actions(sdp.cash.multiItem.Actions) BiNormalDist(umontreal.ssj.probdistmulti.BiNormalDist) WriteToExcel(sdp.write.WriteToExcel) Function(java.util.function.Function) CashSimulationMulti(sdp.cash.multiItem.CashSimulationMulti) CashStateMulti(sdp.cash.multiItem.CashStateMulti) StateTransitionFunction(sdp.inventory.StateTransition.StateTransitionFunction) ArrayList(java.util.ArrayList) Actions(sdp.cash.multiItem.Actions) Demands(sdp.cash.multiItem.Demands) ArrayList(java.util.ArrayList) CashStateMulti(sdp.cash.multiItem.CashStateMulti) BiNormalDist(umontreal.ssj.probdistmulti.BiNormalDist)

Example 4 with CashStateMulti

use of sdp.cash.multiItem.CashStateMulti in project Stochastic-Inventory by RobinChen121.

the class MultiItemCashXW method main.

public static void main(String[] args) {
    double[] price = { 2, 10 };
    // higher margin vs lower margin
    double[] variCost = { 1, 1 };
    double depositeRate = 0;
    // initial cash
    double iniCash = 10;
    // initial inventory
    int iniInventory1 = 0;
    int iniInventory2 = 0;
    // gamma distribution:mean demand is shape / beta and variance is shape / beta^2
    // beta = 1 / scale
    // shape = demand * beta
    // variance = demand / beta
    // gamma in ssj: alpha is alpha, and lambda is beta(beta)
    // horizon length
    int T = 4;
    double[] meanDemands = new double[] { 10, 3 };
    // higher average demand vs lower average demand
    double[][] demand = new double[2][T];
    // higher variance vs lower variance
    double[] beta = { 10, 1 };
    double d1 = meanDemands[0];
    double d2 = meanDemands[1];
    double v1 = variCost[0];
    double v2 = variCost[1];
    double p1 = price[0];
    double p2 = price[1];
    for (int t = 0; t < T; t++) {
        demand[0][t] = d1;
        demand[1][t] = d2;
    }
    double[] salPrice = Arrays.stream(variCost).map(a -> a * 0.5).toArray();
    // number of products
    int m = demand.length;
    // may affect poisson results
    double truncationQuantile = 0.9999;
    double stepSize = 1;
    double minCashState = 0;
    double maxCashState = 10000;
    int minInventoryState = 0;
    int maxInventoryState = 200;
    int Qbound = 20;
    double discountFactor = 1;
    // get demand possibilities for each period
    Distribution[][] distributions = new GammaDist[m][T];
    // Distribution[][] distributions =  new UniformIntDist[m][T];
    for (int i = 0; i < m; i++) for (int t = 0; t < T; t++) {
        distributions[i][t] = new GammaDist(demand[i][t] * beta[i], beta[i]);
    // distributions[i][t] = new UniformIntDist((int)(demand[i][t] * 0.6), (int)(demand[i][t] * 1.4));
    // distributions[i][t] = new PoissonDist(demand[i][t]);
    // distributions[i][t]= new NormalDist(demand[i][t], 0.1 * demand[i][t]);
    }
    GetPmfMulti PmfMulti = new GetPmfMulti(distributions, truncationQuantile, stepSize);
    // build action list (y1, y2) for pai(x1, x2, w)
    // CashStateMulti are states (x1, x2, w)
    Function<CashStateMulti, ArrayList<double[]>> buildActionListPai = s -> {
        ArrayList<double[]> actions = new ArrayList<>();
        double Ybound = Qbound;
        for (double i = 0; i < Ybound; i = i + 1) for (double j = 0; j < Ybound; j = j + 1) {
            double[] thisActions = { i, j };
            actions.add(thisActions);
        }
        return actions;
    };
    // build action list (y1, y2) for V(x1, x2, w)
    Function<CashStateMulti, ArrayList<double[]>> buildActionListV = s -> {
        ArrayList<double[]> actions = new ArrayList<>();
        int miny1 = (int) s.getIniInventory1();
        int miny2 = (int) s.getIniInventory2();
        double iniR = s.getIniCash() + v1 * s.getIniInventory1() + v2 * s.getIniInventory2();
        for (double i = miny1; i < miny1 + Qbound; i = i + 1) for (double j = miny2; j < miny2 + Qbound; j = j + 1) {
            if (v1 * i + v2 * j < iniR + 0.1) {
                double[] thisActions = { i, j };
                actions.add(thisActions);
            }
        }
        return actions;
    };
    BoundaryFuncton<CashStateMulti, Double> boundFinalCash = (IniState) -> {
        return IniState.getIniCash() + salPrice[0] * IniState.getIniInventory1() + salPrice[1] * IniState.getIniInventory2();
    };
    // State Transition Function
    // revise
    StateTransitionFunction<CashStateMulti, double[], double[], CashStateMulti> stateTransition = (IniState, actions, RandomDemands) -> {
        double x1 = IniState.getIniInventory1();
        double x2 = IniState.getIniInventory2();
        double y1 = actions[0];
        double y2 = actions[1];
        double endInventory1 = y1 - RandomDemands[0];
        endInventory1 = Math.max(0, endInventory1);
        double endInventory2 = y2 - RandomDemands[1];
        endInventory2 = Math.max(0, endInventory2);
        double revenue1 = p1 * Math.min(y1, RandomDemands[0]);
        double revenue2 = p2 * Math.min(y2, RandomDemands[1]);
        double nextW = revenue1 + revenue2 + (1 + depositeRate) * (IniState.getIniCash() - v1 * (y1 - x1) - // revise
        v2 * (y2 - x2));
        // rounding the states to one decimal 10.0
        endInventory1 = Math.round(endInventory1 * 10) / 10;
        endInventory2 = Math.round(endInventory2 * 10) / 10;
        nextW = Math.round(nextW * 10) / 10;
        nextW = nextW > maxCashState ? maxCashState : nextW;
        nextW = nextW < minCashState ? minCashState : nextW;
        endInventory1 = endInventory1 > maxInventoryState ? maxInventoryState : endInventory1;
        endInventory2 = endInventory2 < minInventoryState ? minInventoryState : endInventory2;
        return new CashStateMulti(IniState.getPeriod() + 1, endInventory1, endInventory2, nextW);
    };
    /**
     *****************************************************************
     * Solve
     */
    CashRecursionV2 recursion = new CashRecursionV2(discountFactor, PmfMulti, buildActionListV, buildActionListPai, stateTransition, boundFinalCash, T, variCost);
    int period = 1;
    CashStateMulti iniState = new CashStateMulti(period, iniInventory1, iniInventory2, iniCash);
    long currTime = System.currentTimeMillis();
    double finalValue = recursion.getExpectedValueV(iniState);
    System.out.println("final optimal cash  is " + finalValue);
    System.out.println("optimal order quantity in the first priod is :  y1 = " + recursion.getAction(iniState)[0] + ", y2 = " + recursion.getAction(iniState)[1]);
    double time = (System.currentTimeMillis() - currTime) / 1000.0;
    System.out.println("running time is " + time + "s");
    double[] optY = recursion.getYStar(iniState);
    System.out.println("optimal order quantity y* in the first priod is : " + Arrays.toString(optY));
    /**
     *****************************************************************
     * Simulate
     *
     * basically, this simulation is testing for Theorem 1:
     * optimal ordering decisions depend on y*(R)
     */
    int sampleNum = 10000;
    currTime = System.currentTimeMillis();
    CashSimulationY simulation = new CashSimulationY(sampleNum, distributions, discountFactor, recursion, stateTransition);
    double simFinalValue = simulation.simulateSDPGivenSamplNum2(iniState, variCost);
    double gap = (finalValue - simFinalValue) / finalValue;
    System.out.printf("optimality gap for this policy y* is %.2f%%\n", gap * 100);
    time = (System.currentTimeMillis() - currTime) / 1000.0;
    System.out.println("running time is " + time + "s");
    /**
     *****************************************************************
     * Compute a1* and a2*
     *
     * and simulate their results to test Theorem 2
     */
    stepSize = 0.1;
    double[][][] pmf1 = new GetPmf(distributions[0], truncationQuantile, stepSize).getpmf();
    Distribution[] distributions1 = distributions[0];
    double[][][] pmf2 = new GetPmf(distributions[1], truncationQuantile, stepSize).getpmf();
    Distribution[] distributions2 = distributions[1];
    RecursionG recursionG1 = new RecursionG(pmf1, distributions1, price[0], variCost[0], 0, salPrice[0]);
    RecursionG recursionG2 = new RecursionG(pmf2, distributions2, price[1], variCost[1], 0, salPrice[1]);
    double[] opta1 = recursionG1.getOptY();
    double[] opta2 = recursionG2.getOptY();
    System.out.println("---------------");
    System.out.println("a1* in each period:");
    DecimalFormat df = new DecimalFormat("0.00");
    Arrays.stream(opta1).forEach(e -> System.out.print(df.format(e) + " "));
    System.out.println("");
    System.out.println("a2* in each period:");
    Arrays.stream(opta2).forEach(e -> System.out.print(df.format(e) + " "));
    // double simFinalValue2 = simulation.simulateSDPGivenSamplNuma1a22(iniState, variCost, opta1, opta2);
    // double gap2 = (simFinalValue2 - finalValue) / finalValue;
    // System.out.printf("optimality gap for this policy a* is %.2f%%\n", gap2 * 100);
    double[] mean = new double[] { demand[0][0], demand[1][0] };
    double[] variance = new double[] { demand[0][0] / beta[0], demand[1][0] / beta[1] };
    double[][] optTable = recursion.getOptTableDetail(mean, variance, price, opta1, opta2);
    double[] gaps = new double[] { gap };
    WriteToExcel wr = new WriteToExcel();
    String fileName = "run" + ".xls";
    String headString = "meanD1" + "\t" + "meanD2" + "\t" + "variance1" + "\t" + "variance2" + "\t" + "period" + "\t" + "x1" + "\t" + "x2" + "\t" + "w" + "\t" + "p1" + "\t" + "p2" + "\t" + "c1" + "\t" + "c2" + "\t" + "R" + "\t" + "y1*" + "\t" + "y2*" + "\t" + "cashSituation" + "\t" + "alpha" + "\t" + "yHead1" + "\t" + "yHead2" + "\t" + "a1*" + "\t" + "a2*" + "\t" + "Theorem1Gap";
    wr.writeArrayToExcel2(optTable, fileName, headString, gaps);
}
Also used : RecursionG(sdp.cash.RecursionG) Arrays(java.util.Arrays) CashRecursionV2(sdp.cash.multiItem.CashRecursionV2) GammaDist(umontreal.ssj.probdist.GammaDist) DecimalFormat(java.text.DecimalFormat) UniformIntDist(umontreal.ssj.probdist.UniformIntDist) Function(java.util.function.Function) CashRecursionVTest(sdp.cash.multiItem.CashRecursionVTest) StateTransitionFunction(sdp.inventory.StateTransition.StateTransitionFunction) ArrayList(java.util.ArrayList) StateTransitionFunctionV(sdp.inventory.StateTransition.StateTransitionFunctionV) GetPmf(sdp.inventory.GetPmf) CashStateMultiXYW(sdp.cash.multiItem.CashStateMultiXYW) GetPmfMulti(sdp.cash.multiItem.GetPmfMulti) WriteToExcel(sdp.write.WriteToExcel) CashStateMulti(sdp.cash.multiItem.CashStateMulti) BoundaryFuncton(sdp.inventory.FinalCash.BoundaryFuncton) Distribution(umontreal.ssj.probdist.Distribution) CashSimulationY(sdp.cash.multiItem.CashSimulationY) GammaDist(umontreal.ssj.probdist.GammaDist) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) CashSimulationY(sdp.cash.multiItem.CashSimulationY) WriteToExcel(sdp.write.WriteToExcel) GetPmfMulti(sdp.cash.multiItem.GetPmfMulti) GetPmf(sdp.inventory.GetPmf) RecursionG(sdp.cash.RecursionG) CashStateMulti(sdp.cash.multiItem.CashStateMulti) CashRecursionV2(sdp.cash.multiItem.CashRecursionV2) Distribution(umontreal.ssj.probdist.Distribution)

Example 5 with CashStateMulti

use of sdp.cash.multiItem.CashStateMulti in project Stochastic-Inventory by RobinChen121.

the class MultiItemCashXWTesting method main.

public static void main(String[] args) {
    double[] price = { 2, 10 };
    // higher margin vs lower margin
    double[] variCost = { 1, 2 };
    double depositeRate = 0;
    // initial cash
    double iniCash = 10;
    // initial inventory
    int iniInventory1 = 0;
    int iniInventory2 = 0;
    // gamma distribution:mean demand is shape / beta and variance is shape / beta^2
    // beta = 1 / scale
    // shape = demand * beta
    // variance = demand / beta
    // gamma in ssj: alpha is alpha, and lambda is beta(beta)
    // horizon length
    int T = 4;
    double[] meanDemands = new double[] { 10, 3 };
    // read parameter settings from excel files
    ReadExcel re = new ReadExcel();
    double[][] paraSettings = re.readExcelXLSX("Numerical experiments-2021-02-06.xlsx", 2);
    for (int runTime = 1; runTime < 2; runTime = runTime + 1) {
        price = new double[] { paraSettings[runTime][2], paraSettings[runTime][8] };
        variCost = new double[] { paraSettings[runTime][1], paraSettings[runTime][7] };
        double[] beta = new double[] { paraSettings[runTime][6], paraSettings[runTime][12] };
        // a = new int[] {(int)paraSettings[runTime][5], (int)paraSettings[runTime][11]}; // integer for uniform
        meanDemands = new double[] { paraSettings[runTime][3], paraSettings[runTime][9] };
        // higher average demand vs lower average demand
        double[][] demand = new double[2][T];
        double d1 = meanDemands[0];
        double d2 = meanDemands[1];
        double v1 = variCost[0];
        double v2 = variCost[1];
        double p1 = price[0];
        double p2 = price[1];
        for (int t = 0; t < T; t++) {
            demand[0][t] = d1;
            demand[1][t] = d2;
        }
        double[] salPrice = Arrays.stream(variCost).map(a -> a * 0.5).toArray();
        // number of products
        int m = demand.length;
        // may affect poisson results
        double truncationQuantile = 0.9999;
        double stepSize = 1;
        double minCashState = 0;
        double maxCashState = 10000;
        int minInventoryState = 0;
        int maxInventoryState = 200;
        int Qbound = 20;
        double discountFactor = 1;
        // get demand possibilities for each period
        // Distribution[][] distributions =  new GammaDist[m][T];
        // Distribution[][] distributions =  new PoissonDist[m][T];
        // Distribution[][] distributions =  new NormalDist[m][T];
        Distribution[][] distributions = new UniformIntDist[m][T];
        for (int i = 0; i < m; i++) for (int t = 0; t < T; t++) {
            // distributions[i][t] = new GammaDist(demand[i][t]* beta[i], beta[i]);
            distributions[i][t] = new UniformIntDist((int) (demand[i][t] * 0.2), (int) (demand[i][t] * 1.8));
        // distributions[i][t] = new PoissonDist(demand[i][t]);
        // distributions[i][t]= new NormalDist(demand[i][t], 0.1 * demand[i][t]);
        // distributions[i][t] = new UniformIntDist(a[i], b[i]);
        }
        GetPmfMulti PmfMulti = new GetPmfMulti(distributions, truncationQuantile, stepSize);
        // build action list (y1, y2) for pai(x1, x2, w)
        // CashStateMulti are states (x1, x2, w)
        Function<CashStateMulti, ArrayList<double[]>> buildActionListPai = s -> {
            ArrayList<double[]> actions = new ArrayList<>();
            double Ybound = Qbound;
            for (double i = 0; i < Ybound; i = i + 1) for (double j = 0; j < Ybound; j = j + 1) {
                double[] thisActions = { i, j };
                actions.add(thisActions);
            }
            return actions;
        };
        // build action list (y1, y2) for V(x1, x2, w), no use in the recursion
        Function<CashStateMulti, ArrayList<double[]>> buildActionListV = s -> {
            ArrayList<double[]> actions = new ArrayList<>();
            int miny1 = (int) s.getIniInventory1();
            int miny2 = (int) s.getIniInventory2();
            double iniR = s.getIniCash() + v1 * s.getIniInventory1() + v2 * s.getIniInventory2();
            for (double i = miny1; i < miny1 + Qbound; i = i + 1) for (double j = miny2; j < miny2 + Qbound; j = j + 1) {
                if (v1 * i + v2 * j < iniR + 0.1) {
                    double[] thisActions = { i, j };
                    actions.add(thisActions);
                }
            }
            return actions;
        };
        BoundaryFuncton<CashStateMulti, Double> boundFinalCash = (IniState) -> {
            return IniState.getIniCash() + salPrice[0] * IniState.getIniInventory1() + salPrice[1] * IniState.getIniInventory2();
        };
        // State Transition Function
        // revise
        StateTransitionFunction<CashStateMulti, double[], double[], CashStateMulti> stateTransition = (IniState, actions, RandomDemands) -> {
            double x1 = IniState.getIniInventory1();
            double x2 = IniState.getIniInventory2();
            double y1 = actions[0];
            double y2 = actions[1];
            double endInventory1 = y1 - RandomDemands[0];
            endInventory1 = Math.max(0, endInventory1);
            double endInventory2 = y2 - RandomDemands[1];
            endInventory2 = Math.max(0, endInventory2);
            double revenue1 = p1 * Math.min(y1, RandomDemands[0]);
            double revenue2 = p2 * Math.min(y2, RandomDemands[1]);
            double nextW = revenue1 + revenue2 + (1 + depositeRate) * (IniState.getIniCash() - v1 * (y1 - x1) - // revise
            v2 * (y2 - x2));
            // rounding the states to one decimal 10.0
            endInventory1 = Math.round(endInventory1 * 1) / 1;
            // very slow when decimal
            endInventory2 = Math.round(endInventory2 * 1) / 1;
            nextW = Math.round(nextW * 1) / 1;
            nextW = nextW > maxCashState ? maxCashState : nextW;
            nextW = nextW < minCashState ? minCashState : nextW;
            endInventory1 = endInventory1 > maxInventoryState ? maxInventoryState : endInventory1;
            endInventory2 = endInventory2 < minInventoryState ? minInventoryState : endInventory2;
            return new CashStateMulti(IniState.getPeriod() + 1, endInventory1, endInventory2, nextW);
        };
        /**
         *****************************************************************
         * Solve
         */
        CashRecursionV2 recursion = new CashRecursionV2(discountFactor, PmfMulti, buildActionListV, buildActionListPai, stateTransition, boundFinalCash, T, variCost);
        int period = 1;
        CashStateMulti iniState = new CashStateMulti(period, iniInventory1, iniInventory2, iniCash);
        long currTime = System.currentTimeMillis();
        double finalValue = recursion.getExpectedValueV(iniState);
        System.out.println("final optimal cash  is " + finalValue);
        System.out.println("optimal order quantity in the first priod is :  y1 = " + recursion.getAction(iniState)[0] + ", y2 = " + recursion.getAction(iniState)[1]);
        double time = (System.currentTimeMillis() - currTime) / 1000.0;
        System.out.println("running time is " + time + "s");
        double[] optY = recursion.getYStar(iniState);
        System.out.println("optimal order quantity y* in the first priod is : " + Arrays.toString(optY));
        /**
         *****************************************************************
         * Simulate
         *
         * basically, this simulation is testing for Theorem 1:
         * optimal ordering decisions depend on y*(R)
         */
        int sampleNum = 10000;
        currTime = System.currentTimeMillis();
        CashSimulationY simulation = new CashSimulationY(sampleNum, distributions, discountFactor, recursion, stateTransition);
        double simFinalValue = simulation.simulateSDPGivenSamplNum2(iniState, variCost);
        double gap = (finalValue - simFinalValue) / finalValue;
        System.out.printf("optimality gap for this policy y* is %.2f%%\n", gap * 100);
        time = (System.currentTimeMillis() - currTime) / 1000.0;
        System.out.println("running time is " + time + "s");
        /**
         *****************************************************************
         * Compute a1* and a2*
         *
         * and simulate their results to test Theorem 2
         */
        // can be changed
        stepSize = 1;
        double[][][] pmf1 = new GetPmf(distributions[0], truncationQuantile, stepSize).getpmf();
        Distribution[] distributions1 = distributions[0];
        double[][][] pmf2 = new GetPmf(distributions[1], truncationQuantile, stepSize).getpmf();
        Distribution[] distributions2 = distributions[1];
        RecursionG recursionG1 = new RecursionG(pmf1, distributions1, price[0], variCost[0], 0, salPrice[0]);
        RecursionG recursionG2 = new RecursionG(pmf2, distributions2, price[1], variCost[1], 0, salPrice[1]);
        double[] opta1 = recursionG1.getOptY();
        double[] opta2 = recursionG2.getOptY();
        System.out.println("---------------");
        System.out.println("a1* in each period:");
        DecimalFormat df = new DecimalFormat("0.00");
        Arrays.stream(opta1).forEach(e -> System.out.print(df.format(e) + " "));
        System.out.println("");
        System.out.println("a2* in each period:");
        Arrays.stream(opta2).forEach(e -> System.out.print(df.format(e) + " "));
        // double simFinalValue2 = simulation.simulateSDPGivenSamplNuma1a22(iniState, variCost, opta1, opta2);
        // double gap2 = (simFinalValue2 - finalValue) / finalValue;
        // System.out.printf("optimality gap for this policy a* is %.2f%%\n", gap2 * 100);
        System.out.println();
        System.out.println("*****************************************");
        double[] mean = new double[] { demand[0][0], demand[1][0] };
        double[] variance = new double[] { demand[0][0] / beta[0], demand[1][0] / beta[1] };
        double[][] optTable = recursion.getOptTableDetail(mean, variance, price, opta1, opta2);
        double[] gaps = new double[] { gap };
        WriteToExcel wr = new WriteToExcel();
        String fileName = "run" + (int) paraSettings[runTime][0] + ".xls";
        String headString = "meanD1" + "\t" + "meanD2" + "\t" + "variance1" + "\t" + "variance2" + "\t" + "period" + "\t" + "x1" + "\t" + "x2" + "\t" + "w" + "\t" + "p1" + "\t" + "p2" + "\t" + "c1" + "\t" + "c2" + "\t" + "R" + "\t" + "y1*" + "\t" + "y2*" + "\t" + "cashSituation" + "\t" + "alpha" + "\t" + "yHead1" + "\t" + "yHead2" + "\t" + "a1*" + "\t" + "a2*" + "\t" + "Theorem1Gap";
        wr.writeArrayToExcel2(optTable, fileName, headString, gaps);
    }
}
Also used : RecursionG(sdp.cash.RecursionG) Arrays(java.util.Arrays) ReadExcel(sdp.write.ReadExcel) CashRecursionV2(sdp.cash.multiItem.CashRecursionV2) GammaDist(umontreal.ssj.probdist.GammaDist) DecimalFormat(java.text.DecimalFormat) UniformIntDist(umontreal.ssj.probdist.UniformIntDist) Function(java.util.function.Function) StateTransitionFunction(sdp.inventory.StateTransition.StateTransitionFunction) ArrayList(java.util.ArrayList) GetPmf(sdp.inventory.GetPmf) GetPmfMulti(sdp.cash.multiItem.GetPmfMulti) WriteToExcel(sdp.write.WriteToExcel) CashStateMulti(sdp.cash.multiItem.CashStateMulti) BoundaryFuncton(sdp.inventory.FinalCash.BoundaryFuncton) Distribution(umontreal.ssj.probdist.Distribution) CashSimulationY(sdp.cash.multiItem.CashSimulationY) ReadExcel(sdp.write.ReadExcel) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) CashSimulationY(sdp.cash.multiItem.CashSimulationY) WriteToExcel(sdp.write.WriteToExcel) GetPmfMulti(sdp.cash.multiItem.GetPmfMulti) GetPmf(sdp.inventory.GetPmf) RecursionG(sdp.cash.RecursionG) CashStateMulti(sdp.cash.multiItem.CashStateMulti) CashRecursionV2(sdp.cash.multiItem.CashRecursionV2) Distribution(umontreal.ssj.probdist.Distribution) UniformIntDist(umontreal.ssj.probdist.UniformIntDist)

Aggregations

ArrayList (java.util.ArrayList)6 Function (java.util.function.Function)6 CashStateMulti (sdp.cash.multiItem.CashStateMulti)6 GetPmfMulti (sdp.cash.multiItem.GetPmfMulti)6 WriteToExcel (sdp.write.WriteToExcel)6 GetPmf (sdp.inventory.GetPmf)5 Distribution (umontreal.ssj.probdist.Distribution)5 DecimalFormat (java.text.DecimalFormat)4 Arrays (java.util.Arrays)4 RecursionG (sdp.cash.RecursionG)4 CashSimulationY (sdp.cash.multiItem.CashSimulationY)4 BoundaryFuncton (sdp.inventory.FinalCash.BoundaryFuncton)4 StateTransitionFunction (sdp.inventory.StateTransition.StateTransitionFunction)4 GammaDist (umontreal.ssj.probdist.GammaDist)4 StateTransitionFunctionV (sdp.inventory.StateTransition.StateTransitionFunctionV)3 ReadExcel (sdp.write.ReadExcel)3 PoissonDist (umontreal.ssj.probdist.PoissonDist)3 UniformIntDist (umontreal.ssj.probdist.UniformIntDist)3 Actions (sdp.cash.multiItem.Actions)2 CashRecursionMulti (sdp.cash.multiItem.CashRecursionMulti)2