<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META name="GENERATOR" content="hevea 1.06-7 of 2001-11-14"> <TITLE> Labeling constraints </TITLE> </HEAD> <BODY TEXT=black BGCOLOR=white> <A HREF="manual062.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="manual054.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual064.html"><IMG SRC ="next_motif.gif" ALT="Next"></A> <HR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#66dbff"><DIV ALIGN=center><TABLE> <TR><TD><FONT SIZE=4><B><A NAME="htoc336">8.9</A></B></FONT></TD> <TD WIDTH="100%" ALIGN=center><FONT SIZE=4><B>Labeling constraints</B></FONT></TD> </TR></TABLE></DIV></TD> </TR></TABLE><UL> <LI><A HREF="manual063.html#toc275"> <TT>fd_labeling/2</TT>, <TT>fd_labeling/1</TT>, <TT>fd_labelingff/1</TT></A> </UL> <BR> <A NAME="toc275"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE> <TR><TD><B><A NAME="htoc337">8.9.1</A></B></TD> <TD WIDTH="100%" ALIGN=center><B><TT>fd_labeling/2</TT>, <TT>fd_labeling/1</TT>, <TT>fd_labelingff/1</TT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="fd-labeling/2"></A> <BR> <B>Templates</B> <DL COMPACT=compact><DT><DD><TT> fd_labeling(+fd_variable_list, +fd_labeling_option_list)<BR> fd_labeling(+fd_variable, +fd_labeling_option_list)<BR> fd_labeling(+fd_variable_list)<BR> fd_labeling(+fd_variable)<BR> fd_labelingff(+fd_variable_list)<BR> fd_labelingff(+fd_variable)</TT></DL> <B>Description</B><BR> <BR> <TT>fd_labeling(Vars, Options)</TT> assigns a value to each variable <TT>X</TT> of the list <TT>Vars</TT> according to the list of labeling options given by <TT>Options</TT>. <TT>Vars</TT> can be also a single FD variable. This predicate is re-executable on backtracking.<BR> <BR> <B>FD labeling options</B>: <TT>Options</TT> is a list of labeling options. If this list contains contradictory options, the rightmost option is the one which applies. Possible options are: <UL><LI><TT>variable_method(V)</TT>: specifies the heuristics to select the variable to enumerate: <UL><LI><TT>standard</TT>: no heuristics, the leftmost variable is selected.<BR> <BR> <LI><TT>first_fail</TT> (or <TT>ff</TT>): selects the variable with the smallest number of elements in its domain. If several variables have the same number of elements the leftmost variable is selected.<BR> <BR> <LI><TT>most_constrained</TT>: like <TT>first_fail</TT> but when several variables have the same number of elements selects the variable that appears in most constraints.<BR> <BR> <LI><TT>smallest</TT>: selects the variable that has the smallest value in its domain. If there is more than one such variable selects the variable that appears in most constraints.<BR> <BR> <LI><TT>largest</TT>: selects the variable that has the greatest value in its domain. If there is more than one such variable selects the variable that appears in most constraints.<BR> <BR> <LI><TT>max_regret</TT>: selects the variable that has the greatest difference between the smallest value and the next value of its domain. If there is more than one such variable selects the variable that appears in most constraints.<BR> <BR> <LI><TT>random</TT>: selects randomly a variable. Each variable is only chosen once.</UL><BR> The default value is <TT>standard</TT>.<BR> <BR> <LI><TT>reorder(true/false)</TT>: specifies if the variable heuristics should dynamically reorder the list of variable (<TT>true</TT>) or not (<TT>false</TT>). Dynamic reordering is generally more efficient but in some cases a static ordering is faster. The default value is <TT>true</TT>.<BR> <BR> <LI><TT>value_method(V)</TT>: specifies the heuristics to select the value to assign to the chosen variable: <UL><LI><TT>min</TT>: enumerates the values from the smallest to the greatest (default).<BR> <BR> <LI><TT>max</TT>: enumerates the values from the greatest to the smallest.<BR> <BR> <LI><TT>middle</TT>: enumerates the values from the middle to the bounds.<BR> <BR> <LI><TT>bounds</TT>: enumerates the values from the bounds to the middle.<BR> <BR> <LI><TT>random</TT>: enumerates the values randomly. Each value is only tried once.</UL><BR> The default value is <TT>min</TT>.<BR> <BR> <LI><TT>backtracks(B)</TT>: unifies <TT>B</TT> with the number of backtracks during the enumeration.</UL> <TT>fd_labeling(Vars)</TT> is equivalent to <TT>fd_labeling(Vars, [])</TT>.<BR> <BR> <TT>fd_labelingff(Vars)</TT> is equivalent to <TT>fd_labeling(Vars, [variable_method(ff)])</TT>.<BR> <BR> <B>Errors</B><BR> <TABLE CELLSPACING=2 CELLPADDING=0> <TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD> </TR> <TR><TD VALIGN=top ALIGN=left><TT>Vars</TT> is a partial list or a list with an element <TT>E</TT> which is a variable</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD> </TR> <TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD> </TR> <TR><TD VALIGN=top ALIGN=left><TT>Vars</TT> is neither a partial list nor a list</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(list, Vars)</TT></TD> </TR> <TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD> </TR> <TR><TD VALIGN=top ALIGN=left>an element <TT>E</TT> of the <TT>Vars</TT> list is neither a variable nor an integer nor an FD variable</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(fd_variable, E)</TT></TD> </TR> <TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD> </TR> <TR><TD VALIGN=top ALIGN=left><TT>Options</TT> is a partial list or a list with an element <TT>E</TT> which is a variable</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD> </TR> <TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD> </TR> <TR><TD VALIGN=top ALIGN=left><TT>Options</TT> is neither a partial list nor a list</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>type_error(list, Options)</TT></TD> </TR> <TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD> </TR> <TR><TD VALIGN=top ALIGN=left>an element <TT>E</TT> of the <TT>Options</TT> list is neither a variable nor a labeling option</TD> <TD VALIGN=top ALIGN=center NOWRAP> </TD> <TD VALIGN=top ALIGN=left><TT>domain_error(fd_labeling_option, E)</TT></TD> </TR> <TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD> </TR></TABLE><BR> <B>Portability</B><BR> <BR> GNU Prolog predicates.<BR> <BR> <HR SIZE=2> Copyright (C) 1999-2002 Daniel Diaz <BR> <BR> Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. <BR> <BR> <A HREF="index.html#copyright">More about the copyright</A> <HR> <A HREF="manual062.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="manual054.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual064.html"><IMG SRC ="next_motif.gif" ALT="Next"></A> </BODY> </HTML>