Search in sources :

Example 1 with MRG32k3aL

use of umontreal.ssj.rng.MRG32k3aL in project Stochastic-Inventory by RobinChen121.

the class LocalSearch method testLocalOptima.

public static void testLocalOptima() {
    long[] seed = { 1, 2, 3, 4, 5, 6 };
    MRG32k3aL randomGenerator = new MRG32k3aL();
    randomGenerator.setSeed(seed);
    PiecewiseComplementaryFirstOrderLossFunction[] pwcfolfs = new PiecewiseComplementaryFirstOrderLossFunction[2];
    double[] observations1 = { 28.0741, 37.0565, 17.8413, 36.5158, 21.6293, 20.4246, 71.4112, 37.6059, 37.9011, 36.325, 33.5892, 25.9398, 40.6084, 11.3667, 15.0024, 19.465, 27.265, 78.504, 27.1685, 76.4571, 72.0118, 23.7986, 70.5609, 26.463, 25.3521, 17.4925, 37.513, 22.7177, 32.0754, 17.4422, 33.2551, 23.8737, 47.2574, 67.5549, 29.6037, 22.3234, 54.5201, 73.9199, 32.543, 17.1827, 59.1714, 39.2098, 35.6647, 19.1226, 64.8445, 33.8207, 36.1044, 28.4903, 83.8897, 29.9214, 21.8565, 27.2275, 34.6711, 54.8081, 19.7576, 50.0901, 37.721, 33.0879, 57.5642, 35.861, 68.1631, 20.3139, 84.9478, 47.0687, 37.5119, 21.7852, 14.3257, 10.6876, 33.1993, 28.261, 33.2155, 72.4989, 32.2685, 19.1746, 73.9071, 20.9411, 23.4219, 26.4588, 34.7484, 28.6204, 83.3349, 27.4877, 25.5364, 31.3102, 40.1026, 32.2763, 33.9677, 31.4265, 21.5841, 80.9962, 73.9571, 38.615, 56.6494, 64.2206, 33.9953, 37.6291, 31.3204, 26.6406, 28.5466, -2.56407, 35.7539, 28.754, 60.4775, 69.5395, 34.5684, 31.4762, 32.1759, 19.9471, 30.4914, 15.3123, 17.905, 27.962, 25.1847, 25.2175, 42.4135, 25.4947, 70.2815, 14.2841, 82.3108, 19.0916, 49.0102, 65.6284, 18.0347, 18.5975, 47.6527, 37.7432, 24.0594, 26.3102, 23.7305, 12.6009, 21.9906, 32.4108, 23.6196, 9.21787, 54.7988, 42.6507, 73.5334, 25.6067, 40.7631, 41.9349, 33.7569, 35.2573, 24.3099, 84.2028, 25.7688, 34.3607, 26.5855, 72.5383, 18.8661, 43.656, 68.8784, 60.6869, 71.5258, 75.1431, 39.7538, 29.4983, 25.2816, 23.6204, 56.6435, 22.9425, 31.8486, 70.2084, 11.9978, 44.7344, 34.2046, 33.7131, 31.5913, 28.6397, 22.9598, 23.4668, 26.7419, 22.5111, 41.7394, 13.3714, 88.2541, 39.1714, 72.4239, 45.7921, 51.9322, 32.2951, 37.3388, 20.0179, 76.4912, 24.1718, 77.2087, 65.8098, 19.62, 66.0744, 82.2651, 71.2201, 31.6994, 23.6553, 33.0635, 40.4197, 32.6747, 19.7996, 36.0052, 38.047, 3.42543, 42.1742, 47.4269, 66.4148, 30.5918, 72.4994, 19.8016, 24.2546, 18.7883, 32.4965, 65.2762, 63.9234, 30.3478, 16.0009, 32.2717, 1.65196, 38.535, 18.3457, 67.7012, 65.6919, 23.9415, 46.8337, 16.2651, 30.1157, 31.8795, 32.3591, 67.1413, 57.5025, 71.8455, 75.0887, 36.4344, 73.0453, 27.7212, 61.0768, 28.8377, 53.9263, 31.5856, 16.1044, 3.69301, 32.019, 57.5973, 23.2975, 18.7782, 24.2909, 34.7884, 11.5381, 68.7499, 26.5432, 34.1972, 10.5637, 31.3054, 52.754, 39.1474, 18.1672, 31.4205, 30.3261, 18.3458, 80.6453, 48.8155, 11.3507, 80.1665, 37.2467, 32.2537, 33.6072, 18.2034, 72.6979, 38.2461, 32.6766, 61.6329, 25.8569, 47.2018, 28.3907, 82.2836, 33.8426, 15.9098, 55.6322, 28.8267, 36.0302, 47.4414, 26.6971, 64.2641, 64.7451, 33.8348, 70.7965, 36.2064, 75.1953, 31.2499, 20.7991, 21.3809, 27.5349, 24.9914, 39.1093, 19.0464, 73.5757, 15.6159, 34.3066, 24.6083, 17.9586, 75.8947, 91.4498, 36.1667, 40.1685, 23.598, 21.148, 24.6226, 35.7321, 63.3948, 74.7273, 28.7412, 68.3333, 28.5688, 21.9989, 21.1213, 26.1011, 35.5599, 28.1384, 20.021, 75.1544, 35.1936, 25.2616, 1.70038, 17.8895, 76.8902, 35.1254, 73.2399, 15.0038, 29.8682, 14.2947, 22.5822, 39.2031, 28.0553, 24.9845, 14.5433, 27.4424, 22.7428, 24.0465, 23.6355, 61.8469, 26.462, 39.7285, 46.4482, 32.341, 25.0918, 38.3904, 26.284, 30.667, 35.4871, 16.3957, 39.1846, 17.7234, 15.7191, 25.2957, 15.7521, 70.6436, 82.3403, 45.3663, 11.2882, 13.1438, 41.1792, 33.1248, 56.0817, 27.1867, 25.2638, 76.2728, 62.2844, 58.8604, 22.7928, 53.4659, 48.3358, 37.8583, 26.3246, 33.9605, 39.0206, 25.6244, 32.7355, 20.9361, 19.0955, 43.0133, 15.0526, 32.7747, 44.5282, 23.7317, 72.6272, 47.6351, 75.0638, 28.8967, 22.3245, 24.9527, 29.5371, 71.4213, 17.6563, 45.5411, 43.5561, 21.7395, 58.4722, 72.613, 33.405, 32.6981, 52.7684, 72.994, 23.1276, 28.9063 };
    Distribution[] distributions1 = { new EmpiricalDist(observations1) };
    pwcfolfs[0] = new PiecewiseComplementaryFirstOrderLossFunction(distributions1, seed);
    double[] observations2 = { 63.4049, 49.7431, 98.2874, 72.1489, 6.70325, 55.0911, 8.16425, 82.3973, 60.2456, 28.687, 97.931, 60.6241, 61.9652, 18.0754, 5.84652, 53.9288, 33.7648, 18.3471, 68.259, 44.8769, 74.7729, 9.37814, 72.2867, 41.2157, 10.2297, 60.669, 67.8683, 54.0558, 85.6881, 6.54943, 64.9499, 58.3083, 61.1755, 83.5816, 3.522, 0.251908, 35.498, 55.8284, 46.8813, 36.2971, 61.3581, 58.3464, 30.5702, 68.3962, 3.02535, 74.2239, 69.7271, 65.2046, 24.0099, 9.66892, 26.1496, 104.464, 53.0333, 44.0788, 90.7747, 6.67427, 4.69108, 89.7861, 60.0749, 35.3153, 71.3723, 1.93182, 66.4741, 25.1942, 83.0325, 88.2236, 87.9208, 21.8986, 57.9547, 34.6292, 5.85153, 82.153, 17.8169, 48.1183, 41.6441, 60.4861, 59.0518, 78.9059, 48.8856, 26.4719, 47.327, 1.62829, 42.9448, 0.983071, 82.8186, 73.1106, 8.37273, 75.131, 37.0327, 68.8736, 49.0243, 46.0151, 11.6974, 37.8142, 37.7773, 84.679, 46.8882, 66.7545, 7.46726, 49.7849, 77.1833, 25.9418, 90.9709, 52.351, 12.3385, 2.77454, 4.59362, 65.3159, 25.5208, 60.627, 14.2435, 0.858485, 45.5093, 44.2894, 63.1954, 23.5834, 53.0563, 23.5659, 2.47876, 7.0748, 69.4835, 10.0951, 62.1781, 73.4596, 63.0113, 83.1602, 3.79486, 66.7396, 8.8963, 42.173, 13.0026, 76.9337, 76.5908, 91.464, 4.47613, 64.0771, 1.17219, 4.6857, 0.812106, 66.9142, 85.04, 4.86323, 1.77279, 16.2038, 60.96, 77.9269, 13.5308, 47.6034, 18.2706, 32.5374, 23.7074, 26.6945, 52.257, 41.2909, 11.9714, 1.32484, 39.7415, 45.419, 29.4219, 87.5243, 33.0665, 14.2467, 0.796378, 49.4508, 67.184, 8.65801, 87.9505, 34.8374, 66.4889, 57.5287, 0.185386, 37.1761, 80.1379, 11.7232, 79.0982, 82.0065, 29.6477, 21.0023, 47.9231, 54.6587, 78.6668, 78.3218, 55.0015, 108.432, 94.6621, 40.893, 3.4765, 2.50739, 52.1598, 6.95193, 83.596, 14.3164, 14.5686, 49.4514, 69.6493, 65.9588, 73.4052, 56.9232, 50.7877, 75.3402, 99.0672, 15.507, 22.5798, 0.832404, 75.7336, 90.0872, 71.0788, 52.2645, 62.9782, 26.1946, 66.4443, 63.7976, 95.3219, 0.128229, 65.0506, 38.8051, 3.31758, 16.5506, 4.50226, 96.7296, 103.263, 84.7201, 11.8774, 51.6167, 44.2268, 0.525752, 58.3541, 65.6275, 37.118, 31.2515, 29.1207, 47.5121, 74.6872, 87.7308, 72.3813, 68.4761, 5.28055, 49.7506, 44.4426, 43.3843, 76.3153, 60.7385, 1.09989, 69.7635, 41.924, 1.24718, 3.92268, 0.336283, 19.7256, 46.4883, 70.1879, 78.9288, 21.3933, 33.7022, 48.1611, 2.95351, 1.48788, 22.3215, 80.1718, 97.617, 35.8137, 83.0107, 5.49969, 80.9309, 44.6753, 53.6202, 68.042, 69.3151, 59.8003, 54.2005, 73.1622, 63.8349, 73.2136, 73.3634, 40.4595, 61.0203, 46.9732, 45.5854, 59.8298, 23.2752, 49.556, 60.1231, 57.5179, 11.3818, 79.6682, 103.481, 99.1486, 4.82067, 36.6592, 6.82595, 43.8694, 67.6414, 36.354, 44.5273, 44.281, 49.1332, 76.4088, 59.8129, 15.3144, 53.2114, 52.2487, 11.17, 37.8858, 62.7593, 88.4599, 31.0753, 2.67468, 47.8929, 4.98802, 2.23822, 58.8278, 10.5323, 10.1903, 83.8942, 63.436, 25.4112, 42.9789, 33.7188, 93.7439, 91.2494, 8.46958, 41.7114, 55.0515, 87.0487, 55.6446, 14.8123, 53.7773, 44.2562, 63.3135, 39.2929, 23.8872, 75.3651, 68.6517, 6.5044, 20.1349, 3.19185, 43.7163, 9.21238, 7.54149, 53.4388, 69.902, 99.9, 71.6383, 82.8874, 82.8314, 90.2156, 60.4963, 55.7917, 66.4666, 93.7426, 47.7014, 74.4245, 3.3344, 10.9358, 27.8028, 48.5167, 72.8611, 0.804015, 74.455, 83.8912, 26.5895, 3.6511, 21.9575, 20.063, 26.505, 83.5355, 93.7192, 7.00239, 54.4818, 84.0105, 72.2029, 15.5663, 27.3149, 78.499, 33.5704, 13.7192, 39.0149, 57.9133, 14.9824, 56.6921, 16.5191, 47.431, 58.9464, 36.8409, 29.2285, 38.4334, 70.4695, 85.8938, 4.60473, 27.3362, 50.345, 49.2085, 12.4552, 40.9776, 13.9681, 3.25816, 11.3622, 37.1044, 61.4925, 25.2853 };
    Distribution[] distributions2 = { new EmpiricalDist(observations2) };
    pwcfolfs[1] = new PiecewiseComplementaryFirstOrderLossFunction(distributions2, seed);
    int nbSamples = 1000;
    // double[] bestMass = {0.3,0.3,0.1,0.04,0.26};
    double[] bestMass = { 0.16, 0.3, 0.1, 0.18, 0.26 };
    // double[] bestMass = {0.04,0.3,0.1,0.3,0.26};
    double maxApproxError = 0;
    for (int p = 0; p < pwcfolfs.length; p++) {
        maxApproxError = Math.max(maxApproxError, pwcfolfs[p].getMaxApproximationError(bestMass, nbSamples));
    }
    System.out.println(maxApproxError);
    pwcfolfs[0].plotPiecewiseLossFunction(0, 85, -1, bestMass, nbSamples, 0.1, false);
    pwcfolfs[1].plotPiecewiseLossFunction(0, 85, -1, bestMass, nbSamples, 0.1, false);
}
Also used : EmpiricalDist(umontreal.ssj.probdist.EmpiricalDist) Distribution(umontreal.ssj.probdist.Distribution) MRG32k3aL(umontreal.ssj.rng.MRG32k3aL) PiecewiseComplementaryFirstOrderLossFunction(milp.PiecewiseComplementaryFirstOrderLossFunction)

Example 2 with MRG32k3aL

use of umontreal.ssj.rng.MRG32k3aL in project Stochastic-Inventory by RobinChen121.

the class LocalSearch method exhaustiveEnumeration.

public static void exhaustiveEnumeration() {
    long[] seed = { 1, 2, 3, 4, 5, 6 };
    MRG32k3aL randomGenerator = new MRG32k3aL();
    randomGenerator.setSeed(seed);
    PiecewiseComplementaryFirstOrderLossFunction[] pwcfolfs = new PiecewiseComplementaryFirstOrderLossFunction[2];
    double[] observations1 = { 28.0741, 37.0565, 17.8413, 36.5158, 21.6293, 20.4246, 71.4112, 37.6059, 37.9011, 36.325, 33.5892, 25.9398, 40.6084, 11.3667, 15.0024, 19.465, 27.265, 78.504, 27.1685, 76.4571, 72.0118, 23.7986, 70.5609, 26.463, 25.3521, 17.4925, 37.513, 22.7177, 32.0754, 17.4422, 33.2551, 23.8737, 47.2574, 67.5549, 29.6037, 22.3234, 54.5201, 73.9199, 32.543, 17.1827, 59.1714, 39.2098, 35.6647, 19.1226, 64.8445, 33.8207, 36.1044, 28.4903, 83.8897, 29.9214, 21.8565, 27.2275, 34.6711, 54.8081, 19.7576, 50.0901, 37.721, 33.0879, 57.5642, 35.861, 68.1631, 20.3139, 84.9478, 47.0687, 37.5119, 21.7852, 14.3257, 10.6876, 33.1993, 28.261, 33.2155, 72.4989, 32.2685, 19.1746, 73.9071, 20.9411, 23.4219, 26.4588, 34.7484, 28.6204, 83.3349, 27.4877, 25.5364, 31.3102, 40.1026, 32.2763, 33.9677, 31.4265, 21.5841, 80.9962, 73.9571, 38.615, 56.6494, 64.2206, 33.9953, 37.6291, 31.3204, 26.6406, 28.5466, -2.56407, 35.7539, 28.754, 60.4775, 69.5395, 34.5684, 31.4762, 32.1759, 19.9471, 30.4914, 15.3123, 17.905, 27.962, 25.1847, 25.2175, 42.4135, 25.4947, 70.2815, 14.2841, 82.3108, 19.0916, 49.0102, 65.6284, 18.0347, 18.5975, 47.6527, 37.7432, 24.0594, 26.3102, 23.7305, 12.6009, 21.9906, 32.4108, 23.6196, 9.21787, 54.7988, 42.6507, 73.5334, 25.6067, 40.7631, 41.9349, 33.7569, 35.2573, 24.3099, 84.2028, 25.7688, 34.3607, 26.5855, 72.5383, 18.8661, 43.656, 68.8784, 60.6869, 71.5258, 75.1431, 39.7538, 29.4983, 25.2816, 23.6204, 56.6435, 22.9425, 31.8486, 70.2084, 11.9978, 44.7344, 34.2046, 33.7131, 31.5913, 28.6397, 22.9598, 23.4668, 26.7419, 22.5111, 41.7394, 13.3714, 88.2541, 39.1714, 72.4239, 45.7921, 51.9322, 32.2951, 37.3388, 20.0179, 76.4912, 24.1718, 77.2087, 65.8098, 19.62, 66.0744, 82.2651, 71.2201, 31.6994, 23.6553, 33.0635, 40.4197, 32.6747, 19.7996, 36.0052, 38.047, 3.42543, 42.1742, 47.4269, 66.4148, 30.5918, 72.4994, 19.8016, 24.2546, 18.7883, 32.4965, 65.2762, 63.9234, 30.3478, 16.0009, 32.2717, 1.65196, 38.535, 18.3457, 67.7012, 65.6919, 23.9415, 46.8337, 16.2651, 30.1157, 31.8795, 32.3591, 67.1413, 57.5025, 71.8455, 75.0887, 36.4344, 73.0453, 27.7212, 61.0768, 28.8377, 53.9263, 31.5856, 16.1044, 3.69301, 32.019, 57.5973, 23.2975, 18.7782, 24.2909, 34.7884, 11.5381, 68.7499, 26.5432, 34.1972, 10.5637, 31.3054, 52.754, 39.1474, 18.1672, 31.4205, 30.3261, 18.3458, 80.6453, 48.8155, 11.3507, 80.1665, 37.2467, 32.2537, 33.6072, 18.2034, 72.6979, 38.2461, 32.6766, 61.6329, 25.8569, 47.2018, 28.3907, 82.2836, 33.8426, 15.9098, 55.6322, 28.8267, 36.0302, 47.4414, 26.6971, 64.2641, 64.7451, 33.8348, 70.7965, 36.2064, 75.1953, 31.2499, 20.7991, 21.3809, 27.5349, 24.9914, 39.1093, 19.0464, 73.5757, 15.6159, 34.3066, 24.6083, 17.9586, 75.8947, 91.4498, 36.1667, 40.1685, 23.598, 21.148, 24.6226, 35.7321, 63.3948, 74.7273, 28.7412, 68.3333, 28.5688, 21.9989, 21.1213, 26.1011, 35.5599, 28.1384, 20.021, 75.1544, 35.1936, 25.2616, 1.70038, 17.8895, 76.8902, 35.1254, 73.2399, 15.0038, 29.8682, 14.2947, 22.5822, 39.2031, 28.0553, 24.9845, 14.5433, 27.4424, 22.7428, 24.0465, 23.6355, 61.8469, 26.462, 39.7285, 46.4482, 32.341, 25.0918, 38.3904, 26.284, 30.667, 35.4871, 16.3957, 39.1846, 17.7234, 15.7191, 25.2957, 15.7521, 70.6436, 82.3403, 45.3663, 11.2882, 13.1438, 41.1792, 33.1248, 56.0817, 27.1867, 25.2638, 76.2728, 62.2844, 58.8604, 22.7928, 53.4659, 48.3358, 37.8583, 26.3246, 33.9605, 39.0206, 25.6244, 32.7355, 20.9361, 19.0955, 43.0133, 15.0526, 32.7747, 44.5282, 23.7317, 72.6272, 47.6351, 75.0638, 28.8967, 22.3245, 24.9527, 29.5371, 71.4213, 17.6563, 45.5411, 43.5561, 21.7395, 58.4722, 72.613, 33.405, 32.6981, 52.7684, 72.994, 23.1276, 28.9063 };
    Distribution[] distributions1 = { new EmpiricalDist(observations1) };
    pwcfolfs[0] = new PiecewiseComplementaryFirstOrderLossFunction(distributions1, seed);
    double[] observations2 = { 63.4049, 49.7431, 98.2874, 72.1489, 6.70325, 55.0911, 8.16425, 82.3973, 60.2456, 28.687, 97.931, 60.6241, 61.9652, 18.0754, 5.84652, 53.9288, 33.7648, 18.3471, 68.259, 44.8769, 74.7729, 9.37814, 72.2867, 41.2157, 10.2297, 60.669, 67.8683, 54.0558, 85.6881, 6.54943, 64.9499, 58.3083, 61.1755, 83.5816, 3.522, 0.251908, 35.498, 55.8284, 46.8813, 36.2971, 61.3581, 58.3464, 30.5702, 68.3962, 3.02535, 74.2239, 69.7271, 65.2046, 24.0099, 9.66892, 26.1496, 104.464, 53.0333, 44.0788, 90.7747, 6.67427, 4.69108, 89.7861, 60.0749, 35.3153, 71.3723, 1.93182, 66.4741, 25.1942, 83.0325, 88.2236, 87.9208, 21.8986, 57.9547, 34.6292, 5.85153, 82.153, 17.8169, 48.1183, 41.6441, 60.4861, 59.0518, 78.9059, 48.8856, 26.4719, 47.327, 1.62829, 42.9448, 0.983071, 82.8186, 73.1106, 8.37273, 75.131, 37.0327, 68.8736, 49.0243, 46.0151, 11.6974, 37.8142, 37.7773, 84.679, 46.8882, 66.7545, 7.46726, 49.7849, 77.1833, 25.9418, 90.9709, 52.351, 12.3385, 2.77454, 4.59362, 65.3159, 25.5208, 60.627, 14.2435, 0.858485, 45.5093, 44.2894, 63.1954, 23.5834, 53.0563, 23.5659, 2.47876, 7.0748, 69.4835, 10.0951, 62.1781, 73.4596, 63.0113, 83.1602, 3.79486, 66.7396, 8.8963, 42.173, 13.0026, 76.9337, 76.5908, 91.464, 4.47613, 64.0771, 1.17219, 4.6857, 0.812106, 66.9142, 85.04, 4.86323, 1.77279, 16.2038, 60.96, 77.9269, 13.5308, 47.6034, 18.2706, 32.5374, 23.7074, 26.6945, 52.257, 41.2909, 11.9714, 1.32484, 39.7415, 45.419, 29.4219, 87.5243, 33.0665, 14.2467, 0.796378, 49.4508, 67.184, 8.65801, 87.9505, 34.8374, 66.4889, 57.5287, 0.185386, 37.1761, 80.1379, 11.7232, 79.0982, 82.0065, 29.6477, 21.0023, 47.9231, 54.6587, 78.6668, 78.3218, 55.0015, 108.432, 94.6621, 40.893, 3.4765, 2.50739, 52.1598, 6.95193, 83.596, 14.3164, 14.5686, 49.4514, 69.6493, 65.9588, 73.4052, 56.9232, 50.7877, 75.3402, 99.0672, 15.507, 22.5798, 0.832404, 75.7336, 90.0872, 71.0788, 52.2645, 62.9782, 26.1946, 66.4443, 63.7976, 95.3219, 0.128229, 65.0506, 38.8051, 3.31758, 16.5506, 4.50226, 96.7296, 103.263, 84.7201, 11.8774, 51.6167, 44.2268, 0.525752, 58.3541, 65.6275, 37.118, 31.2515, 29.1207, 47.5121, 74.6872, 87.7308, 72.3813, 68.4761, 5.28055, 49.7506, 44.4426, 43.3843, 76.3153, 60.7385, 1.09989, 69.7635, 41.924, 1.24718, 3.92268, 0.336283, 19.7256, 46.4883, 70.1879, 78.9288, 21.3933, 33.7022, 48.1611, 2.95351, 1.48788, 22.3215, 80.1718, 97.617, 35.8137, 83.0107, 5.49969, 80.9309, 44.6753, 53.6202, 68.042, 69.3151, 59.8003, 54.2005, 73.1622, 63.8349, 73.2136, 73.3634, 40.4595, 61.0203, 46.9732, 45.5854, 59.8298, 23.2752, 49.556, 60.1231, 57.5179, 11.3818, 79.6682, 103.481, 99.1486, 4.82067, 36.6592, 6.82595, 43.8694, 67.6414, 36.354, 44.5273, 44.281, 49.1332, 76.4088, 59.8129, 15.3144, 53.2114, 52.2487, 11.17, 37.8858, 62.7593, 88.4599, 31.0753, 2.67468, 47.8929, 4.98802, 2.23822, 58.8278, 10.5323, 10.1903, 83.8942, 63.436, 25.4112, 42.9789, 33.7188, 93.7439, 91.2494, 8.46958, 41.7114, 55.0515, 87.0487, 55.6446, 14.8123, 53.7773, 44.2562, 63.3135, 39.2929, 23.8872, 75.3651, 68.6517, 6.5044, 20.1349, 3.19185, 43.7163, 9.21238, 7.54149, 53.4388, 69.902, 99.9, 71.6383, 82.8874, 82.8314, 90.2156, 60.4963, 55.7917, 66.4666, 93.7426, 47.7014, 74.4245, 3.3344, 10.9358, 27.8028, 48.5167, 72.8611, 0.804015, 74.455, 83.8912, 26.5895, 3.6511, 21.9575, 20.063, 26.505, 83.5355, 93.7192, 7.00239, 54.4818, 84.0105, 72.2029, 15.5663, 27.3149, 78.499, 33.5704, 13.7192, 39.0149, 57.9133, 14.9824, 56.6921, 16.5191, 47.431, 58.9464, 36.8409, 29.2285, 38.4334, 70.4695, 85.8938, 4.60473, 27.3362, 50.345, 49.2085, 12.4552, 40.9776, 13.9681, 3.25816, 11.3622, 37.1044, 61.4925, 25.2853 };
    Distribution[] distributions2 = { new EmpiricalDist(observations2) };
    pwcfolfs[1] = new PiecewiseComplementaryFirstOrderLossFunction(distributions2, seed);
    int nbSamples = 1000;
    double precision = 0.02;
    try {
        File out = new File("plot.txt");
        out.delete();
        out = new File("plot.txt");
        PrintWriter pw = new PrintWriter(out);
        double m = 0.3;
        double n = 0.1;
        for (double i = precision; i + m + n < 1; i += precision) {
            for (double j = precision; j + i + m + n < 1; j += precision) {
                // for(double n = precision; j + i + m + n < 1; n+=precision){
                double k = 1.0 - i - j - m - n;
                double[] probabilityMass = { i, m, n, j, k };
                double maxApproxError = 0;
                for (int p = 0; p < pwcfolfs.length; p++) {
                    maxApproxError = Math.max(maxApproxError, pwcfolfs[p].getMaxApproximationError(probabilityMass, nbSamples));
                }
                // if(maxApproxError <= 1.2){
                pw.print("{");
                for (int p = 0; p < probabilityMass.length; p++) {
                    if (p == 1 || p == 2 || p == 4)
                        continue;
                    double sum = 0;
                    for (int l = 0; l <= p; l++) sum += probabilityMass[l];
                    pw.print(sum + ",");
                }
                // pw.println("},");
                // }
                pw.println(maxApproxError + "},");
            // }
            }
        }
        /*
			double m = 0.3;
			for(double i = precision; i + m < 1; i+=precision){
				for(double j = precision; j + i + m < 1; j+=precision){
					for(double n = precision; j + i + m + n < 1; n+=precision){
						double k = 1.0-i-j-m-n;
						double[] probabilityMass = {i,m,n,j,k};
						double maxApproxError = 0;
						for(int p = 0; p < pwcfolfs.length; p++){
							maxApproxError = Math.max(maxApproxError,pwcfolfs[p].getMaxApproximationError(probabilityMass, nbSamples));
						}
						if(maxApproxError <= 1.2){
							pw.print("{");
							for(int p = 0; p < probabilityMass.length; p++){
								if(p==1||p==4)continue;
								double sum = 0;
								for(int l = 0; l <= p; l++) sum += probabilityMass[l];
								pw.print(sum+",");
							}
							pw.println("},");
						}
						//pw.println(maxApproxError+"},");
					}
				}
			}
			*/
        /*double m = 0.1;
			double n = 0.3;
			double j = 0.1;
			for(double i = precision; i + m + n + j < 1; i+=precision){
				double k = 1.0-i-j-m-n;
				double[] probabilityMass = {i,j,k,n,m};
				double maxApproxError = 0;
				for(int p = 0; p < pwcfolfs.length; p++){
					maxApproxError = Math.max(maxApproxError,pwcfolfs[p].getMaxApproximationError(probabilityMass, nbSamples));
				}
				pw.print("{");
				pw.print(probabilityMass[0]+",");
				pw.println(maxApproxError+"},");
			}*/
        /*double m = 0.1;
			double n = 0.3;
			double j = 0.2;
			for(double i = precision; i + m + n + j < 1; i+=precision){
				double k = 1.0-i-j-m-n;
				double[] probabilityMass = {j,i,k,n,m};
				double maxApproxError = 0;
				for(int p = 0; p < pwcfolfs.length; p++){
					maxApproxError = Math.max(maxApproxError,pwcfolfs[p].getMaxApproximationError(probabilityMass, nbSamples));
				}
				pw.print("{");
				pw.print(probabilityMass[1]+",");
				pw.println(maxApproxError+"},");
			}*/
        pw.close();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : EmpiricalDist(umontreal.ssj.probdist.EmpiricalDist) FileNotFoundException(java.io.FileNotFoundException) Distribution(umontreal.ssj.probdist.Distribution) MRG32k3aL(umontreal.ssj.rng.MRG32k3aL) File(java.io.File) PiecewiseComplementaryFirstOrderLossFunction(milp.PiecewiseComplementaryFirstOrderLossFunction) PrintWriter(java.io.PrintWriter)

Example 3 with MRG32k3aL

use of umontreal.ssj.rng.MRG32k3aL in project Stochastic-Inventory by RobinChen121.

the class LocalSearch method testSimpleRandomSampling.

public static void testSimpleRandomSampling() {
    long[] seed = { 1, 2, 3, 4, 5, 6 };
    PiecewiseComplementaryFirstOrderLossFunction[] pwcfolfs = new PiecewiseComplementaryFirstOrderLossFunction[2];
    double[] observations1 = { 28.0741, 37.0565, 17.8413, 36.5158, 21.6293, 20.4246, 71.4112, 37.6059, 37.9011, 36.325, 33.5892, 25.9398, 40.6084, 11.3667, 15.0024, 19.465, 27.265, 78.504, 27.1685, 76.4571, 72.0118, 23.7986, 70.5609, 26.463, 25.3521, 17.4925, 37.513, 22.7177, 32.0754, 17.4422, 33.2551, 23.8737, 47.2574, 67.5549, 29.6037, 22.3234, 54.5201, 73.9199, 32.543, 17.1827, 59.1714, 39.2098, 35.6647, 19.1226, 64.8445, 33.8207, 36.1044, 28.4903, 83.8897, 29.9214, 21.8565, 27.2275, 34.6711, 54.8081, 19.7576, 50.0901, 37.721, 33.0879, 57.5642, 35.861, 68.1631, 20.3139, 84.9478, 47.0687, 37.5119, 21.7852, 14.3257, 10.6876, 33.1993, 28.261, 33.2155, 72.4989, 32.2685, 19.1746, 73.9071, 20.9411, 23.4219, 26.4588, 34.7484, 28.6204, 83.3349, 27.4877, 25.5364, 31.3102, 40.1026, 32.2763, 33.9677, 31.4265, 21.5841, 80.9962, 73.9571, 38.615, 56.6494, 64.2206, 33.9953, 37.6291, 31.3204, 26.6406, 28.5466, -2.56407, 35.7539, 28.754, 60.4775, 69.5395, 34.5684, 31.4762, 32.1759, 19.9471, 30.4914, 15.3123, 17.905, 27.962, 25.1847, 25.2175, 42.4135, 25.4947, 70.2815, 14.2841, 82.3108, 19.0916, 49.0102, 65.6284, 18.0347, 18.5975, 47.6527, 37.7432, 24.0594, 26.3102, 23.7305, 12.6009, 21.9906, 32.4108, 23.6196, 9.21787, 54.7988, 42.6507, 73.5334, 25.6067, 40.7631, 41.9349, 33.7569, 35.2573, 24.3099, 84.2028, 25.7688, 34.3607, 26.5855, 72.5383, 18.8661, 43.656, 68.8784, 60.6869, 71.5258, 75.1431, 39.7538, 29.4983, 25.2816, 23.6204, 56.6435, 22.9425, 31.8486, 70.2084, 11.9978, 44.7344, 34.2046, 33.7131, 31.5913, 28.6397, 22.9598, 23.4668, 26.7419, 22.5111, 41.7394, 13.3714, 88.2541, 39.1714, 72.4239, 45.7921, 51.9322, 32.2951, 37.3388, 20.0179, 76.4912, 24.1718, 77.2087, 65.8098, 19.62, 66.0744, 82.2651, 71.2201, 31.6994, 23.6553, 33.0635, 40.4197, 32.6747, 19.7996, 36.0052, 38.047, 3.42543, 42.1742, 47.4269, 66.4148, 30.5918, 72.4994, 19.8016, 24.2546, 18.7883, 32.4965, 65.2762, 63.9234, 30.3478, 16.0009, 32.2717, 1.65196, 38.535, 18.3457, 67.7012, 65.6919, 23.9415, 46.8337, 16.2651, 30.1157, 31.8795, 32.3591, 67.1413, 57.5025, 71.8455, 75.0887, 36.4344, 73.0453, 27.7212, 61.0768, 28.8377, 53.9263, 31.5856, 16.1044, 3.69301, 32.019, 57.5973, 23.2975, 18.7782, 24.2909, 34.7884, 11.5381, 68.7499, 26.5432, 34.1972, 10.5637, 31.3054, 52.754, 39.1474, 18.1672, 31.4205, 30.3261, 18.3458, 80.6453, 48.8155, 11.3507, 80.1665, 37.2467, 32.2537, 33.6072, 18.2034, 72.6979, 38.2461, 32.6766, 61.6329, 25.8569, 47.2018, 28.3907, 82.2836, 33.8426, 15.9098, 55.6322, 28.8267, 36.0302, 47.4414, 26.6971, 64.2641, 64.7451, 33.8348, 70.7965, 36.2064, 75.1953, 31.2499, 20.7991, 21.3809, 27.5349, 24.9914, 39.1093, 19.0464, 73.5757, 15.6159, 34.3066, 24.6083, 17.9586, 75.8947, 91.4498, 36.1667, 40.1685, 23.598, 21.148, 24.6226, 35.7321, 63.3948, 74.7273, 28.7412, 68.3333, 28.5688, 21.9989, 21.1213, 26.1011, 35.5599, 28.1384, 20.021, 75.1544, 35.1936, 25.2616, 1.70038, 17.8895, 76.8902, 35.1254, 73.2399, 15.0038, 29.8682, 14.2947, 22.5822, 39.2031, 28.0553, 24.9845, 14.5433, 27.4424, 22.7428, 24.0465, 23.6355, 61.8469, 26.462, 39.7285, 46.4482, 32.341, 25.0918, 38.3904, 26.284, 30.667, 35.4871, 16.3957, 39.1846, 17.7234, 15.7191, 25.2957, 15.7521, 70.6436, 82.3403, 45.3663, 11.2882, 13.1438, 41.1792, 33.1248, 56.0817, 27.1867, 25.2638, 76.2728, 62.2844, 58.8604, 22.7928, 53.4659, 48.3358, 37.8583, 26.3246, 33.9605, 39.0206, 25.6244, 32.7355, 20.9361, 19.0955, 43.0133, 15.0526, 32.7747, 44.5282, 23.7317, 72.6272, 47.6351, 75.0638, 28.8967, 22.3245, 24.9527, 29.5371, 71.4213, 17.6563, 45.5411, 43.5561, 21.7395, 58.4722, 72.613, 33.405, 32.6981, 52.7684, 72.994, 23.1276, 28.9063 };
    Distribution[] distributions1 = { new EmpiricalDist(observations1) };
    pwcfolfs[0] = new PiecewiseComplementaryFirstOrderLossFunction(distributions1, seed);
    double[] observations2 = { 63.4049, 49.7431, 98.2874, 72.1489, 6.70325, 55.0911, 8.16425, 82.3973, 60.2456, 28.687, 97.931, 60.6241, 61.9652, 18.0754, 5.84652, 53.9288, 33.7648, 18.3471, 68.259, 44.8769, 74.7729, 9.37814, 72.2867, 41.2157, 10.2297, 60.669, 67.8683, 54.0558, 85.6881, 6.54943, 64.9499, 58.3083, 61.1755, 83.5816, 3.522, 0.251908, 35.498, 55.8284, 46.8813, 36.2971, 61.3581, 58.3464, 30.5702, 68.3962, 3.02535, 74.2239, 69.7271, 65.2046, 24.0099, 9.66892, 26.1496, 104.464, 53.0333, 44.0788, 90.7747, 6.67427, 4.69108, 89.7861, 60.0749, 35.3153, 71.3723, 1.93182, 66.4741, 25.1942, 83.0325, 88.2236, 87.9208, 21.8986, 57.9547, 34.6292, 5.85153, 82.153, 17.8169, 48.1183, 41.6441, 60.4861, 59.0518, 78.9059, 48.8856, 26.4719, 47.327, 1.62829, 42.9448, 0.983071, 82.8186, 73.1106, 8.37273, 75.131, 37.0327, 68.8736, 49.0243, 46.0151, 11.6974, 37.8142, 37.7773, 84.679, 46.8882, 66.7545, 7.46726, 49.7849, 77.1833, 25.9418, 90.9709, 52.351, 12.3385, 2.77454, 4.59362, 65.3159, 25.5208, 60.627, 14.2435, 0.858485, 45.5093, 44.2894, 63.1954, 23.5834, 53.0563, 23.5659, 2.47876, 7.0748, 69.4835, 10.0951, 62.1781, 73.4596, 63.0113, 83.1602, 3.79486, 66.7396, 8.8963, 42.173, 13.0026, 76.9337, 76.5908, 91.464, 4.47613, 64.0771, 1.17219, 4.6857, 0.812106, 66.9142, 85.04, 4.86323, 1.77279, 16.2038, 60.96, 77.9269, 13.5308, 47.6034, 18.2706, 32.5374, 23.7074, 26.6945, 52.257, 41.2909, 11.9714, 1.32484, 39.7415, 45.419, 29.4219, 87.5243, 33.0665, 14.2467, 0.796378, 49.4508, 67.184, 8.65801, 87.9505, 34.8374, 66.4889, 57.5287, 0.185386, 37.1761, 80.1379, 11.7232, 79.0982, 82.0065, 29.6477, 21.0023, 47.9231, 54.6587, 78.6668, 78.3218, 55.0015, 108.432, 94.6621, 40.893, 3.4765, 2.50739, 52.1598, 6.95193, 83.596, 14.3164, 14.5686, 49.4514, 69.6493, 65.9588, 73.4052, 56.9232, 50.7877, 75.3402, 99.0672, 15.507, 22.5798, 0.832404, 75.7336, 90.0872, 71.0788, 52.2645, 62.9782, 26.1946, 66.4443, 63.7976, 95.3219, 0.128229, 65.0506, 38.8051, 3.31758, 16.5506, 4.50226, 96.7296, 103.263, 84.7201, 11.8774, 51.6167, 44.2268, 0.525752, 58.3541, 65.6275, 37.118, 31.2515, 29.1207, 47.5121, 74.6872, 87.7308, 72.3813, 68.4761, 5.28055, 49.7506, 44.4426, 43.3843, 76.3153, 60.7385, 1.09989, 69.7635, 41.924, 1.24718, 3.92268, 0.336283, 19.7256, 46.4883, 70.1879, 78.9288, 21.3933, 33.7022, 48.1611, 2.95351, 1.48788, 22.3215, 80.1718, 97.617, 35.8137, 83.0107, 5.49969, 80.9309, 44.6753, 53.6202, 68.042, 69.3151, 59.8003, 54.2005, 73.1622, 63.8349, 73.2136, 73.3634, 40.4595, 61.0203, 46.9732, 45.5854, 59.8298, 23.2752, 49.556, 60.1231, 57.5179, 11.3818, 79.6682, 103.481, 99.1486, 4.82067, 36.6592, 6.82595, 43.8694, 67.6414, 36.354, 44.5273, 44.281, 49.1332, 76.4088, 59.8129, 15.3144, 53.2114, 52.2487, 11.17, 37.8858, 62.7593, 88.4599, 31.0753, 2.67468, 47.8929, 4.98802, 2.23822, 58.8278, 10.5323, 10.1903, 83.8942, 63.436, 25.4112, 42.9789, 33.7188, 93.7439, 91.2494, 8.46958, 41.7114, 55.0515, 87.0487, 55.6446, 14.8123, 53.7773, 44.2562, 63.3135, 39.2929, 23.8872, 75.3651, 68.6517, 6.5044, 20.1349, 3.19185, 43.7163, 9.21238, 7.54149, 53.4388, 69.902, 99.9, 71.6383, 82.8874, 82.8314, 90.2156, 60.4963, 55.7917, 66.4666, 93.7426, 47.7014, 74.4245, 3.3344, 10.9358, 27.8028, 48.5167, 72.8611, 0.804015, 74.455, 83.8912, 26.5895, 3.6511, 21.9575, 20.063, 26.505, 83.5355, 93.7192, 7.00239, 54.4818, 84.0105, 72.2029, 15.5663, 27.3149, 78.499, 33.5704, 13.7192, 39.0149, 57.9133, 14.9824, 56.6921, 16.5191, 47.431, 58.9464, 36.8409, 29.2285, 38.4334, 70.4695, 85.8938, 4.60473, 27.3362, 50.345, 49.2085, 12.4552, 40.9776, 13.9681, 3.25816, 11.3622, 37.1044, 61.4925, 25.2853 };
    Distribution[] distributions2 = { new EmpiricalDist(observations2) };
    pwcfolfs[1] = new PiecewiseComplementaryFirstOrderLossFunction(distributions2, seed);
    MRG32k3aL randomGenerator = new MRG32k3aL();
    randomGenerator.setSeed(seed);
    int nbSamples = 1000;
    int partitions = 3;
    int population = 1000;
    double[] bestMass = simpleRandomSampling(randomGenerator, nbSamples, pwcfolfs, partitions, population);
    pwcfolfs[0].plotPiecewiseLossFunction(0, 100, -1, bestMass, nbSamples, 0.01, false);
    pwcfolfs[1].plotPiecewiseLossFunction(0, 100, -1, bestMass, nbSamples, 0.01, false);
}
Also used : EmpiricalDist(umontreal.ssj.probdist.EmpiricalDist) Distribution(umontreal.ssj.probdist.Distribution) MRG32k3aL(umontreal.ssj.rng.MRG32k3aL) PiecewiseComplementaryFirstOrderLossFunction(milp.PiecewiseComplementaryFirstOrderLossFunction)

Example 4 with MRG32k3aL

use of umontreal.ssj.rng.MRG32k3aL in project Stochastic-Inventory by RobinChen121.

the class LocalSearch method testCoordinateDescent.

public static void testCoordinateDescent() {
    long[] seed = { 1, 2, 3, 4, 5, 6 };
    PiecewiseComplementaryFirstOrderLossFunction[] pwcfolfs = new PiecewiseComplementaryFirstOrderLossFunction[2];
    double[] observations1 = { 28.0741, 37.0565, 17.8413, 36.5158, 21.6293, 20.4246, 71.4112, 37.6059, 37.9011, 36.325, 33.5892, 25.9398, 40.6084, 11.3667, 15.0024, 19.465, 27.265, 78.504, 27.1685, 76.4571, 72.0118, 23.7986, 70.5609, 26.463, 25.3521, 17.4925, 37.513, 22.7177, 32.0754, 17.4422, 33.2551, 23.8737, 47.2574, 67.5549, 29.6037, 22.3234, 54.5201, 73.9199, 32.543, 17.1827, 59.1714, 39.2098, 35.6647, 19.1226, 64.8445, 33.8207, 36.1044, 28.4903, 83.8897, 29.9214, 21.8565, 27.2275, 34.6711, 54.8081, 19.7576, 50.0901, 37.721, 33.0879, 57.5642, 35.861, 68.1631, 20.3139, 84.9478, 47.0687, 37.5119, 21.7852, 14.3257, 10.6876, 33.1993, 28.261, 33.2155, 72.4989, 32.2685, 19.1746, 73.9071, 20.9411, 23.4219, 26.4588, 34.7484, 28.6204, 83.3349, 27.4877, 25.5364, 31.3102, 40.1026, 32.2763, 33.9677, 31.4265, 21.5841, 80.9962, 73.9571, 38.615, 56.6494, 64.2206, 33.9953, 37.6291, 31.3204, 26.6406, 28.5466, -2.56407, 35.7539, 28.754, 60.4775, 69.5395, 34.5684, 31.4762, 32.1759, 19.9471, 30.4914, 15.3123, 17.905, 27.962, 25.1847, 25.2175, 42.4135, 25.4947, 70.2815, 14.2841, 82.3108, 19.0916, 49.0102, 65.6284, 18.0347, 18.5975, 47.6527, 37.7432, 24.0594, 26.3102, 23.7305, 12.6009, 21.9906, 32.4108, 23.6196, 9.21787, 54.7988, 42.6507, 73.5334, 25.6067, 40.7631, 41.9349, 33.7569, 35.2573, 24.3099, 84.2028, 25.7688, 34.3607, 26.5855, 72.5383, 18.8661, 43.656, 68.8784, 60.6869, 71.5258, 75.1431, 39.7538, 29.4983, 25.2816, 23.6204, 56.6435, 22.9425, 31.8486, 70.2084, 11.9978, 44.7344, 34.2046, 33.7131, 31.5913, 28.6397, 22.9598, 23.4668, 26.7419, 22.5111, 41.7394, 13.3714, 88.2541, 39.1714, 72.4239, 45.7921, 51.9322, 32.2951, 37.3388, 20.0179, 76.4912, 24.1718, 77.2087, 65.8098, 19.62, 66.0744, 82.2651, 71.2201, 31.6994, 23.6553, 33.0635, 40.4197, 32.6747, 19.7996, 36.0052, 38.047, 3.42543, 42.1742, 47.4269, 66.4148, 30.5918, 72.4994, 19.8016, 24.2546, 18.7883, 32.4965, 65.2762, 63.9234, 30.3478, 16.0009, 32.2717, 1.65196, 38.535, 18.3457, 67.7012, 65.6919, 23.9415, 46.8337, 16.2651, 30.1157, 31.8795, 32.3591, 67.1413, 57.5025, 71.8455, 75.0887, 36.4344, 73.0453, 27.7212, 61.0768, 28.8377, 53.9263, 31.5856, 16.1044, 3.69301, 32.019, 57.5973, 23.2975, 18.7782, 24.2909, 34.7884, 11.5381, 68.7499, 26.5432, 34.1972, 10.5637, 31.3054, 52.754, 39.1474, 18.1672, 31.4205, 30.3261, 18.3458, 80.6453, 48.8155, 11.3507, 80.1665, 37.2467, 32.2537, 33.6072, 18.2034, 72.6979, 38.2461, 32.6766, 61.6329, 25.8569, 47.2018, 28.3907, 82.2836, 33.8426, 15.9098, 55.6322, 28.8267, 36.0302, 47.4414, 26.6971, 64.2641, 64.7451, 33.8348, 70.7965, 36.2064, 75.1953, 31.2499, 20.7991, 21.3809, 27.5349, 24.9914, 39.1093, 19.0464, 73.5757, 15.6159, 34.3066, 24.6083, 17.9586, 75.8947, 91.4498, 36.1667, 40.1685, 23.598, 21.148, 24.6226, 35.7321, 63.3948, 74.7273, 28.7412, 68.3333, 28.5688, 21.9989, 21.1213, 26.1011, 35.5599, 28.1384, 20.021, 75.1544, 35.1936, 25.2616, 1.70038, 17.8895, 76.8902, 35.1254, 73.2399, 15.0038, 29.8682, 14.2947, 22.5822, 39.2031, 28.0553, 24.9845, 14.5433, 27.4424, 22.7428, 24.0465, 23.6355, 61.8469, 26.462, 39.7285, 46.4482, 32.341, 25.0918, 38.3904, 26.284, 30.667, 35.4871, 16.3957, 39.1846, 17.7234, 15.7191, 25.2957, 15.7521, 70.6436, 82.3403, 45.3663, 11.2882, 13.1438, 41.1792, 33.1248, 56.0817, 27.1867, 25.2638, 76.2728, 62.2844, 58.8604, 22.7928, 53.4659, 48.3358, 37.8583, 26.3246, 33.9605, 39.0206, 25.6244, 32.7355, 20.9361, 19.0955, 43.0133, 15.0526, 32.7747, 44.5282, 23.7317, 72.6272, 47.6351, 75.0638, 28.8967, 22.3245, 24.9527, 29.5371, 71.4213, 17.6563, 45.5411, 43.5561, 21.7395, 58.4722, 72.613, 33.405, 32.6981, 52.7684, 72.994, 23.1276, 28.9063 };
    Distribution[] distributions1 = { new EmpiricalDist(observations1) };
    pwcfolfs[0] = new PiecewiseComplementaryFirstOrderLossFunction(distributions1, seed);
    double[] observations2 = { 63.4049, 49.7431, 98.2874, 72.1489, 6.70325, 55.0911, 8.16425, 82.3973, 60.2456, 28.687, 97.931, 60.6241, 61.9652, 18.0754, 5.84652, 53.9288, 33.7648, 18.3471, 68.259, 44.8769, 74.7729, 9.37814, 72.2867, 41.2157, 10.2297, 60.669, 67.8683, 54.0558, 85.6881, 6.54943, 64.9499, 58.3083, 61.1755, 83.5816, 3.522, 0.251908, 35.498, 55.8284, 46.8813, 36.2971, 61.3581, 58.3464, 30.5702, 68.3962, 3.02535, 74.2239, 69.7271, 65.2046, 24.0099, 9.66892, 26.1496, 104.464, 53.0333, 44.0788, 90.7747, 6.67427, 4.69108, 89.7861, 60.0749, 35.3153, 71.3723, 1.93182, 66.4741, 25.1942, 83.0325, 88.2236, 87.9208, 21.8986, 57.9547, 34.6292, 5.85153, 82.153, 17.8169, 48.1183, 41.6441, 60.4861, 59.0518, 78.9059, 48.8856, 26.4719, 47.327, 1.62829, 42.9448, 0.983071, 82.8186, 73.1106, 8.37273, 75.131, 37.0327, 68.8736, 49.0243, 46.0151, 11.6974, 37.8142, 37.7773, 84.679, 46.8882, 66.7545, 7.46726, 49.7849, 77.1833, 25.9418, 90.9709, 52.351, 12.3385, 2.77454, 4.59362, 65.3159, 25.5208, 60.627, 14.2435, 0.858485, 45.5093, 44.2894, 63.1954, 23.5834, 53.0563, 23.5659, 2.47876, 7.0748, 69.4835, 10.0951, 62.1781, 73.4596, 63.0113, 83.1602, 3.79486, 66.7396, 8.8963, 42.173, 13.0026, 76.9337, 76.5908, 91.464, 4.47613, 64.0771, 1.17219, 4.6857, 0.812106, 66.9142, 85.04, 4.86323, 1.77279, 16.2038, 60.96, 77.9269, 13.5308, 47.6034, 18.2706, 32.5374, 23.7074, 26.6945, 52.257, 41.2909, 11.9714, 1.32484, 39.7415, 45.419, 29.4219, 87.5243, 33.0665, 14.2467, 0.796378, 49.4508, 67.184, 8.65801, 87.9505, 34.8374, 66.4889, 57.5287, 0.185386, 37.1761, 80.1379, 11.7232, 79.0982, 82.0065, 29.6477, 21.0023, 47.9231, 54.6587, 78.6668, 78.3218, 55.0015, 108.432, 94.6621, 40.893, 3.4765, 2.50739, 52.1598, 6.95193, 83.596, 14.3164, 14.5686, 49.4514, 69.6493, 65.9588, 73.4052, 56.9232, 50.7877, 75.3402, 99.0672, 15.507, 22.5798, 0.832404, 75.7336, 90.0872, 71.0788, 52.2645, 62.9782, 26.1946, 66.4443, 63.7976, 95.3219, 0.128229, 65.0506, 38.8051, 3.31758, 16.5506, 4.50226, 96.7296, 103.263, 84.7201, 11.8774, 51.6167, 44.2268, 0.525752, 58.3541, 65.6275, 37.118, 31.2515, 29.1207, 47.5121, 74.6872, 87.7308, 72.3813, 68.4761, 5.28055, 49.7506, 44.4426, 43.3843, 76.3153, 60.7385, 1.09989, 69.7635, 41.924, 1.24718, 3.92268, 0.336283, 19.7256, 46.4883, 70.1879, 78.9288, 21.3933, 33.7022, 48.1611, 2.95351, 1.48788, 22.3215, 80.1718, 97.617, 35.8137, 83.0107, 5.49969, 80.9309, 44.6753, 53.6202, 68.042, 69.3151, 59.8003, 54.2005, 73.1622, 63.8349, 73.2136, 73.3634, 40.4595, 61.0203, 46.9732, 45.5854, 59.8298, 23.2752, 49.556, 60.1231, 57.5179, 11.3818, 79.6682, 103.481, 99.1486, 4.82067, 36.6592, 6.82595, 43.8694, 67.6414, 36.354, 44.5273, 44.281, 49.1332, 76.4088, 59.8129, 15.3144, 53.2114, 52.2487, 11.17, 37.8858, 62.7593, 88.4599, 31.0753, 2.67468, 47.8929, 4.98802, 2.23822, 58.8278, 10.5323, 10.1903, 83.8942, 63.436, 25.4112, 42.9789, 33.7188, 93.7439, 91.2494, 8.46958, 41.7114, 55.0515, 87.0487, 55.6446, 14.8123, 53.7773, 44.2562, 63.3135, 39.2929, 23.8872, 75.3651, 68.6517, 6.5044, 20.1349, 3.19185, 43.7163, 9.21238, 7.54149, 53.4388, 69.902, 99.9, 71.6383, 82.8874, 82.8314, 90.2156, 60.4963, 55.7917, 66.4666, 93.7426, 47.7014, 74.4245, 3.3344, 10.9358, 27.8028, 48.5167, 72.8611, 0.804015, 74.455, 83.8912, 26.5895, 3.6511, 21.9575, 20.063, 26.505, 83.5355, 93.7192, 7.00239, 54.4818, 84.0105, 72.2029, 15.5663, 27.3149, 78.499, 33.5704, 13.7192, 39.0149, 57.9133, 14.9824, 56.6921, 16.5191, 47.431, 58.9464, 36.8409, 29.2285, 38.4334, 70.4695, 85.8938, 4.60473, 27.3362, 50.345, 49.2085, 12.4552, 40.9776, 13.9681, 3.25816, 11.3622, 37.1044, 61.4925, 25.2853 };
    Distribution[] distributions2 = { new EmpiricalDist(observations2) };
    pwcfolfs[1] = new PiecewiseComplementaryFirstOrderLossFunction(distributions2, seed);
    MRG32k3aL randomGenerator = new MRG32k3aL();
    randomGenerator.setSeed(seed);
    int nbSamples = 1000;
    int population = 1000;
    int partitions = 5;
    double[] bestMass = coordinateDescent(randomGenerator, nbSamples, pwcfolfs, partitions, population);
    pwcfolfs[0].plotPiecewiseLossFunction(0, 87, -1, bestMass, nbSamples, 0.1, true);
    pwcfolfs[1].plotPiecewiseLossFunction(0, 87, -1, bestMass, nbSamples, 0.1, false);
}
Also used : EmpiricalDist(umontreal.ssj.probdist.EmpiricalDist) Distribution(umontreal.ssj.probdist.Distribution) MRG32k3aL(umontreal.ssj.rng.MRG32k3aL) PiecewiseComplementaryFirstOrderLossFunction(milp.PiecewiseComplementaryFirstOrderLossFunction)

Example 5 with MRG32k3aL

use of umontreal.ssj.rng.MRG32k3aL in project Stochastic-Inventory by RobinChen121.

the class LocalSearch method testMonteCarlo.

public static void testMonteCarlo(int nbIterations) {
    long[] seed = { 1, 2, 3, 4, 5, 6 };
    MRG32k3aL randomGenerator = new MRG32k3aL();
    randomGenerator.setSeed(seed);
    int nbSamples = 1000;
    int population = 100;
    int partitions = 10;
    double[] avgBestMass = new double[partitions];
    Tally[] tally = new Tally[partitions];
    for (int i = 0; i < tally.length; i++) tally[i] = new Tally();
    PiecewiseComplementaryFirstOrderLossFunction[] pwcfolfs = new PiecewiseComplementaryFirstOrderLossFunction[1];
    Distribution[] distributions1 = { new NormalDist(0, 1) };
    pwcfolfs[0] = new PiecewiseComplementaryFirstOrderLossFunction(distributions1, seed);
    for (int i = 0; i < nbIterations; i++) {
        double[] bestMass = simpleRandomSampling(randomGenerator, nbSamples, pwcfolfs, partitions, population);
        for (int j = 0; j < bestMass.length; j++) {
            avgBestMass[j] += bestMass[j];
            tally[j].add(bestMass[j]);
        }
    }
    for (int i = 0; i < avgBestMass.length; i++) avgBestMass[i] /= nbIterations;
    double maxApproxError = 0;
    for (int i = 0; i < pwcfolfs.length; i++) {
        maxApproxError = Math.max(maxApproxError, pwcfolfs[i].getMaxApproximationError(avgBestMass, nbSamples));
    }
    System.out.println("AVG Minimax: " + maxApproxError);
    for (int i = 0; i < partitions; i++) {
        System.out.print(avgBestMass[i] + "\t");
    }
    System.out.println();
    for (int i = 0; i < partitions; i++) {
        System.out.print(tally[i].formatCIStudent(0.95));
    }
    pwcfolfs[0].plotPiecewiseLossFunction(-2, 2, -1, avgBestMass, nbSamples, 0.01, false);
}
Also used : Tally(umontreal.ssj.stat.Tally) Distribution(umontreal.ssj.probdist.Distribution) MRG32k3aL(umontreal.ssj.rng.MRG32k3aL) PiecewiseComplementaryFirstOrderLossFunction(milp.PiecewiseComplementaryFirstOrderLossFunction) NormalDist(umontreal.ssj.probdist.NormalDist)

Aggregations

PiecewiseComplementaryFirstOrderLossFunction (milp.PiecewiseComplementaryFirstOrderLossFunction)6 Distribution (umontreal.ssj.probdist.Distribution)6 MRG32k3aL (umontreal.ssj.rng.MRG32k3aL)6 EmpiricalDist (umontreal.ssj.probdist.EmpiricalDist)4 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 PrintWriter (java.io.PrintWriter)1 NormalDist (umontreal.ssj.probdist.NormalDist)1 Tally (umontreal.ssj.stat.Tally)1