@x @ After this program finds all solutions, it normally prints their total @y This version of {\mc XCCDC} uses a dynamic weighting scheme, namely the ``{\mc FRB} heuristic,'' motivated by the paper of Li, Yin, and Li in @^Li, Hongbo@> @^Yin, Minghao@> @^Li, Zhanshan@> {\sl Leibniz International Proceedings in Informatics\/ \bf210} (2021), 9:1--9:10 [the proceedings of the 27th International Conference on Principles and Practice of Constraint Programming, CP~2021]. When the option chosen for branching on some primary item~$i$ causes another primary item~$i'$ to be wiped out, we say that a failure has occurred with respect to~$i$. We branch on an item that has a small number of options and a relatively high failure rate. Details are discussed below. @ After this program finds all solutions, it normally prints their total @z @x @d show_max_deg 2048 /* |vbose| code for reporting maximum branching degree */ @y @d show_max_deg 2048 /* |vbose| code for reporting maximum branching degree */ @d show_final_stats 4096 /* |vbose| code to display item stats at the end */ @z @x if (vbose&show_profile) @; @y if (vbose&show_profile) @; if (vbose&show_final_stats) { fprintf(stderr,"Final primary item stats:\n"); print_item_stats(); } @z @x (The |match| field is present only in secondary items.) @y (The |match| field is present only in secondary items.) Finally, a primary item $x$ also has two special fields called |assigns| and |fails|, used in the {\mc FRB} heuristic. Their significance is described below. @z @x @d match(x) set[(x)-6] /* a required color in compatibility tests */ @d primextra 5 /* this many extra entries of |set| for each primary item */ @d secondextra 6 /* and this many for each secondary item */ @d maxextra 6 /* maximum of |primextra| and |secondextra| */ @y @d match(x) set[(x)-6] /* a required color in compatibility tests */ @d assigns(x) set[(x)-6] /* number of assignments tried so far for |x|, plus 1 */ @d fails(x) set[(x)-7] /* how many of them failed? */ @d primextra 7 /* this many extra entries of |set| for each primary item */ @d secondextra 6 /* and this many for each secondary item */ @d maxextra 7 /* maximum of |primextra| and |secondextra| */ @z @x if (c; goto tryagain; } if (!empty_the_queue()) { nmems+=mems-tmems; @; goto tryagain; } @; @z @x @ The ``best item'' is considered to be an item that minimizes the number of remaining choices. If there are several candidates, we choose the first one that we encounter. Each primary item should have at least one valid choice, because of domain consistency. @d infty 0x7fffffff @= t=infty; if ((vbose&show_details) && level=maxl-show_choices_gap) fprintf(stderr,"Stage "O"d,",stage); for (k=0;t>1 && k=maxl-show_choices_gap) { print_item_name(item[k],stderr); fprintf(stderr,"("O"d)",s); } if (s<=t) { if (s==0) fprintf(stderr,"I'm confused.\n"); /* |hide| missed this */ if (s=maxl-show_choices_gap) { if (t==infty) fprintf(stderr," solution\n"); else { fprintf(stderr," branching on"); print_item_name(best_itm,stderr); fprintf(stderr,"("O"d)\n",t); } } if (t>maxdeg && t @^Yin, Minghao@> @^Li, Zhanshan@> @= oo,assigns(best_itm)++; if (assigns(best_itm)<=0) { fprintf(stderr,"Too many assignments (2^{31})!\n"); exit(-6); } bmems+=2; @ @= oo,assigns(best_itm)++; if (assigns(best_itm)<=0) { fprintf(stderr,"Too many assignments (2^{31})!\n"); exit(-66); } oo,fails(best_itm)++; bmems+=4; @ @= void print_item_stats(void) { register int k; for (k=0;k= { register float score,tscore,w; register int force; score=finfty,t=infty; if ((vbose&show_details) && level=maxl-show_choices_gap) fprintf(stderr,"Level "O"d:",level); for (k=0;t>1 && k=finfty) tscore=dangerous; if (tscore=maxl-show_choices_gap) { print_item_name(item[k],stderr);@+ if (t==1) fprintf(stderr,"(1)"); else fprintf(stderr,"("O"d,"O"d/"O"d)",s,fails(item[k]),assigns(item[k])); } } if ((vbose&show_details) && level=maxl-show_choices_gap) { if (t==infty) fprintf(stderr," solution\n"); else { fprintf(stderr," branching on"); print_item_name(best_itm,stderr);@+ if (t==1) fprintf(stderr,"(forced)\n"); else fprintf(stderr,"("O"d), score "O".4f\n",t,score); } } if (t>maxdeg && t

AltStyle によって変換されたページ (->オリジナル) /