int Dev = 10;// Deviation
extern const int CNN = 1;// Case Index
extern const int P = 3;// Number of phases
extern const int PT = 6;// Number of periods in a phase
extern const int T = 18;// Number of periods
extern const int I1 =1;// Number of suppliers
extern const int I2 = 8;// Number of customers
extern const int I = 9;// Number of sites
extern const int BN = 72;//Number of bids
extern const int LBN = 9;//Number of bids on each arc
extern const int SPN = 339;//Number of shipments
extern const int SN = 10;//Number of scenarios at each stage
extern const int MBSN = 9;//Number of shipments in a bid
// tree parameters:
double PRO[P][SN]={{0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1},{0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1},{0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1}}; // the probability of each scenario at each phase 
// timing parameters: 
int PTN[P]={6,6,6}; // number of periods in each phase 
int PTset[P][PT]={{0,1,2,3,4,5},{6,7,8,9,10,11},{12,13,14,15,16,17}}; // set of periods in each phase 
// distribution parameters: 
int sup[I][P][SN][PT]={{{{11408,0,0,0,0,0},{11615,0,0,0,0,0},{11400,0,0,0,0,0},{11421,0,0,0,0,0},{11558,0,0,0,0,0},{11534,0,0,0,0,0},{11594,0,0,0,0,0},{11595,0,0,0,0,0},{11726,0,0,0,0,0},{11553,0,0,0,0,0}},{{11316,0,0,0,0,0},{11677,0,0,0,0,0},{11516,0,0,0,0,0},{11630,0,0,0,0,0},{11392,0,0,0,0,0},{11482,0,0,0,0,0},{11441,0,0,0,0,0},{11563,0,0,0,0,0},{11761,0,0,0,0,0},{11582,0,0,0,0,0}},{{11667,0,0,0,0,0},{11389,0,0,0,0,0},{11415,0,0,0,0,0},{11419,0,0,0,0,0},{11460,0,0,0,0,0},{11422,0,0,0,0,0},{11466,0,0,0,0,0},{11689,0,0,0,0,0},{11472,0,0,0,0,0},{11566,0,0,0,0,0}}},{{{-185,-221,-193,-187,-199,-209},{-195,-197,-201,-185,-207,-209},{-189,-183,-185,-209,-219,-201},{-199,-183,-185,-203,-209,-219},{-195,-195,-223,-193,-217,-201},{-221,-195,-207,-197,-213,-201},{-203,-217,-215,-183,-215,-187},{-217,-211,-197,-217,-213,-187},{-213,-223,-189,-207,-221,-217},{-215,-215,-185,-201,-183,-189}},{{-213,-191,-199,-183,-185,-215},{-195,-219,-213,-203,-209,-215},{-195,-215,-209,-219,-221,-221},{-205,-189,-223,-189,-189,-205},{-203,-199,-201,-199,-187,-215},{-203,-205,-201,-199,-215,-213},{-203,-191,-191,-205,-207,-183},{-193,-187,-223,-213,-197,-223},{-223,-199,-223,-197,-191,-223},{-191,-203,-195,-193,-219,-217}},{{-215,-223,-217,-221,-195,-205},{-203,-215,-199,-193,-187,-213},{-209,-207,-221,-207,-183,-189},{-215,-221,-189,-217,-191,-207},{-195,-189,-197,-223,-199,-205},{-191,-207,-203,-207,-211,-187},{-223,-211,-215,-193,-183,-195},{-211,-201,-213,-221,-207,-217},{-207,-201,-223,-197,-219,-191},{-189,-205,-209,-205,-223,-195}}},{{{-172,-156,-148,-169,-163,-150},{-161,-167,-171,-159,-167,-167},{-147,-147,-174,-169,-155,-156},{-159,-161,-155,-163,-159,-150},{-161,-169,-148,-177,-153,-175},{-145,-172,-177,-156,-156,-163},{-153,-177,-145,-166,-177,-169},{-150,-164,-159,-150,-156,-172},{-158,-172,-167,-159,-164,-167},{-147,-150,-159,-177,-171,-172}},{{-150,-164,-167,-155,-171,-161},{-156,-175,-163,-163,-177,-145},{-148,-155,-167,-166,-155,-155},{-175,-145,-167,-175,-145,-150},{-153,-171,-169,-159,-161,-172},{-172,-147,-156,-158,-156,-172},{-147,-150,-148,-147,-164,-163},{-174,-167,-147,-163,-148,-164},{-158,-166,-158,-167,-175,-145},{-172,-169,-150,-156,-172,-174}},{{-164,-158,-148,-156,-171,-158},{-150,-172,-156,-172,-145,-172},{-151,-164,-163,-175,-169,-161},{-161,-161,-158,-151,-163,-163},{-174,-159,-161,-148,-164,-156},{-167,-153,-159,-163,-145,-147},{-155,-169,-158,-153,-175,-163},{-158,-169,-151,-175,-171,-163},{-175,-156,-150,-174,-167,-167},{-166,-163,-155,-159,-153,-150}}},{{{-231,-229,-243,-208,-238,-236},{-240,-210,-254,-249,-213,-247},{-226,-245,-222,-215,-222,-238},{-238,-249,-238,-224,-213,-245},{-213,-240,-245,-217,-231,-224},{-210,-231,-213,-226,-219,-243},{-210,-245,-231,-236,-245,-236},{-231,-224,-217,-236,-243,-240},{-240,-217,-229,-222,-247,-252},{-247,-254,-231,-213,-238,-238}},{{-222,-217,-247,-229,-238,-215},{-213,-217,-219,-238,-231,-245},{-229,-247,-231,-215,-210,-252},{-233,-219,-236,-222,-233,-254},{-215,-254,-222,-233,-224,-222},{-224,-252,-238,-217,-215,-231},{-233,-226,-210,-243,-233,-219},{-224,-254,-249,-233,-226,-217},{-245,-240,-249,-231,-247,-254},{-249,-240,-233,-222,-236,-226}},{{-245,-247,-247,-226,-245,-231},{-236,-236,-249,-245,-249,-213},{-226,-252,-252,-231,-247,-219},{-224,-233,-249,-226,-217,-252},{-233,-213,-240,-245,-229,-215},{-224,-247,-222,-217,-233,-236},{-236,-245,-236,-229,-208,-217},{-226,-215,-229,-245,-252,-247},{-229,-243,-215,-219,-245,-217},{-238,-252,-233,-229,-224,-219}}},{{{-226,-217,-217,-202,-234,-221},{-234,-215,-200,-221,-228,-221},{-215,-228,-204,-221,-217,-239},{-195,-202,-239,-228,-224,-224},{-226,-217,-197,-204,-206,-239},{-219,-200,-213,-234,-195,-224},{-237,-206,-234,-197,-204,-204},{-226,-210,-239,-226,-195,-213},{-202,-224,-226,-210,-210,-215},{-226,-208,-239,-217,-208,-230}},{{-202,-197,-232,-226,-208,-197},{-215,-210,-213,-221,-221,-210},{-197,-221,-230,-200,-224,-221},{-200,-221,-232,-195,-208,-232},{-208,-234,-195,-208,-195,-197},{-239,-206,-221,-206,-224,-226},{-213,-228,-217,-230,-206,-228},{-234,-206,-213,-239,-206,-224},{-230,-208,-195,-234,-200,-210},{-215,-221,-221,-206,-213,-200}},{{-202,-204,-224,-232,-197,-195},{-228,-215,-219,-206,-239,-217},{-224,-224,-232,-195,-217,-237},{-237,-215,-195,-204,-232,-202},{-219,-239,-237,-208,-195,-200},{-230,-221,-221,-221,-221,-206},{-210,-202,-200,-195,-210,-221},{-237,-234,-195,-237,-215,-221},{-197,-224,-195,-197,-200,-237},{-234,-197,-213,-219,-224,-221}}},{{{-279,-293,-247,-271,-242,-261},{-287,-263,-247,-293,-255,-277},{-261,-245,-287,-277,-253,-279},{-250,-239,-261,-261,-274,-277},{-269,-285,-255,-242,-245,-269},{-253,-279,-279,-282,-287,-285},{-285,-293,-279,-245,-261,-290},{-282,-287,-282,-266,-247,-287},{-271,-293,-277,-274,-269,-269},{-250,-263,-282,-250,-253,-263}},{{-247,-239,-258,-255,-239,-271},{-271,-293,-282,-239,-263,-258},{-293,-239,-258,-242,-271,-290},{-287,-293,-282,-279,-245,-290},{-250,-242,-261,-285,-282,-269},{-263,-261,-274,-245,-271,-255},{-263,-239,-282,-255,-277,-261},{-253,-274,-255,-258,-271,-239},{-271,-261,-290,-285,-269,-245},{-274,-250,-247,-247,-279,-261}},{{-287,-269,-290,-266,-285,-245},{-245,-293,-239,-242,-266,-261},{-255,-258,-285,-271,-239,-239},{-266,-279,-250,-250,-282,-255},{-250,-239,-293,-274,-263,-263},{-274,-247,-253,-242,-282,-266},{-239,-282,-266,-245,-287,-261},{-255,-287,-290,-282,-263,-250},{-271,-253,-293,-253,-266,-255},{-261,-287,-242,-253,-274,-258}}},{{{-300,-260,-272,-252,-263,-280},{-255,-274,-294,-283,-274,-258},{-252,-291,-260,-266,-294,-277},{-252,-255,-300,-288,-269,-286},{-297,-308,-286,-283,-302,-288},{-258,-274,-269,-297,-283,-288},{-300,-302,-269,-260,-266,-252},{-291,-263,-308,-308,-277,-286},{-272,-300,-277,-258,-294,-294},{-305,-258,-302,-288,-305,-283}},{{-294,-308,-297,-277,-291,-274},{-277,-258,-302,-308,-300,-291},{-294,-302,-252,-283,-263,-266},{-305,-272,-272,-305,-269,-294},{-255,-263,-255,-297,-272,-297},{-283,-305,-263,-274,-260,-252},{-297,-258,-283,-286,-274,-269},{-272,-291,-266,-305,-277,-260},{-308,-274,-288,-297,-308,-269},{-266,-277,-263,-297,-300,-283}},{{-291,-297,-288,-252,-258,-294},{-288,-258,-252,-255,-288,-294},{-252,-252,-252,-263,-291,-302},{-260,-302,-258,-255,-300,-280},{-255,-302,-266,-269,-286,-305},{-300,-286,-300,-269,-302,-300},{-274,-308,-294,-291,-294,-266},{-260,-305,-286,-286,-252,-283},{-263,-272,-288,-302,-294,-274},{-258,-255,-291,-272,-286,-308}}},{{{-300,-260,-294,-266,-291,-308},{-288,-286,-283,-302,-277,-252},{-272,-258,-252,-294,-300,-288},{-260,-305,-277,-260,-269,-294},{-308,-294,-286,-288,-266,-297},{-260,-286,-280,-274,-260,-272},{-308,-272,-291,-286,-277,-272},{-266,-291,-272,-288,-252,-269},{-274,-294,-255,-288,-302,-286},{-252,-283,-260,-286,-302,-308}},{{-283,-255,-263,-260,-255,-255},{-291,-283,-305,-269,-269,-305},{-283,-288,-308,-266,-252,-288},{-300,-300,-255,-269,-300,-266},{-288,-280,-277,-283,-288,-272},{-280,-302,-269,-269,-286,-297},{-277,-283,-302,-297,-308,-255},{-252,-291,-308,-305,-269,-297},{-294,-277,-288,-288,-255,-291},{-294,-286,-272,-277,-297,-297}},{{-302,-272,-255,-305,-297,-255},{-280,-291,-269,-274,-286,-258},{-291,-274,-280,-272,-252,-269},{-283,-255,-272,-260,-300,-255},{-300,-266,-280,-286,-266,-302},{-294,-272,-258,-260,-288,-277},{-263,-258,-277,-255,-266,-280},{-291,-280,-297,-277,-266,-269},{-260,-283,-288,-269,-305,-258},{-252,-269,-305,-302,-294,-302}}},{{{-291,-266,-277,-263,-258,-260},{-280,-308,-302,-274,-302,-283},{-260,-291,-255,-280,-305,-277},{-297,-288,-269,-263,-286,-277},{-272,-283,-260,-277,-272,-260},{-291,-305,-288,-291,-291,-272},{-272,-255,-302,-280,-283,-302},{-277,-274,-305,-283,-258,-283},{-300,-305,-283,-302,-286,-252},{-269,-255,-283,-252,-297,-291}},{{-260,-294,-283,-283,-286,-305},{-291,-286,-302,-252,-302,-294},{-297,-263,-308,-266,-255,-286},{-274,-297,-260,-305,-300,-269},{-294,-305,-263,-272,-283,-263},{-274,-263,-297,-297,-266,-280},{-274,-305,-266,-291,-302,-252},{-294,-274,-288,-260,-283,-297},{-305,-266,-280,-274,-308,-302},{-305,-266,-286,-300,-263,-302}},{{-288,-266,-294,-283,-294,-308},{-300,-274,-258,-255,-274,-260},{-263,-283,-297,-263,-280,-277},{-308,-291,-263,-272,-260,-280},{-260,-308,-263,-280,-255,-286},{-263,-302,-258,-252,-280,-258},{-263,-308,-294,-277,-308,-308},{-286,-308,-291,-263,-255,-297},{-302,-255,-286,-286,-263,-288},{-294,-300,-263,-308,-260,-297}}}}; // supply (positive for supply and negative for demand) under different scenarios 
int iniv[I]={2070,261,23,150,170,304,400,300,160}; // initial inventory 
int ubiv[I]={2740,522,414,300,341,608,800,600,320}; // the upper bounds of inventory 
int len[I1][I2]={{3,6,2,2,3,3,2,1}}; // the traveling time between two sites 
// cost parameters: 
double c1[I]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; // inventory holding cost 
double c2[I]={0.05,7.19,13.32,4.32,2.64,5.16,6.85,4.63,1.82}; // cost of leftover and unmet 
double c3[BN]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; // transportation cost for capacity contracts 
double c4[I1][I2]={{6.54,12.11,3.93,2.4,4.69,6.23,4.21,1.65}}; // cost of spot market 
// bid parameters: 
int RLBN[I1][I2]={{9,9,9,9,9,9,9,9}}; // number of bids on each arc 
int LBset[I1][I2][LBN]={{{0,1,2,3,4,5,6,7,8},{9,10,11,12,13,14,15,16,17},{18,19,20,21,22,23,24,25,26},{27,28,29,30,31,32,33,34,35},{36,37,38,39,40,41,42,43,44},{45,46,47,48,49,50,51,52,53},{54,55,56,57,58,59,60,61,62},{63,64,65,66,67,68,69,70,71}}}; // set of bids on each arc 
double frt[BN]={5.23,5.23,5.23,4.58,4.58,4.58,3.92,3.92,3.92,9.69,9.69,9.69,8.48,8.48,8.48,7.27,7.27,7.27,3.14,3.14,3.14,2.75,2.75,2.75,2.36,2.36,2.36,1.92,1.92,1.92,1.68,1.68,1.68,1.44,1.44,1.44,3.75,3.75,3.75,3.28,3.28,3.28,2.81,2.81,2.81,4.98,4.98,4.98,4.36,4.36,4.36,3.74,3.74,3.74,3.37,3.37,3.37,2.95,2.95,2.95,2.53,2.53,2.53,1.32,1.32,1.32,1.16,1.16,1.16,0.99,0.99,0.99}; // freight rate of each bid 
int lbcap[BN]={75,75,75,1,151,151,151,226,226,75,75,75,301,151,151,151,226,226,75,75,75,301,151,151,151,226,226,75,75,75,301,151,151,151,226,226,75,75,75,301,151,151,151,226,226,75,75,75,301,151,151,151,226,226,75,75,75,301,151,151,151,226,226,75,75,75,301,151,151,151,226,226}; // capacity lower bound of each bid 
int ubcap[BN]={150,150,150,225,225,225,300,300,300,150,150,150,225,225,225,300,300,300,150,150,150,225,225,225,300,300,300,150,150,150,225,225,225,300,300,300,150,150,150,225,225,225,300,300,300,150,150,150,225,225,225,300,300,300,150,150,150,225,225,225,300,300,300,150,150,150,225,225,225,300,300,300}; // capacity upper bound of each bid 
// shipment parameters: 
int SHN[BN]={8,4,3,7,4,3,8,4,3,6,3,2,5,3,2,6,3,2,7,4,3,7,4,3,8,4,3,7,4,3,7,4,3,8,4,3,8,4,3,7,4,3,8,4,3,8,4,3,7,4,3,7,4,3,7,4,3,7,4,3,8,4,3,9,4,3,9,4,3,8,4,3}; // number of shipment for each bid 
int SHset[BN][MBSN]={{0,1,2,3,4,5,6,7},{8,9,10,11},{12,13,14},{15,16,17,18,19,20,21},{22,23,24,25},{26,27,28},{29,30,31,32,33,34,35,36},{37,38,39,40},{41,42,43},{44,45,46,47,48,49},{50,51,52},{53,54},{55,56,57,58,59},{60,61,62},{63,64},{65,66,67,68,69,70},{71,72,73},{74,75},{76,77,78,79,80,81,82},{83,84,85,86},{87,88,89},{90,91,92,93,94,95,96},{97,98,99,100},{101,102,103},{104,105,106,107,108,109,110,111},{112,113,114,115},{116,117,118},{119,120,121,122,123,124,125},{126,127,128,129},{130,131,132},{133,134,135,136,137,138,139},{140,141,142,143},{144,145,146},{147,148,149,150,151,152,153,154},{155,156,157,158},{159,160,161},{162,163,164,165,166,167,168,169},{170,171,172,173},{174,175,176},{177,178,179,180,181,182,183},{184,185,186,187},{188,189,190},{191,192,193,194,195,196,197,198},{199,200,201,202},{203,204,205},{206,207,208,209,210,211,212,213},{214,215,216,217},{218,219,220},{221,222,223,224,225,226,227},{228,229,230,231},{232,233,234},{235,236,237,238,239,240,241},{242,243,244,245},{246,247,248},{249,250,251,252,253,254,255},{256,257,258,259},{260,261,262},{263,264,265,266,267,268,269},{270,271,272,273},{274,275,276},{277,278,279,280,281,282,283,284},{285,286,287,288},{289,290,291},{292,293,294,295,296,297,298,299,300},{301,302,303,304},{305,306,307},{308,309,310,311,312,313,314,315,316},{317,318,319,320},{321,322,323},{324,325,326,327,328,329,330,331},{332,333,334,335},{336,337,338}}; // set of shipments in each bid 
int SHsts[SPN]={0,2,4,6,8,10,12,14,2,6,10,14,1,7,13,2,4,6,8,10,12,14,2,6,10,14,0,6,12,0,2,4,6,8,10,12,14,2,6,10,14,0,6,12,0,2,4,6,8,10,2,6,10,1,7,2,4,6,8,10,0,4,8,2,8,1,3,5,7,9,11,1,5,9,1,7,2,4,6,8,10,12,14,0,4,8,12,1,7,13,2,4,6,8,10,12,14,1,5,9,13,0,6,12,0,2,4,6,8,10,12,14,2,6,10,14,0,6,12,2,4,6,8,10,12,14,1,5,9,13,1,7,13,2,4,6,8,10,12,14,0,4,8,12,1,7,13,0,2,4,6,8,10,12,14,2,6,10,14,0,6,12,0,2,4,6,8,10,12,14,1,5,9,13,0,6,12,2,4,6,8,10,12,14,2,6,10,14,2,8,14,0,2,4,6,8,10,12,14,0,4,8,12,2,8,14,0,2,4,6,8,10,12,14,0,4,8,12,1,7,13,2,4,6,8,10,12,14,2,6,10,14,1,7,13,2,4,6,8,10,12,14,0,4,8,12,2,8,14,2,4,6,8,10,12,14,0,4,8,12,1,7,13,2,4,6,8,10,12,14,1,5,9,13,0,6,12,1,3,5,7,9,11,13,15,1,5,9,13,1,7,13,0,2,4,6,8,10,12,14,16,1,5,9,13,0,6,12,0,2,4,6,8,10,12,14,16,1,5,9,13,1,7,13,2,4,6,8,10,12,14,16,1,5,9,13,2,8,14}; // set of start times of each shipment 
int SHets[SPN]={3,5,7,9,11,13,15,17,5,9,13,17,4,10,16,5,7,9,11,13,15,17,5,9,13,17,3,9,15,3,5,7,9,11,13,15,17,5,9,13,17,3,9,15,6,8,10,12,14,16,8,12,16,7,13,8,10,12,14,16,6,10,14,8,14,7,9,11,13,15,17,7,11,15,7,13,4,6,8,10,12,14,16,2,6,10,14,3,9,15,4,6,8,10,12,14,16,3,7,11,15,2,8,14,2,4,6,8,10,12,14,16,4,8,12,16,2,8,14,4,6,8,10,12,14,16,3,7,11,15,3,9,15,4,6,8,10,12,14,16,2,6,10,14,3,9,15,2,4,6,8,10,12,14,16,4,8,12,16,2,8,14,3,5,7,9,11,13,15,17,4,8,12,16,3,9,15,5,7,9,11,13,15,17,5,9,13,17,5,11,17,3,5,7,9,11,13,15,17,3,7,11,15,5,11,17,3,5,7,9,11,13,15,17,3,7,11,15,4,10,16,5,7,9,11,13,15,17,5,9,13,17,4,10,16,5,7,9,11,13,15,17,3,7,11,15,5,11,17,4,6,8,10,12,14,16,2,6,10,14,3,9,15,4,6,8,10,12,14,16,3,7,11,15,2,8,14,3,5,7,9,11,13,15,17,3,7,11,15,3,9,15,1,3,5,7,9,11,13,15,17,2,6,10,14,1,7,13,1,3,5,7,9,11,13,15,17,2,6,10,14,2,8,14,3,5,7,9,11,13,15,17,2,6,10,14,3,9,15}; // set of end times of each shipment 
