File: gprolog064.html

package info (click to toggle)
gprolog 1.3.0-6.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 13,512 kB
  • ctags: 8,954
  • sloc: ansic: 57,431; perl: 16,620; sh: 5,900; makefile: 1,284
file content (98 lines) | stat: -rw-r--r-- 4,218 bytes parent folder | download | duplicates (2)
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
<!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.08">
<LINK rel="stylesheet" type="text/css" href="gprolog.css">
<TITLE>
Optimization constraints
</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="gprolog063.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="gprolog054.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<HR>

<H3 CLASS="subsection"><A NAME="htoc338">8.10</A>&nbsp;&nbsp;Optimization constraints</H3><UL>
<LI><A HREF="gprolog064.html#toc276"><TT>fd_minimize/2</TT>,
 <TT>fd_maximize/2</TT></A>
</UL>

<A NAME="toc276"></A>
<H4 CLASS="subsubsection"><A NAME="htoc339">8.10.1</A>&nbsp;&nbsp;<TT>fd_minimize/2</TT>,
 <TT>fd_maximize/2</TT></H4>
 
 
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
fd_minimize(+callable_term, ?fd_variable)<BR>
fd_maximize(+callable_term, ?fd_variable)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>fd_minimize(Goal, X)</TT> repeatedly calls <TT>Goal</TT> to find a
value that minimizes the variable <TT>X</TT>. <TT>Goal</TT> is a Prolog goal
that should instantiate <TT>X</TT>, a common case being the use of
<TT>fd_labeling/2</TT> (section&nbsp;<A HREF="gprolog063.html#fd-labeling/2">8.9.1</A>). This predicate uses a
branch-and-bound algorithm with restart: each time <TT>call(Goal)</TT>
succeeds the computation restarts with a new constraint <TT>X #&lt; V</TT>
where <TT>V</TT> is the value of <TT>X</TT> at the end of the last call of
<TT>Goal</TT>. When a failure occurs (either because there are no remaining
choice-points for <TT>Goal</TT> or because the added constraint is
inconsistent with the rest of the store) the last solution is recomputed
since it is optimal.<BR>
<BR>
<TT>fd_maximize(Goal, X)</TT> is similar to <TT>fd_minimize/2</TT> but
<TT>X</TT> is maximized<TT>.</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>Goal</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</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>Goal</TT> is neither a variable nor a callable term</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(callable, Goal)</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>The predicate indicator <TT>Pred</TT> of <TT>Goal</TT> does not
correspond to an existing procedure and the value of the <TT>unknown</TT>
Prolog flag is <TT>error</TT> (section&nbsp;<A HREF="gprolog045.html#set-prolog-flag/2">7.22.1</A>)</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>existence_error(procedure, Pred)</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>X</TT> is neither a variable nor an FD variable nor an integer
</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(fd_variable, X)</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.

<HR SIZE=2>
Copyright (C) 1999-2007 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="gprolog063.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="gprolog054.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
</BODY>
</HTML>