int Dev = 30;// 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 = 341;//Number of shipments
extern const int SN = 10;//Number of scenarios at each stage
extern const int MBSN = 8;//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]={{{{11394,0,0,0,0,0},{11587,0,0,0,0,0},{11744,0,0,0,0,0},{11466,0,0,0,0,0},{11386,0,0,0,0,0},{11482,0,0,0,0,0},{10848,0,0,0,0,0},{11272,0,0,0,0,0},{11194,0,0,0,0,0},{11420,0,0,0,0,0}},{{11144,0,0,0,0,0},{11213,0,0,0,0,0},{11519,0,0,0,0,0},{11355,0,0,0,0,0},{11540,0,0,0,0,0},{11908,0,0,0,0,0},{11515,0,0,0,0,0},{11591,0,0,0,0,0},{11522,0,0,0,0,0},{11668,0,0,0,0,0}},{{11398,0,0,0,0,0},{11371,0,0,0,0,0},{11319,0,0,0,0,0},{11506,0,0,0,0,0},{11346,0,0,0,0,0},{11544,0,0,0,0,0},{11450,0,0,0,0,0},{11306,0,0,0,0,0},{11394,0,0,0,0,0},{11515,0,0,0,0,0}}},{{{-201,-211,-248,-248,-160,-248},{-242,-211,-238,-209,-185,-258},{-160,-173,-152,-177,-260,-229},{-175,-158,-193,-187,-246,-225},{-203,-213,-252,-195,-189,-191},{-244,-179,-197,-164,-179,-217},{-166,-156,-229,-227,-142,-203},{-233,-248,-207,-264,-217,-221},{-185,-240,-246,-144,-171,-219},{-231,-160,-168,-181,-219,-250}},{{-193,-160,-215,-173,-219,-183},{-162,-195,-242,-254,-246,-258},{-150,-177,-235,-227,-154,-209},{-235,-150,-238,-209,-181,-223},{-156,-168,-264,-193,-152,-162},{-231,-148,-254,-144,-207,-229},{-181,-252,-156,-179,-262,-229},{-191,-258,-156,-231,-238,-229},{-231,-142,-177,-203,-189,-179},{-223,-209,-162,-181,-183,-171}},{{-246,-264,-158,-250,-156,-197},{-156,-256,-213,-213,-187,-244},{-227,-264,-229,-207,-235,-175},{-199,-244,-233,-248,-177,-189},{-209,-160,-244,-223,-215,-221},{-209,-256,-209,-258,-254,-248},{-211,-168,-154,-173,-197,-231},{-160,-205,-246,-256,-213,-185},{-171,-179,-144,-144,-262,-242},{-231,-175,-235,-209,-213,-189}}},{{{-148,-116,-143,-132,-172,-140},{-169,-124,-198,-113,-169,-148},{-188,-184,-142,-114,-135,-127},{-167,-180,-175,-209,-185,-182},{-130,-171,-201,-163,-208,-184},{-148,-143,-155,-142,-163,-206},{-159,-209,-159,-147,-138,-171},{-166,-156,-209,-116,-114,-150},{-164,-164,-206,-196,-172,-203},{-114,-171,-142,-159,-147,-145}},{{-172,-114,-121,-140,-147,-196},{-126,-175,-151,-195,-113,-185},{-161,-140,-167,-167,-127,-127},{-158,-179,-132,-153,-163,-116},{-161,-192,-148,-151,-137,-193},{-138,-163,-172,-132,-132,-193},{-135,-209,-206,-138,-200,-166},{-126,-196,-135,-118,-143,-155},{-190,-119,-164,-206,-188,-161},{-193,-208,-204,-129,-200,-190}},{{-150,-124,-204,-174,-188,-209},{-166,-190,-158,-129,-156,-148},{-150,-163,-119,-119,-195,-177},{-145,-208,-175,-192,-182,-114},{-203,-175,-150,-155,-180,-192},{-118,-159,-172,-129,-121,-150},{-127,-171,-137,-150,-129,-158},{-185,-127,-122,-156,-145,-174},{-119,-113,-145,-169,-151,-198},{-158,-129,-153,-182,-153,-164}}},{{{-213,-222,-231,-238,-252,-206},{-261,-254,-282,-243,-298,-182},{-215,-240,-196,-176,-247,-259},{-201,-171,-289,-270,-286,-286},{-166,-180,-222,-199,-280,-192},{-245,-224,-210,-263,-289,-291},{-187,-173,-210,-185,-291,-259},{-270,-293,-173,-256,-224,-280},{-192,-277,-189,-199,-169,-229},{-199,-226,-277,-229,-199,-247}},{{-178,-238,-273,-245,-162,-178},{-208,-268,-217,-203,-219,-296},{-289,-282,-224,-284,-300,-182},{-182,-243,-194,-192,-189,-182},{-233,-162,-196,-270,-282,-245},{-256,-233,-206,-217,-270,-300},{-217,-213,-192,-277,-270,-215},{-233,-180,-164,-217,-171,-296},{-189,-252,-182,-252,-291,-203},{-189,-226,-256,-243,-173,-282}},{{-275,-180,-298,-286,-282,-194},{-273,-293,-201,-171,-254,-194},{-208,-243,-217,-249,-192,-196},{-210,-233,-277,-300,-203,-176},{-206,-217,-203,-182,-238,-280},{-263,-194,-273,-254,-254,-162},{-275,-215,-273,-291,-180,-210},{-219,-162,-266,-213,-275,-196},{-231,-182,-178,-247,-226,-252},{-199,-249,-217,-192,-180,-208}}},{{{-247,-278,-171,-245,-171,-208},{-278,-191,-197,-241,-217,-154},{-204,-204,-158,-224,-191,-280},{-197,-282,-263,-219,-193,-152},{-178,-208,-282,-191,-226,-191},{-210,-226,-254,-241,-169,-256},{-243,-252,-206,-195,-152,-250},{-171,-197,-208,-258,-154,-232},{-237,-247,-193,-230,-224,-221},{-245,-178,-280,-184,-178,-200}},{{-154,-210,-202,-182,-217,-219},{-245,-180,-252,-247,-232,-152},{-158,-202,-260,-254,-234,-252},{-208,-265,-247,-213,-204,-219},{-245,-169,-254,-156,-265,-247},{-226,-165,-191,-265,-213,-276},{-210,-247,-224,-165,-219,-243},{-200,-210,-252,-282,-273,-269},{-187,-180,-202,-247,-230,-260},{-178,-267,-241,-191,-252,-215}},{{-171,-180,-163,-161,-193,-226},{-165,-189,-217,-180,-206,-258},{-282,-263,-187,-158,-230,-187},{-206,-237,-156,-271,-163,-171},{-158,-256,-182,-163,-187,-167},{-195,-219,-195,-245,-241,-263},{-189,-241,-243,-265,-252,-282},{-215,-230,-241,-167,-282,-271},{-197,-206,-245,-195,-219,-226},{-250,-158,-184,-280,-245,-234}}},{{{-213,-298,-271,-282,-261,-322},{-258,-263,-290,-253,-279,-338},{-330,-258,-293,-277,-298,-303},{-309,-285,-340,-194,-215,-293},{-239,-309,-293,-322,-282,-237},{-229,-234,-279,-250,-327,-229},{-250,-250,-237,-269,-255,-317},{-282,-221,-207,-205,-221,-194},{-197,-277,-215,-317,-301,-261},{-282,-229,-322,-231,-290,-192}},{{-210,-258,-338,-215,-332,-258},{-237,-327,-277,-221,-186,-311},{-229,-285,-301,-197,-277,-247},{-295,-290,-266,-295,-250,-279},{-330,-274,-237,-210,-279,-330},{-340,-253,-274,-250,-330,-258},{-319,-213,-234,-343,-322,-194},{-200,-309,-234,-322,-285,-213},{-295,-332,-335,-319,-213,-231},{-309,-221,-207,-253,-253,-338}},{{-189,-271,-327,-266,-274,-231},{-186,-205,-319,-213,-242,-311},{-194,-226,-338,-226,-332,-282},{-247,-314,-229,-269,-282,-189},{-234,-325,-279,-285,-325,-221},{-229,-330,-239,-332,-231,-186},{-327,-263,-192,-306,-261,-279},{-221,-207,-250,-287,-332,-319},{-229,-263,-325,-253,-192,-290},{-317,-317,-330,-338,-261,-194}}},{{{-272,-202,-325,-316,-314,-300},{-322,-333,-202,-213,-196,-325},{-224,-356,-325,-252,-356,-227},{-218,-210,-358,-241,-302,-308},{-302,-230,-328,-308,-305,-260},{-277,-311,-263,-353,-221,-353},{-199,-202,-235,-333,-347,-364},{-358,-199,-347,-232,-325,-300},{-246,-230,-241,-232,-260,-210},{-356,-291,-277,-202,-283,-241}},{{-294,-210,-308,-235,-314,-353},{-300,-280,-199,-204,-297,-258},{-297,-308,-342,-218,-364,-344},{-277,-232,-300,-246,-280,-364},{-288,-224,-300,-336,-272,-218},{-196,-230,-288,-227,-246,-286},{-269,-202,-218,-218,-216,-291},{-297,-336,-263,-330,-196,-328},{-232,-294,-269,-258,-196,-325},{-263,-280,-263,-316,-269,-350}},{{-221,-227,-244,-218,-347,-302},{-235,-249,-252,-358,-277,-336},{-266,-328,-277,-196,-202,-224},{-358,-344,-218,-221,-272,-246},{-216,-218,-314,-336,-356,-224},{-280,-291,-255,-342,-232,-218},{-263,-218,-258,-238,-333,-328},{-252,-227,-246,-330,-227,-241},{-319,-330,-305,-347,-224,-204},{-210,-297,-224,-244,-196,-328}}},{{{-358,-210,-330,-325,-216,-199},{-232,-213,-319,-269,-216,-207},{-218,-316,-274,-308,-302,-305},{-204,-199,-230,-274,-216,-286},{-255,-291,-277,-280,-216,-238},{-266,-260,-291,-319,-272,-277},{-227,-224,-305,-252,-263,-238},{-224,-266,-316,-260,-328,-235},{-202,-280,-260,-272,-347,-235},{-196,-202,-235,-356,-305,-272}},{{-221,-218,-302,-283,-305,-252},{-218,-255,-339,-196,-300,-258},{-347,-218,-221,-235,-238,-227},{-218,-364,-350,-305,-322,-196},{-358,-347,-339,-330,-230,-221},{-258,-311,-277,-344,-350,-350},{-316,-342,-322,-238,-216,-288},{-277,-255,-258,-255,-213,-302},{-196,-347,-230,-288,-361,-342},{-311,-330,-244,-356,-263,-361}},{{-314,-204,-288,-358,-364,-350},{-297,-322,-288,-221,-277,-325},{-232,-347,-221,-196,-277,-361},{-207,-230,-322,-283,-353,-350},{-325,-258,-305,-252,-344,-221},{-336,-210,-314,-246,-294,-339},{-344,-274,-238,-269,-199,-260},{-364,-263,-291,-280,-227,-204},{-244,-210,-344,-333,-344,-252},{-347,-244,-350,-260,-196,-311}}},{{{-196,-330,-218,-342,-238,-207},{-361,-249,-227,-305,-325,-330},{-344,-311,-294,-255,-336,-347},{-260,-302,-308,-255,-252,-316},{-258,-207,-249,-286,-308,-291},{-224,-227,-227,-274,-199,-305},{-210,-286,-235,-221,-213,-207},{-224,-210,-249,-266,-230,-356},{-286,-274,-244,-325,-263,-302},{-316,-336,-263,-297,-364,-353}},{{-291,-266,-322,-305,-336,-227},{-235,-277,-210,-230,-216,-361},{-216,-232,-316,-196,-358,-344},{-286,-204,-258,-277,-316,-210},{-263,-260,-244,-361,-216,-272},{-330,-269,-300,-336,-314,-330},{-330,-350,-274,-218,-336,-241},{-263,-241,-342,-364,-274,-311},{-238,-249,-353,-314,-249,-232},{-305,-241,-196,-207,-336,-230}},{{-218,-305,-235,-288,-210,-218},{-328,-330,-241,-207,-199,-336},{-269,-252,-235,-325,-308,-333},{-274,-322,-311,-291,-252,-213},{-266,-344,-204,-199,-260,-269},{-230,-344,-260,-328,-230,-207},{-230,-302,-342,-221,-342,-241},{-241,-266,-238,-238,-356,-288},{-342,-328,-213,-288,-353,-221},{-263,-328,-330,-266,-230,-347}}}}; // 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]={7,4,3,8,4,3,7,4,3,6,3,2,6,3,2,6,3,2,7,4,3,8,4,3,8,4,3,7,4,3,8,4,3,8,4,3,8,4,3,7,4,3,7,4,3,7,4,3,8,4,3,7,4,3,8,4,3,8,4,3,8,4,3,8,4,3,8,5,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,339,340}}; // set of shipments in each bid 
int SHsts[SPN]={1,3,5,7,9,11,13,1,5,9,13,1,7,13,0,2,4,6,8,10,12,14,0,4,8,12,1,7,13,1,3,5,7,9,11,13,2,6,10,14,2,8,14,0,2,4,6,8,10,2,6,10,0,6,1,3,5,7,9,11,0,4,8,0,6,0,2,4,6,8,10,0,4,8,2,8,2,4,6,8,10,12,14,1,5,9,13,2,8,14,1,3,5,7,9,11,13,15,2,6,10,14,2,8,14,1,3,5,7,9,11,13,15,2,6,10,14,1,7,13,2,4,6,8,10,12,14,1,5,9,13,1,7,13,0,2,4,6,8,10,12,14,0,4,8,12,2,8,14,0,2,4,6,8,10,12,14,2,6,10,14,1,7,13,0,2,4,6,8,10,12,14,1,5,9,13,2,8,14,1,3,5,7,9,11,13,1,5,9,13,1,7,13,1,3,5,7,9,11,13,0,4,8,12,2,8,14,2,4,6,8,10,12,14,1,5,9,13,1,7,13,0,2,4,6,8,10,12,14,2,6,10,14,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,1,3,5,7,9,11,13,15,1,5,9,13,2,8,14,0,2,4,6,8,10,12,14,1,5,9,13,1,7,13,2,4,6,8,10,12,14,16,2,6,10,14,2,8,14,1,3,5,7,9,11,13,15,0,4,8,12,16,2,8,14,2,4,6,8,10,12,14,16,2,6,10,14,0,6,12}; // set of start times of each shipment 
int SHets[SPN]={4,6,8,10,12,14,16,4,8,12,16,4,10,16,3,5,7,9,11,13,15,17,3,7,11,15,4,10,16,4,6,8,10,12,14,16,5,9,13,17,5,11,17,6,8,10,12,14,16,8,12,16,6,12,7,9,11,13,15,17,6,10,14,6,12,6,8,10,12,14,16,6,10,14,8,14,4,6,8,10,12,14,16,3,7,11,15,4,10,16,3,5,7,9,11,13,15,17,4,8,12,16,4,10,16,3,5,7,9,11,13,15,17,4,8,12,16,3,9,15,4,6,8,10,12,14,16,3,7,11,15,3,9,15,2,4,6,8,10,12,14,16,2,6,10,14,4,10,16,2,4,6,8,10,12,14,16,4,8,12,16,3,9,15,3,5,7,9,11,13,15,17,4,8,12,16,5,11,17,4,6,8,10,12,14,16,4,8,12,16,4,10,16,4,6,8,10,12,14,16,3,7,11,15,5,11,17,5,7,9,11,13,15,17,4,8,12,16,4,10,16,3,5,7,9,11,13,15,17,5,9,13,17,4,10,16,5,7,9,11,13,15,17,4,8,12,16,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,3,7,11,15,4,10,16,2,4,6,8,10,12,14,16,3,7,11,15,3,9,15,3,5,7,9,11,13,15,17,3,7,11,15,3,9,15,2,4,6,8,10,12,14,16,1,5,9,13,17,3,9,15,3,5,7,9,11,13,15,17,3,7,11,15,1,7,13}; // set of end times of each shipment 
