int Dev = 20;// 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 = 343;//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]={{{{11695,0,0,0,0,0},{11498,0,0,0,0,0},{11572,0,0,0,0,0},{11335,0,0,0,0,0},{11574,0,0,0,0,0},{11845,0,0,0,0,0},{11154,0,0,0,0,0},{11341,0,0,0,0,0},{11500,0,0,0,0,0},{11729,0,0,0,0,0}},{{11371,0,0,0,0,0},{11389,0,0,0,0,0},{11555,0,0,0,0,0},{11769,0,0,0,0,0},{11757,0,0,0,0,0},{11231,0,0,0,0,0},{11569,0,0,0,0,0},{11730,0,0,0,0,0},{11791,0,0,0,0,0},{11516,0,0,0,0,0}},{{11796,0,0,0,0,0},{11555,0,0,0,0,0},{11222,0,0,0,0,0},{11396,0,0,0,0,0},{11620,0,0,0,0,0},{11320,0,0,0,0,0},{11953,0,0,0,0,0},{11717,0,0,0,0,0},{11768,0,0,0,0,0},{11232,0,0,0,0,0}}},{{{-233,-162,-217,-227,-240,-179},{-221,-199,-227,-199,-195,-229},{-205,-183,-215,-179,-183,-223},{-217,-217,-231,-244,-244,-197},{-229,-215,-205,-209,-185,-197},{-166,-199,-205,-235,-213,-238},{-238,-195,-227,-189,-166,-197},{-244,-183,-185,-175,-244,-240},{-238,-215,-171,-164,-175,-207},{-207,-191,-225,-207,-209,-235}},{{-235,-244,-173,-181,-242,-221},{-238,-166,-209,-205,-183,-209},{-166,-219,-229,-207,-217,-219},{-227,-235,-233,-235,-233,-195},{-183,-177,-171,-229,-233,-195},{-171,-162,-201,-168,-207,-177},{-179,-217,-221,-221,-189,-235},{-227,-168,-229,-197,-181,-235},{-242,-189,-215,-235,-227,-213},{-203,-179,-175,-181,-227,-171}},{{-195,-229,-209,-197,-191,-205},{-175,-171,-215,-209,-215,-235},{-201,-171,-181,-179,-166,-181},{-162,-201,-168,-203,-181,-215},{-217,-227,-235,-233,-199,-233},{-209,-183,-227,-242,-219,-185},{-225,-219,-227,-189,-166,-183},{-219,-187,-217,-242,-235,-191},{-244,-179,-195,-238,-179,-164},{-219,-197,-181,-183,-197,-187}}},{{{-185,-137,-140,-172,-171,-156},{-161,-156,-148,-137,-134,-193},{-147,-166,-193,-150,-163,-150},{-148,-150,-163,-135,-138,-134},{-151,-143,-135,-167,-159,-169},{-172,-150,-179,-142,-145,-177},{-193,-129,-177,-147,-172,-169},{-155,-182,-138,-132,-175,-190},{-132,-138,-192,-182,-150,-140},{-150,-182,-167,-180,-134,-129}},{{-174,-175,-137,-130,-185,-135},{-143,-171,-159,-150,-134,-138},{-150,-155,-185,-161,-169,-140},{-175,-151,-148,-132,-164,-187},{-143,-148,-169,-147,-134,-156},{-161,-171,-155,-163,-193,-143},{-182,-164,-151,-142,-175,-174},{-153,-151,-166,-166,-155,-169},{-155,-153,-185,-169,-163,-159},{-169,-163,-177,-192,-150,-185}},{{-185,-187,-184,-190,-163,-182},{-132,-174,-137,-140,-172,-135},{-148,-134,-142,-142,-140,-174},{-130,-159,-155,-155,-180,-182},{-163,-171,-153,-163,-158,-175},{-172,-129,-159,-137,-156,-130},{-135,-135,-167,-155,-190,-180},{-145,-190,-150,-190,-177,-167},{-193,-159,-190,-185,-187,-151},{-177,-161,-145,-138,-137,-155}}},{{{-217,-215,-213,-217,-208,-273},{-208,-222,-199,-226,-233,-213},{-247,-219,-203,-243,-266,-249},{-247,-201,-236,-256,-249,-247},{-201,-270,-249,-185,-224,-224},{-210,-236,-222,-240,-229,-275},{-270,-275,-203,-192,-222,-256},{-247,-199,-275,-243,-213,-189},{-199,-238,-263,-213,-226,-187},{-273,-206,-196,-247,-187,-252}},{{-213,-240,-266,-185,-219,-185},{-185,-240,-245,-201,-219,-277},{-231,-266,-199,-261,-268,-189},{-247,-231,-206,-252,-254,-266},{-263,-229,-256,-266,-203,-266},{-206,-219,-236,-219,-187,-208},{-189,-217,-259,-249,-201,-277},{-240,-266,-261,-275,-219,-245},{-249,-240,-189,-249,-259,-199},{-224,-238,-256,-189,-192,-187}},{{-236,-240,-252,-268,-208,-263},{-254,-254,-247,-277,-266,-270},{-229,-196,-210,-256,-240,-231},{-268,-194,-196,-210,-259,-210},{-219,-240,-201,-252,-261,-206},{-185,-203,-268,-192,-219,-189},{-224,-219,-256,-233,-275,-192},{-252,-210,-270,-192,-226,-256},{-263,-226,-236,-206,-245,-270},{-252,-210,-224,-256,-192,-266}}},{{{-217,-208,-232,-234,-178,-247},{-254,-228,-176,-219,-247,-176},{-174,-239,-245,-197,-189,-232},{-237,-174,-180,-193,-184,-174},{-204,-200,-260,-237,-210,-200},{-182,-182,-206,-189,-208,-204},{-239,-239,-174,-217,-184,-254},{-243,-180,-247,-178,-260,-197},{-258,-204,-195,-180,-178,-237},{-193,-195,-180,-224,-245,-230}},{{-252,-247,-258,-213,-206,-234},{-187,-256,-215,-182,-200,-228},{-228,-258,-254,-237,-193,-184},{-232,-193,-184,-254,-252,-247},{-187,-241,-243,-180,-182,-232},{-215,-210,-210,-191,-208,-213},{-184,-250,-234,-206,-239,-208},{-206,-224,-232,-193,-193,-180},{-226,-213,-217,-260,-247,-200},{-215,-180,-187,-193,-234,-239}},{{-250,-202,-247,-189,-250,-202},{-202,-247,-221,-215,-228,-219},{-252,-176,-204,-234,-250,-258},{-191,-250,-187,-210,-247,-250},{-232,-247,-204,-180,-260,-256},{-200,-184,-189,-237,-204,-187},{-180,-237,-174,-256,-237,-206},{-193,-206,-202,-210,-193,-206},{-217,-239,-184,-180,-189,-219},{-197,-197,-217,-206,-184,-178}}},{{{-247,-261,-269,-303,-314,-221},{-245,-263,-295,-298,-253,-263},{-226,-301,-311,-287,-298,-245},{-306,-295,-311,-213,-229,-221},{-223,-295,-311,-290,-303,-306},{-269,-298,-215,-293,-285,-314},{-279,-231,-250,-237,-215,-229},{-269,-298,-215,-229,-314,-261},{-237,-317,-215,-282,-263,-282},{-309,-221,-303,-309,-295,-271}},{{-223,-293,-247,-221,-269,-234},{-213,-242,-295,-314,-226,-311},{-218,-317,-295,-279,-226,-314},{-306,-237,-226,-287,-271,-234},{-298,-298,-266,-301,-311,-295},{-303,-290,-295,-245,-234,-293},{-277,-298,-303,-231,-245,-221},{-215,-295,-215,-274,-301,-266},{-277,-287,-311,-285,-282,-247},{-309,-255,-311,-213,-223,-253}},{{-287,-306,-231,-237,-231,-309},{-231,-250,-231,-239,-293,-274},{-258,-223,-237,-271,-213,-293},{-247,-303,-221,-282,-261,-237},{-266,-231,-303,-306,-242,-218},{-279,-269,-229,-221,-269,-261},{-282,-301,-247,-269,-285,-306},{-285,-287,-298,-239,-250,-317},{-319,-215,-301,-285,-293,-306},{-274,-242,-229,-258,-229,-317}}},{{{-333,-336,-241,-255,-330,-277},{-308,-260,-316,-319,-328,-274},{-230,-291,-269,-308,-325,-328},{-263,-311,-241,-277,-246,-316},{-300,-308,-269,-246,-272,-291},{-330,-232,-249,-325,-269,-305},{-227,-319,-260,-291,-302,-283},{-258,-260,-300,-249,-297,-286},{-319,-325,-249,-286,-249,-333},{-277,-286,-288,-316,-336,-305}},{{-266,-238,-260,-280,-291,-302},{-319,-300,-308,-235,-249,-277},{-322,-246,-291,-286,-297,-286},{-260,-302,-325,-291,-294,-288},{-238,-260,-291,-333,-328,-297},{-300,-319,-246,-288,-333,-302},{-260,-294,-274,-316,-311,-328},{-328,-330,-314,-311,-311,-260},{-238,-244,-328,-297,-336,-319},{-288,-308,-260,-330,-328,-322}},{{-302,-330,-308,-244,-252,-280},{-238,-330,-246,-260,-280,-280},{-246,-314,-235,-288,-330,-260},{-249,-269,-246,-269,-263,-336},{-297,-302,-249,-246,-255,-308},{-308,-241,-305,-258,-263,-322},{-316,-316,-333,-333,-235,-336},{-252,-260,-330,-316,-314,-328},{-246,-322,-249,-311,-283,-255},{-274,-291,-249,-238,-252,-274}}},{{{-288,-300,-328,-263,-302,-311},{-308,-241,-277,-238,-280,-325},{-274,-314,-325,-263,-288,-263},{-266,-238,-322,-294,-302,-328},{-274,-230,-333,-322,-314,-277},{-302,-269,-283,-277,-325,-328},{-241,-288,-235,-258,-274,-246},{-316,-232,-241,-294,-246,-266},{-291,-311,-330,-305,-316,-291},{-258,-291,-291,-308,-244,-260}},{{-330,-252,-269,-316,-227,-280},{-244,-288,-330,-266,-238,-266},{-230,-230,-311,-230,-252,-302},{-246,-224,-283,-302,-238,-252},{-260,-333,-291,-330,-246,-260},{-277,-288,-230,-235,-291,-280},{-232,-294,-274,-300,-227,-272},{-305,-277,-297,-286,-244,-274},{-227,-252,-316,-224,-291,-297},{-286,-224,-311,-244,-269,-255}},{{-294,-328,-227,-297,-246,-311},{-246,-314,-286,-286,-266,-297},{-336,-235,-241,-291,-302,-252},{-311,-314,-322,-294,-269,-302},{-305,-322,-260,-230,-272,-272},{-328,-319,-333,-297,-232,-266},{-238,-319,-336,-280,-255,-308},{-322,-269,-272,-260,-235,-227},{-286,-325,-274,-316,-325,-277},{-260,-302,-291,-314,-305,-255}}},{{{-283,-244,-252,-302,-269,-288},{-286,-238,-238,-319,-274,-252},{-325,-235,-249,-286,-230,-241},{-230,-244,-263,-277,-232,-314},{-311,-249,-232,-230,-235,-325},{-330,-314,-333,-286,-288,-322},{-241,-260,-266,-241,-238,-319},{-311,-300,-224,-241,-288,-232},{-246,-288,-314,-246,-249,-274},{-269,-288,-325,-230,-322,-283}},{{-305,-302,-277,-283,-224,-232},{-297,-311,-241,-252,-333,-294},{-224,-319,-305,-325,-235,-230},{-302,-238,-269,-314,-325,-322},{-272,-235,-291,-249,-325,-316},{-238,-280,-252,-311,-230,-277},{-297,-286,-232,-266,-291,-277},{-300,-288,-246,-235,-325,-302},{-249,-263,-274,-314,-244,-336},{-300,-336,-300,-280,-308,-297}},{{-246,-280,-336,-280,-286,-224},{-266,-316,-302,-260,-302,-252},{-241,-302,-260,-258,-330,-311},{-266,-258,-294,-325,-260,-235},{-244,-244,-235,-328,-272,-328},{-274,-330,-280,-316,-283,-232},{-294,-280,-330,-325,-300,-269},{-286,-325,-263,-232,-322,-302},{-314,-258,-238,-258,-288,-286},{-246,-325,-319,-269,-272,-291}}}}; // 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,8,4,3,8,4,3,6,3,2,6,3,2,6,3,2,7,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,7,4,3,7,4,3,7,4,3,8,4,3,8,4,3,8,4,3,9,4,3,8,5,3,9,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,341,342}}; // set of shipments in each bid 
int SHsts[SPN]={0,2,4,6,8,10,12,14,0,4,8,12,0,6,12,0,2,4,6,8,10,12,14,0,4,8,12,0,6,12,0,2,4,6,8,10,12,14,0,4,8,12,1,7,13,1,3,5,7,9,11,2,6,10,2,8,1,3,5,7,9,11,0,4,8,1,7,0,2,4,6,8,10,1,5,9,0,6,2,4,6,8,10,12,14,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,0,4,8,12,1,7,13,0,2,4,6,8,10,12,14,2,6,10,14,0,6,12,1,3,5,7,9,11,13,15,2,6,10,14,2,8,14,1,3,5,7,9,11,13,15,1,5,9,13,2,8,14,2,4,6,8,10,12,14,1,5,9,13,2,8,14,2,4,6,8,10,12,14,1,5,9,13,1,7,13,1,3,5,7,9,11,13,0,4,8,12,1,7,13,2,4,6,8,10,12,14,1,5,9,13,2,8,14,2,4,6,8,10,12,14,0,4,8,12,1,7,13,2,4,6,8,10,12,14,0,4,8,12,2,8,14,1,3,5,7,9,11,13,15,1,5,9,13,2,8,14,1,3,5,7,9,11,13,15,2,6,10,14,1,7,13,0,2,4,6,8,10,12,14,0,4,8,12,1,7,13,0,2,4,6,8,10,12,14,16,2,6,10,14,0,6,12,1,3,5,7,9,11,13,15,0,4,8,12,16,2,8,14,0,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]={3,5,7,9,11,13,15,17,3,7,11,15,3,9,15,3,5,7,9,11,13,15,17,3,7,11,15,3,9,15,3,5,7,9,11,13,15,17,3,7,11,15,4,10,16,7,9,11,13,15,17,8,12,16,8,14,7,9,11,13,15,17,6,10,14,7,13,6,8,10,12,14,16,7,11,15,6,12,4,6,8,10,12,14,16,3,7,11,15,4,10,16,2,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,4,10,16,3,5,7,9,11,13,15,17,3,7,11,15,4,10,16,5,7,9,11,13,15,17,4,8,12,16,5,11,17,5,7,9,11,13,15,17,4,8,12,16,4,10,16,4,6,8,10,12,14,16,3,7,11,15,4,10,16,5,7,9,11,13,15,17,4,8,12,16,5,11,17,5,7,9,11,13,15,17,3,7,11,15,4,10,16,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,3,5,7,9,11,13,15,17,4,8,12,16,3,9,15,2,4,6,8,10,12,14,16,2,6,10,14,3,9,15,1,3,5,7,9,11,13,15,17,3,7,11,15,1,7,13,2,4,6,8,10,12,14,16,1,5,9,13,17,3,9,15,1,3,5,7,9,11,13,15,17,3,7,11,15,1,7,13}; // set of end times of each shipment 
