⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page446.html

📁 Data Structures And Algorithms With Object-Oriented Design Patterns In Python (2003) source code and
💻 HTML
字号:
<HTML><HEAD><TITLE>Depth-First, Branch-and-Bound Solver</TITLE></HEAD><BODY bgcolor="#FFFFFF"> <a href="../index.html" target="_top"><img src="../icons/usins.gif" alt="Logo" align=right></a><b>Data Structures and Algorithms with Object-Oriented Design Patterns in Python</b><br><A NAME="tex2html6308" HREF="page447.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html6306" HREF="page445.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html6302" HREF="page445.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html6310" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H3><A NAME="SECTION0014241000000000000000">Depth-First, Branch-and-Bound Solver</A></H3><P>Only a relatively minor modification of the simple,depth-first solver shown in Program&nbsp;<A HREF="page443.html#progdepthFirstSolvera"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> is neededto transform it into a branch-and-bound solver.Program&nbsp;<A HREF="page446.html#progdepthFirstBranchAndBoundSolvera"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>defines the <tt>DepthFirstBranchAndBoundSolver</tt> class.<P><P><A NAME="33432">&#160;</A><A NAME="progdepthFirstBranchAndBoundSolvera">&#160;</A> <IMG WIDTH=575 HEIGHT=257 ALIGN=BOTTOM ALT="program32609" SRC="img1741.gif"  ><BR><STRONG>Program:</STRONG> <tt>DepthFirstBranchAndBoundSolver</tt> class 	<tt>__init__</tt> and <tt>search</tt> methods.<BR><P><P>The only difference between the simple, depth-first solverand the branch-and-bound version is the <tt>if</tt> statement on lines&nbsp;11-12.As each node in the solution space is visited two tests are done:First, the <tt>isFeasible</tt> accessor is called to check whetherthe given node represents a feasible solution.Next, the <tt>bound</tt> accessor is called to determine the lower bound on the best possible solution in the given subtree.The second test determines whether this bound is less thanthe value of the objective function of the best solution already found.The recursive call to explore the subtree is only madeif both tests succeed.Otherwise, the subtree of the solution space is pruned.<P>The degree to which the solution space may be pruneddepends strongly on the nature of the problem being solved.In the worst case, no subtrees are pruned and the branch-and-boundmethod visits all the nodes in the solution space.The branch-and-bound technique is really justa <em>heuristic</em><A NAME=32626>&#160;</A>--sometimes it works and sometimes it does not.<P>It is important to understand the trade-off being made:The solution space is being pruned at the added expenseof performing the tests as each node is visited.The technique is successful only ifthe savings which accrue from pruningexceed the additional execution time arising from the tests.<P><HR><A NAME="tex2html6308" HREF="page447.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html6306" HREF="page445.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html6302" HREF="page445.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html6310" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <P><ADDRESS><img src="../icons/bruno.gif" alt="Bruno" align=right><a href="../copyright.html">Copyright &#169; 2003</a> by <a href="../signature.html">Bruno R. Preiss, P.Eng.</a>  All rights reserved.</ADDRESS></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -