/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Samuel Gagnon * * Copyright: * Samuel Gagnon, 2018 * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #include #ifdef GECODE_HAS_CBS #include namespace Gecode { namespace Int { namespace Distinct { /* * Program used to precompute both factors using GNU gmp and the c++ MPFR * interface. Compile with: g++ linear.cpp -lmpfr -lgmp * * #include * #include * #include * * int main() { * std::cout << "const double mincFactors[] = {" << std::endl; * for (unsigned int _r_i=1; _r_i<400; _r_i++) { * mpfr::mpreal r_i(_r_i, 256); * std::cout.precision(17); * std::cout << std::fixed << mpfr::exp(1/r_i * mpfr::log(mpfr::fac_ui(_r_i))) * << "," << std::endl; * } * std::cout << "};"; * return 0; * } */ const double mincFactors[] = { 1.00000000000000000, 1.41421356237309503, 1.81712059283213963, 2.21336383940064326, 2.60517108469735180, 2.99379516552390906, 3.38001515914129663, 3.76435059950312890, 4.14716627439691264, 4.52872868811676503, 4.90923877958439568, 5.28885199410244722, 5.66769117625176115, 6.04585517141850113, 6.42342474977976057, 6.80046679826764207, 7.17703735702477519, 7.55318386410680540, 7.92894684486515053, 8.30436120373934332, 8.67945722613286892, 9.05426136539794004, 9.42879686817524423, 9.80308427650907665, 10.17714183488018406, 10.55098582305415047, 10.92463083045900753, 11.29808998404420402, 11.67137513880885247, 12.04449703813164141, 12.41746544948987035, 12.79028927998164187, 13.16297667516615132, 13.53553510404150478, 13.90797143243727189, 14.28029198667325177, 14.65250260899859376, 15.02460870605700941, 15.39661529140837855, 15.76852702296325553, 16.14034823604591501, 16.51208297268635648, 16.88373500764762055, 17.25530787161673181, 17.62680487192353526, 17.99822911109791413, 18.36958350353131161, 18.74087079047107193, 19.11209355354424360, 19.48325422698127684, 19.85435510868717075, 20.22539837028827925, 20.59638606626692106, 20.96732014228171861, 21.33820244275927456, 21.70903471783284423, 22.07981862969444027, 22.45055575841889780, 22.82124760731200354, 23.19189560782874148, 23.56250112410235463, 23.93306545712105503, 24.30358984858447164, 24.67407548446931992, 25.04452349832989180, 25.41493497435707758, 25.78531095021668256, 26.15565241968596579, 26.52596033510539678, 26.89623560966105829, 27.26647911951150683, 27.63669170577170811, 28.00687417636541139, 28.37702730775638450, 28.74715184656783522, 29.11724851109866875, 29.48731799274432324, 29.85736095732936654, 30.22737804635839208, 30.59736987819097079, 30.96733704914646171, 31.33728013454339074, 31.70719968967806141, 32.07709625074676090, 32.44697033571526771, 32.81682244513918772, 33.18665306293876446, 33.55646265713073500, 33.92625168052037206, 34.29602057135609012, 34.66576975394924908, 35.03549963926110159, 35.40521062545914593, 35.77490309844468766, 36.14457743235348558, 36.51423399003088432, 36.88387312348332365, 37.25349517430730321, 37.62310047409740785, 37.99268934483428467, 38.36226209925419058, 38.73181904120067863, 39.10136046595984082, 39.47088666057973506, 39.84039790417516111, 40.20989446821820901, 40.57937661681586418, 40.94884460697482086, 41.31829868885470704, 41.68773910600994073, 42.05716609562099287, 42.42657988871569549, 42.79598071038087266, 43.16536877996494880, 43.53474431127211210, 43.90410751274811857, 44.27345858765850139, 44.64279773425932063, 45.01212514596099104, 45.38144101148543546, 45.75074551501685603, 46.12003883634655552, 46.48932115101187068, 46.85859263042992190, 47.22785344202578439, 47.59710374935594824, 47.96634371222699862, 48.33557348680966424, 48.70479322574863139, 49.07400307826826374, 49.44320319027426906, 49.81239370445177532, 50.18157476035956679, 50.55074649452119467, 50.91990904051245372, 51.28906252904602409, 51.65820708805285255, 52.02734284276085039, 52.39646991577064011, 52.76558842712884119, 53.13469849439861556, 53.50380023272806732, 53.87289375491583663, 54.24197917147515649, 54.61105659069504157, 54.98012611869983070, 55.34918785950675601, 55.71824191508138725, 56.08728838539141306, 56.45632736845873036, 56.82535896040967421, 57.19438325552368889, 57.56340034628049008, 57.93241032340582396, 58.30141327591547908, 58.67040929115821791, 59.03939845485717393, 59.40838085115024066, 59.77735656262869922, 60.14632567037530614, 60.51528825400072539, 60.88424439167913076, 61.25319416018254594, 61.62213763491437214, 61.99107488994177307, 62.36000599802717914, 62.72893103065869982, 63.09785005807991765, 63.46676314931864485, 63.83567037221495759, 64.20457179344815074, 64.57346747856338002, 64.94235749199715310, 65.31124189710230274, 65.68012075617224324, 66.04899413046437952, 66.41786208022320524, 66.78672466470250401, 67.15558194218686757, 67.52443397001290661, 67.89328080458979775, 68.26212250141910424, 68.63095911511423117, 68.99979069941927762, 69.36861730722760295, 69.73743899059944570, 70.10625580077968513, 70.47506778821458074, 70.84387500256837793, 71.21267749273960970, 71.58147530687642201, 71.95026849239226373, 72.31905709598060851, 72.68784116362947672, 73.05662074063560163, 73.42539587161839685, 73.79416660053330142, 74.16293297068486223, 74.53169502473967539, 74.90045280473881546, 75.26920635211012469, 75.63795570767994538, 76.00670091168483621, 76.37544200378294049, 76.74417902306495232, 77.11291200806499027, 77.48164099677103035, 77.85036602663534096, 78.21908713458445072, 78.58780435702901428, 78.95651772987328654, 79.32522728852462293, 79.69393306790251438, 80.06263510244762968, 80.43133342613051458, 80.80002807246005155, 81.16871907449189777, 81.53740646483668077, 81.90609027566776094, 82.27477053872929354, 82.64344728534365236, 83.01212054641892440, 83.38079035245636547, 83.74945673355718617, 84.11811971942994005, 84.48677933939692741, 84.85543562240120687, 85.22408859701299143, 85.59273829143593980, 85.96138473351363179, 86.33002795073548830, 86.69866797024287543, 87.06730481883484891, 87.43593852297413504, 87.80456910879249147, 88.17319660209628363, 88.54182102837195806, 88.91044241279134188, 89.27906078021652120, 89.64767615520540334, 90.01628856201625873, 90.38489802461258973, 90.75350456666830848, 91.12210821157192641, 91.49070898243125469, 91.85930690207815631, 92.22790199307263007, 92.59649427770711554, 92.96508377801105311, 93.33367051575445529, 93.70225451245255168, 94.07083578936932036, 94.43941436752178890, 94.80799026768333373, 95.17656351038802180, 95.54513411593379066, 95.91370210438633274, 96.28226749558257550, 96.65083030913417272, 97.01939056443073951, 97.38794828064340887, 97.75650347672818056, 98.12505617142869991, 98.49360638328005161, 98.86215413061107849, 99.23069943154833111, 99.59924230401813377, 99.96778276575037567, 100.33632083428067676, 100.70485652695351310, 101.07338986092532084, 101.44192085316634121, 101.81044952046437632, 102.17897587942649904, 102.54749994648213594, 102.91602173788551236, 103.28454126971807521, 103.65305855789091307, 104.02157361814736058, 104.39008646606486982, 104.75859711705802663, 105.12710558638034934, 105.49561188912648940, 105.86411604023467143, 106.23261805448878405, 106.60111794652054883, 106.96961573081142924, 107.33811142169478783, 107.70660503335786548, 108.07509657984400255, 108.44358607505416399, 108.81207353274911710, 109.18055896655140555, 109.54904238994693985, 109.91752381628703962, 110.28600325879006691, 110.65448073054322885, 111.02295624450436380, 111.39142981350369346, 111.75990145024535234, 112.12837116730909812, 112.49683897715184213, 112.86530489210957024, 113.23376892439852899, 113.60223108611683728, 113.97069138924632800, 114.33914984565349095, 114.70760646709160547, 115.07606126520157731, 115.44451425151365050, 115.81296543744886156, 116.18141483432037246, 116.54986245333464847, 116.91830830559295409, 117.28675240209287705, 117.65519475372908194, 118.02363537129503351, 118.39207426548429654, 118.76051144689120369, 119.12894692601288268, 119.49738071324972350, 119.86581281890703731, 120.23424325319591735, 120.60267202623469729, 120.97109914804969330, 121.33952462857653903, 121.70794847766147518, 122.07637070506195502, 122.44479132044804202, 122.81321033340336693, 123.18162775342610364, 123.55004358993016856, 123.91845785224600143, 124.28687054962146948, 124.65528169122335162, 125.02369128613757413, 125.39209934337076876, 125.76050587185090044, 126.12891088042809589, 126.49731437787578844, 126.86571637289161696, 127.23411687409785482, 127.60251589004292074, 127.97091342920171602, 128.33930949997667740, 128.70770411069855804, 129.07609726962747125, 129.44448898495312414, 129.81287926479629734, 130.18126811720897449, 130.54965555017568437, 130.91804157161396583, 131.28642618937507986, 131.65480941124473874, 132.02319124494412988, 132.39157169813032723, 132.75995077839695881, 133.12832849327515278, 133.49670485023419223, 133.86507985668198497, 134.23345351996579252, 134.60182584737315454, 134.97019684613209956, 135.33856652341218398, 135.70693488632494215, 136.07530194192452795, 136.44366769720831376, 136.81203215911755015, 137.18039533453793605, 137.54875723030011775, 137.91711785318055747, 138.28547720990177492, 138.65383530713307836, 139.02219215149121049, 139.39054774954067273, 139.75890210779442064, 140.12725523271443988, 140.49560713071221876, 140.86395780814921780, 141.23230727133760559, 141.60065552654034661, 141.96900257997217738, 142.33734843779979573, 142.70569310614262985, 143.07403659107284969, 143.44237889861649385, 143.81072003475327547, 144.17906000541770043, 144.54739881649889194, 144.91573647384150086, 145.28407298324610941, 145.65240835046939485, 146.02074258122482610, 146.38907568118306120, 146.75740765597231129, 147.12573851117868335, 147.49406825234693610, 147.86239688498047816, 148.23072441454197175, }; //#include //#include //#include //#include //#include // // //using namespace std; // // //int main() { // // int WIDTH = 400; // double liangBaiFactors[WIDTH][WIDTH]; // // for (int i = 1; i <= WIDTH; i++) { // double b = std::ceil(i/2.0); // for (int j=1; j <= WIDTH; j++) { // double a = std::ceil((j+1)/2.0); // double q = std::min(a,b); // liangBaiFactors[i-1][j-1] = q*(j-q+1); // } // } // // cout << "const double liangBaiFactors[] = {" << endl; // // for (int i=0; i