SolverFinish 函数SolverFinish Function

指示 Microsoft Office Excel 如何处理结果,以及要在解决方案过程完成时生成哪种报表。Tells Microsoft Office Excel what to do with the results and what kind of report to create when the solution process is completed.

注意:求解器加载项默认处于禁用状态。Note The Solver add-in is not enabled by default. 在可以使用此函数之前,必须已安装且已启用规划求解加载项。Before you can use this function, you must have the Solver add-in enabled and installed. 有关如何执行此操作的信息,请参阅使用规划求解 VBA 函数For information about how to do that, see Using the Solver VBA Functions. 安装规划求解加载项之后,必须建立对规划求解加载项的引用。After the Solver add-in is installed, you must establish a reference to the Solver add-in. 在 Visual Basic 编辑器中,模块处于活动状态,单击 "工具" 菜单上的 "引用",然后选择 "可用引用" 下的 "规划求解"。In the Visual Basic Editor, with a module active, click References on the Tools menu, and then select Solver under Available References. 如果 “规划求解” 没有显示在 “可使用的引用” 下面,请单击 “浏览”,然后打开 \Program Files\Microsoft Office\Office14\Library\SOLVER 子文件夹中的 Solver.xlam。If Solver does not appear under Available References, click Browse, and then open Solver.xlam in the \Program Files\Microsoft Office\Office14\Library\SOLVER subfolder.

SolverFinishKeepFinalReportArrayoutlinereports 值SolverFinish(KeepFinal, ReportArray, OutlineReports)

KeepFinalVariant 类型的可选参数。KeepFinal Optional Variant. 可取值为 1 或 2。Can be either 1 or 2. 如果**KeepFinal** 为1或被省略,则最终的解决方案值将保留在可变单元格中,替换任何以前的值。If KeepFinal is 1 or omitted, the final solution values are kept in the changing cells, replacing any former values. 如果 KeepFinal 值为 2,最终解决方案值遭放弃,并还原原有值。If KeepFinal is 2, the final solution values are discarded, and the former values are restored. ReportArrayVariant 类型的可选参数。ReportArray Optional Variant. Excel 在求解器完成时生成的报表种类:The kind of report that Excel will create when Solver is finished:

  • 当使用“单工 LP”或“GRG 非线性求解”方法时,1 会创建一个“解答”报告,2 会创建一个“敏感度”报告,3 会创建一个“限制”报告。When the Simplex LP or GRG Nonlinear Solving method is used, 1 creates an Answer report, 2 creates a Sensitivity report, and 3 creates a Limit report.

  • 如果使用的是演进式求解方法,1 表示生成“答案”报表,2 表示生成“总体”报表。When the Evolutionary Solving method is used, 1 creates an Answer report, and 2 creates a Population report.

  • 当**SolverSolve** 返回5(规划求解找不到可行的解决方案)时,1将创建一个可行性报告,2会创建一个可行性边界报告。When SolverSolve returns 5 (Solver could not find a feasible solution), 1 creates a Feasibility Report, and 2 creates a Feasibility-Bounds report.

  • SolverSolve 返回 7 时(不满足线性条件),1 会创建“线性”报告。When SolverSolve returns 7 (the linearity conditions are not satisfied), 1 creates a Linearity report.

使用 Array 函数可指定要显示的报告,例如,ReportArray:= Array(1,3)Use the Array function to specify the reports you want to display — for example, ReportArray:= Array(1,3). OutlineReportsVariant 类型的可选参数。OutlineReports Optional Variant. 可以是TrueFalseCan be either True or False. 如果**outlinereports 值** 为False或被省略,则报告将以 "常规" 格式生成,而不进行分级显示。If OutlineReports is False or omitted, reports are produced in the "regular" format, without outlining. 如果 OutlineReports 值为 True,生成的报表包含对应于你为决策变量和限制输入的单元格范围的大纲显示组。If OutlineReports is True, reports are produced with outlined groups corresponding to the cell ranges you've entered for decision variables and constraints.


本示例加载先前计算过的规划求解模型(该模型存储于 Sheet1 中),并再次求解该模型,然后在新工作表上生成答案报告。This example loads the previously calculated Solver model stored on Sheet1, solves the model again, and then generates an answer report on a new worksheet.

SolverLoad LoadArea:=Range("A33:A38") 
SolverSolve UserFinish:=True 
SolverFinish KeepFinal:=1, ReportArray:=Array(1)

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.