?? jbmr.c
字號:
/*143:*/#line 3532 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 100if(verbose>=100){printf("Search for an improvement starting at city %d\n",dirty);fflush(stdout);#if defined(JBMR_WATCH_THIS_CITY)if(dirty==JBMR_WATCH_THIS_CITY){old_verbose= verbose;old_verbose_is_set= 1;verbose= 2000;}else if(old_verbose_is_set){verbose= old_verbose;old_verbose_is_set= 0;}#endif}#endif/*:143*/#line 1304 "./jbmr.w"t[1]= dirty;t1_n[0]= tour_prev(t[1]);t1_n[1]= tour_next(t[1]);t1_l[0]= cost(t1_n[0],t[1]);t1_l[1]= cost(t1_n[1],t[1]);#if JBMR_FARTHER_T1_FIRSTif(t1_l[0]<t1_l[1]){int tmp;length_t tmp_l;tmp= t1_n[0];t1_n[0]= t1_n[1];t1_n[1]= tmp;tmp_l= t1_l[0];t1_l[0]= t1_l[1];t1_l[1]= tmp_l;}#endif/*43:*/#line 1345 "./jbmr.w"#if !SPLIT_GAIN_VARcum_gain= 0;#elsecum_gain_pos= cum_gain_neg= 0;#endifbest_gain= 0;best_two_i= 0;best_exit_a= best_exit_b= -1;more_backtracking= 1;scheme_id= best_scheme_id= -1;/*:43*//*53:*/#line 1536 "./jbmr.w"#if !(LENGTH_TYPE_IS_EXACT)best_gain_with_slop= instance_epsilon;#endif/*:53*//*176:*/#line 3938 "./jbmr.w"#if TRACK_DEPTHSprobe_depth= move_depth= 0;#endif/*:176*/#line 1319 "./jbmr.w"put_city(1);for(t1_i= 0;t1_i<2&&more_backtracking;t1_i++){t[2]= t1_n[t1_i];/*185:*/#line 4019 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 70if(verbose>=70){printf("(t1,t2)= (%d,%d) cost=%f, d=%f p=%d\n",t[1],t[2],(double)cost(t[1],t[2]),#if JBMR_DECLUSTER_IN_ELIGIBILITY_TEST || JBMR_DECLUSTER_IN_GREEDY(double)decluster_d(t[1],t[2])#else(double)-1#endif,last_probe_depth);}#endif/*:185*/#line 1323 "./jbmr.w"#if !SPLIT_GAIN_VARcum_gain= t1_l[t1_i];#elsecum_gain_pos= t1_l[t1_i];cum_gain_neg= 0;#endifput_city(2);/*45:*/#line 1399 "./jbmr.w"two_i= 2;/*175:*/#line 3931 "./jbmr.w"#if TRACK_DEPTHSif(probe_depth<two_i+2)(probe_depth= two_i+2);#endif/*:175*/#line 1401 "./jbmr.w"#define BL 0{#if JBMR_DECLUSTER_IN_ELIGIBILITY_TESTconst length_t cluster_dist= decluster_d(t[1],t[2]);#elseconst length_t cluster_dist= 0;#endif/*56:*/#line 1633 "./jbmr.w"en[BL]= ec[BL]= 0;if(CAREFUL_OP(cum_gain,> ,cluster_dist+best_gain)){int i,t2ip1,t2ip2,enbl,*neighbour_list,nn_bound;#if SPLIT_GAIN_VARlength_t cum_1_pos,cum_1_neg,cum_2_pos,cum_2_neg;#elselength_t cum_1,cum_2;#endif/*156:*/#line 3678 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 400if(verbose>=400){/*167:*/#line 3866 "./jbmr.w"#if JBMR_MAX_VERBOSE{int i;for(i= 0;i<two_i;i++)printf(" ");}#endif/*:167*/#line 3681 "./jbmr.w"printf("%d %d "length_t_spec" "length_t_spec" s%d\n",t[two_i-1],t[two_i],#if !SPLIT_GAIN_VARlength_t_pcast(cum_gain),#elselength_t_pcast(cum_gain_pos-cum_gain_neg),#endiflength_t_pcast(best_gain),scheme_id);fflush(stdout);}#endif/*:156*/#line 1642 "./jbmr.w"#if SPLIT_GAIN_VARcum_1_pos= cum_gain_pos;#endifneighbour_list= nn_list(t[two_i],&nn_bound);for(i= 0,enbl= 0;i<nn_bound;i++){t2ip1= neighbour_list[i];#if SPLIT_GAIN_VARcum_1_neg= cum_gain_neg+cost(t[two_i],t2ip1);#elsecum_1= cum_gain-cost(t[two_i],t2ip1);#endifif(CAREFUL_OP(cum_1,<=,best_gain)){/*163:*/#line 3800 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 500if(verbose>=500){/*167:*/#line 3866 "./jbmr.w"#if JBMR_MAX_VERBOSE{int i;for(i= 0;i<two_i;i++)printf(" ");}#endif/*:167*/#line 3803 "./jbmr.w"#if !SPLIT_GAIN_VARprintf("Terminating |cum_1| "length_t_spec"\n",length_t_pcast(cum_1));#elseprintf("Terminating |cum_1| "length_t_spec" ""(== "length_t_spec" - "length_t_spec")\n",length_t_pcast(cum_1_pos-cum_1_neg),length_t_pcast(cum_1_pos),length_t_pcast(cum_1_neg));#endiffflush(stdout);}#endif/*:163*/#line 1659 "./jbmr.w"num_reject_by_cum_1++;break;}/*59:*/#line 1693 "./jbmr.w"#if BL==0/*60:*/#line 1725 "./jbmr.w"#if defined(JBMR_UNROLL_PREV_NEXT_LOOP)#error "JBMR_UNROLL_PREV_NEXT_LOOP is not implemented"#else{int which_neighbour;for(which_neighbour= 0;which_neighbour<2;which_neighbour++){t2ip2= (tour_neighbour[which_neighbour])(t2ip1);/*63:*/#line 1757 "./jbmr.w"#if BL==0if(t[2]!=t2ip2){/*64:*/#line 1773 "./jbmr.w"{#if JBMR_DECLUSTER_IN_ELIGIBILITY_TEST || JBMR_DECLUSTER_IN_GREEDYconst length_t cluster_dist= decluster_d(t[1],t2ip2);/*159:*/#line 3760 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 501 && (JBMR_DECLUSTER_IN_ELIGIBILITY_TEST||JBMR_DECLUSTER_IN_GREEDY)if(verbose>=501){/*167:*/#line 3866 "./jbmr.w"#if JBMR_MAX_VERBOSE{int i;for(i= 0;i<two_i;i++)printf(" ");}#endif/*:167*/#line 3763 "./jbmr.w"printf(" v---- next clust_dist==%f\n",(double)cluster_dist);}#endif/*:159*/#line 1777 "./jbmr.w"#endif#if !SPLIT_GAIN_VARcum_2= cum_1+cost(t2ip1,t2ip2);#else cum_2_pos= cum_1_pos+cost(t2ip1,t2ip2);cum_2_neg= cum_1_neg;#endif #if JBMR_DECLUSTER_IN_ELIGIBILITY_TESTif(CAREFUL_OP(cum_2,<=,cluster_dist+best_gain)){/*160:*/#line 3769 "./jbmr.w"#if JBMR_MAX_VERBOSEnum_reject_by_decluster++;#if JBMR_MAX_VERBOSE >= 500if(verbose>=500){/*167:*/#line 3866 "./jbmr.w"#if JBMR_MAX_VERBOSE{int i;for(i= 0;i<two_i;i++)printf(" ");}#endif/*:167*/#line 3774 "./jbmr.w"printf("%d: %d %d "length_t_spec" s%d rejected (#%d), clust_dist==%f\n",enbl,t2ip1,t2ip2,#if !SPLIT_GAIN_VARlength_t_pcast(cum_2),#elselength_t_pcast(cum_2_pos-cum_2_neg),#endife[BL][enbl].scheme_id,num_reject_by_decluster,(double)cluster_dist);fflush(stdout);}#endif#endif/*:160*/#line 1789 "./jbmr.w"}else#endif{/*66:*/#line 1842 "./jbmr.w"#if BL==0if(tour_inorder(t[1],t[2],t2ip2,t2ip1)){e[BL][enbl].scheme_id= 4;if(t[1]!=t[4]){/*67:*/#line 1864 "./jbmr.w"{const length_t cost_phantom= cost(t[1],t2ip2);#if !SPLIT_GAIN_VARconst length_t cum_exit_now= cum_2-cost_phantom;#endifif(#if LENGTH_TYPE_IS_EXACTcum_exit_now> best_gain#elif SPLIT_GAIN_VARcum_2_pos> best_gain_with_slop+cum_2_neg+cost_phantom#elsecum_exit_now> best_gain_with_slop#endif){#if SPLIT_GAIN_VARbest_gain= cum_2_pos-cum_2_neg-cost_phantom;#elsebest_gain= cum_exit_now;#endif#if !LENGTH_TYPE_IS_EXACTbest_gain_with_slop= best_gain+instance_epsilon;#endifbest_two_i= two_i;best_exit_a= t2ip1;best_exit_b= t2ip2;best_scheme_id= e[BL][enbl].scheme_id;/*148:*/#line 3587 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 200if(verbose>=200){/*167:*/#line 3866 "./jbmr.w"#if JBMR_MAX_VERBOSE{int i;for(i= 0;i<two_i;i++)printf(" ");}#endif/*:167*/#line 3590 "./jbmr.w"printf("best_gain = "length_t_spec" %d %d s%d\n",length_t_pcast(best_gain),best_exit_a,best_exit_b,best_scheme_id);fflush(stdout);}#endif/*:148*/#line 1894 "./jbmr.w"}}/*:67*/#line 1847 "./jbmr.w"}}else{e[BL][enbl].scheme_id= 0;}#endif/*:66*//*81:*/#line 2371 "./jbmr.w"#if BL==1if(scheme_num_cities[e[BL][enbl].scheme_id= base_scheme[6]]==6){/*67:*/#line 1864 "./jbmr.w"{const length_t cost_phantom= cost(t[1],t2ip2);#if !SPLIT_GAIN_VARconst length_t cum_exit_now= cum_2-cost_phantom;#endifif(#if LENGTH_TYPE_IS_EXACTcum_exit_now> best_gain#elif SPLIT_GAIN_VARcum_2_pos> best_gain_with_slop+cum_2_neg+cost_phantom#elsecum_exit_now> best_gain_with_slop#endif){#if SPLIT_GAIN_VARbest_gain= cum_2_pos-cum_2_neg-cost_phantom;#elsebest_gain= cum_exit_now;#endif#if !LENGTH_TYPE_IS_EXACTbest_gain_with_slop= best_gain+instance_epsilon;#endifbest_two_i= two_i;best_exit_a= t2ip1;best_exit_b= t2ip2;best_scheme_id= e[BL][enbl].scheme_id;/*148:*/#line 3587 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 200if(verbose>=200){/*167:*/#line 3866 "./jbmr.w"#if JBMR_MAX_VERBOSE{int i;for(i= 0;i<two_i;i++)printf(" ");}#endif/*:167*/#line 3590 "./jbmr.w"printf("best_gain = "length_t_spec" %d %d s%d\n",length_t_pcast(best_gain),best_exit_a,best_exit_b,best_scheme_id);fflush(stdout);}#endif/*:148*/#line 1894 "./jbmr.w"}}/*:67*/#line 2374 "./jbmr.w"}#endif/*:81*//*90:*/#line 2709 "./jbmr.w"#if BL==2e[BL][enbl].scheme_id= base_scheme[8];/*67:*/#line 1864 "./jbmr.w"{const length_t cost_phantom= cost(t[1],t2ip2);#if !SPLIT_GAIN_VARconst length_t cum_exit_now= cum_2-cost_phantom;#endifif(#if LENGTH_TYPE_IS_EXACTcum_exit_now> best_gain#elif SPLIT_GAIN_VARcum_2_pos> best_gain_with_slop+cum_2_neg+cost_phantom#elsecum_exit_now> best_gain_with_slop#endif){#if SPLIT_GAIN_VARbest_gain= cum_2_pos-cum_2_neg-cost_phantom;#elsebest_gain= cum_exit_now;#endif#if !LENGTH_TYPE_IS_EXACTbest_gain_with_slop= best_gain+instance_epsilon;#endifbest_two_i= two_i;best_exit_a= t2ip1;best_exit_b= t2ip2;best_scheme_id= e[BL][enbl].scheme_id;/*148:*/#line 3587 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 200if(verbose>=200){/*167:*/#line 3866 "./jbmr.w"#if JBMR_MAX_VERBOSE{int i;for(i= 0;i<two_i;i++)printf(" ");}#endif/*:167*/#line 3590 "./jbmr.w"printf("best_gain = "length_t_spec" %d %d s%d\n",length_t_pcast(best_gain),best_exit_a,best_exit_b,best_scheme_id);fflush(stdout);}#endif/*:148*/#line 1894 "./jbmr.w"}}/*:67*/#line 2712 "./jbmr.w"#endif/*:90*//*100:*/#line 2944 "./jbmr.w"#if BL==3e[BL][enbl].scheme_id= 13;/*67:*/#line 1864 "./jbmr.w"{const length_t cost_phantom= cost(t[1],t2ip2);#if !SPLIT_GAIN_VARconst length_t cum_exit_now= cum_2-cost_phantom;#endifif(#if LENGTH_TYPE_IS_EXACTcum_exit_now> best_gain#elif SPLIT_GAIN_VARcum_2_pos> best_gain_with_slop+cum_2_neg+cost_phantom#elsecum_exit_now> best_gain_with_slop#endif){#if SPLIT_GAIN_VARbest_gain= cum_2_pos-cum_2_neg-cost_phantom;#elsebest_gain= cum_exit_now;#endif#if !LENGTH_TYPE_IS_EXACTbest_gain_with_slop= best_gain+instance_epsilon;#endifbest_two_i= two_i;best_exit_a= t2ip1;best_exit_b= t2ip2;best_scheme_id= e[BL][enbl].scheme_id;/*148:*/#line 3587 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 200if(verbose>=200){/*167:*/#line 3866 "./jbmr.w"#if JBMR_MAX_VERBOSE{int i;for(i= 0;i<two_i;i++)printf(" ");}#endif/*:167*/#line 3590 "./jbmr.w"printf("best_gain = "length_t_spec" %d %d s%d\n",length_t_pcast(best_gain),best_exit_a,best_exit_b,best_scheme_id);fflush(stdout);}#endif/*:148*/#line 1894 "./jbmr.w"}}/*:67*/#line 2947 "./jbmr.w"#endif/*:100*/#line 1794 "./jbmr.w"e[BL][enbl].t2ip1= t2ip1;e[BL][enbl].t2ip2= t2ip2;#if !SPLIT_GAIN_VARe[BL][enbl].gain_for_comparison= e[BL][enbl].gain= cum_2;#elsee[BL][enbl].gain_for_comparison= cum_2_pos-cum_2_neg;e[BL][enbl].gain_pos= cum_2_pos;e[BL][enbl].gain_neg= cum_2_neg;#endif#if JBMR_DECLUSTER_IN_GREEDYe[BL][enbl].gain_for_comparison-= cluster_dist;#endif#if JBMR_DECLUSTER_IN_ELIGIBILITY_TESTe[BL][enbl].cluster_dist= cluster_dist;#endif/*158:*/#line 3739 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 500if(verbose>=500){/*167:*/#line 3866 "./jbmr.w"#if JBMR_MAX_VERBOSE{int i;for(i= 0;i<two_i;i++)printf(" ");}#endif/*:167*/#line 3742 "./jbmr.w"#if !SPLIT_GAIN_VARprintf("%d: %d %d "length_t_spec" s%d\n",enbl,t2ip1,t2ip2,length_t_pcast(cum_2),#elseprintf("%d: %d %d "length_t_spec"-"length_t_spec"="length_t_spec" s%d\n",enbl,t2ip1,t2ip2,length_t_pcast(cum_2_pos),length_t_pcast(cum_2_neg),length_t_pcast(cum_2_pos-cum_2_neg),#endife[BL][enbl].scheme_id);fflush(stdout);}#endif/*:158*/#line 1813 "./jbmr.w"enbl++;}}/*:64*/#line 1760 "./jbmr.w"}#endif/*:63*//*80:*/#line 2210 "./jbmr.w"#if BL==1if(!((t2ip2==t[4])||(t2ip1==t[2]&&t2ip2==t[3])||(t2ip1==t[3]&&t2ip2==t[2]))){int is_illegal= 0;switch(base_scheme[5]){case 0:if(tour_inorder(t[1],t[2],t2ip2,t2ip1)){base_scheme[6]= 0;is_illegal= t[2]==t2ip1||t[1]==t2ip2;}else{base_scheme[6]= 1;is_illegal= t[2]==t2ip2||t[1]==t2ip1||t[4]==t2ip2||t[1]==t2ip2;}break;case 2:base_scheme[6]= 2;is_illegal= tour_inorder(t[3],t[4],t2ip1,t2ip2);break;case 5:if(tour_inorder(t[1],t[2],t2ip2,t2ip1)){base_scheme[6]= 5;}else{base_scheme[6]= 7;is_illegal= t2ip2==t[1]||t[1]==t[4];}break;case 8:if(tour_inorder(t[4],t[3],t2ip2,t2ip1)){base_scheme[6]= 8;}else{base_scheme[6]= 9;is_illegal= t2ip2==t[2];}break;default:errorif(1,"Non-exhaustive switch: %d",base_scheme[5]);}if(!is_illegal){/*166:*/#line 3856 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 1000if(verbose>=1000){/*167:*/#line 3866 "./jbmr.w"#if JBMR_MAX_VERBOSE{int i;for(i= 0;i<two_i;i++)printf(" ");}#endif/*:167*/#line 3859 "./jbmr.w"printf("base_scheme6 == %d\n",base_scheme[6]);fflush(stdout);}#endif/*:166*/#line 2306 "./jbmr.w"/*64:*/#line 1773 "./jbmr.w"{#if JBMR_DECLUSTER_IN_ELIGIBILITY_TEST || JBMR_DECLUSTER_IN_GREEDYconst length_t cluster_dist= decluster_d(t[1],t2ip2);/*159:*/#line 3760 "./jbmr.w"#if JBMR_MAX_VERBOSE >= 501 && (JBMR_DECLUSTER_IN_ELIGIBILITY_TEST||JBMR_DECLUSTER_IN_GREEDY)if(verbose>=501){/*167:*/#line 3866 "./jbmr.w"#if JBMR_MAX_VERBOSE{int i;for(i= 0;i<two_i;i++)printf(" ");}#endif/*:167*/#line 3763 "./jbmr.w"printf(" v---- next clust_dist==%f\n",(double)cluster_dist);}#endif/*:159*/#line 1777 "./jbmr.w"#endif#if !SPLIT_GAIN_VARcum_2= cum_1+cost(t2ip1,t2ip2);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -