- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在学习 CBC 的 C++ API,与仅打开 CBC 命令行实用程序相比,我无法匹配加载 MPS 文件并使用 CbcModel 类求解的已编译 C++ 程序的性能,导入相同的文件并使用 solve
。 cmd 行实用程序在 1 秒内解决了 MIP,C++ 程序在 <10 分钟内不会终止。
我认为问题在于,当我使用 C++ API 时,我必须显式配置所有参数,而且 cmd 行实用程序使用的默认参数似乎非常适合您的平均 MIP 模型。
是否有 cmd 行实用程序使用的预求解、启发式算法和剪切的默认参数列表,我应该在我的 C++ 程序中激活这些参数以匹配性能。也许有人已经尝试过这些参数并根据经验找到了一组很好的参数。
C++程序是:
int main ()
{
OsiClpSolverInterface solver1;
solver1.setLogLevel(0);
// Read in example model in MPS file format
// and assert that it is a clean model
int numMpsReadErrors = solver1.readMps("generic_mip.mps","");
assert(numMpsReadErrors==0);
// Pass the solver with the problem to be solved to CbcModel
CbcModel model(solver1);
model.setLogLevel(0);
// Add clique cut generator
CglClique clique_generator;
model.addCutGenerator(&clique_generator,-1, "Clique");
// Add rounding heuristic
CglMixedIntegerRounding mixedGen;
model.addCutGenerator(&mixedGen, -1, "Rounding");
model.setNumberThreads(4);
model.messageHandler()->setPrefix(false);
model.branchAndBound();
const double * solution = model.bestSolution();
printf("Optimal value is %.2f", *solution);
return 0;
}
有问题的 MIP 模型可以从 HERE 下载。最优目标值:-771.2957。
Cbc 命令行实用程序日志,指示各种高级功能已激活(预处理、原始启发式和强分支):
Continuous objective value is -798.689 - 0.03 seconds
Cgl0002I 21 variables fixed
Cgl0003I 0 fixed, 175 tightened bounds, 1972 strengthened rows, 0 substitutions
Cgl0004I processed model has 3731 rows, 3835 columns (3835 integer (3660 of which binary)) and 37873 elements
Cbc0038I Initial state - 365 integers unsatisfied sum - 129.125
Cbc0038I Pass 1: (0.18 seconds) suminf. 58.66667 (121) obj. -572.133 iterations 510
Cbc0038I Pass 2: (0.18 seconds) suminf. 58.66667 (121) obj. -572.133 iterations 23
Cbc0038I Pass 3: (0.18 seconds) suminf. 58.66667 (121) obj. -572.133 iterations 1
Cbc0038I Pass 4: (0.20 seconds) suminf. 69.00000 (138) obj. -299.496 iterations 589
Cbc0038I Pass 5: (0.20 seconds) suminf. 54.00000 (109) obj. -287.063 iterations 194
Cbc0038I Pass 6: (0.21 seconds) suminf. 54.00000 (109) obj. -287.063 iterations 12
Cbc0038I Pass 7: (0.21 seconds) suminf. 49.00000 (100) obj. -273.321 iterations 33
Cbc0038I Pass 8: (0.22 seconds) suminf. 48.00000 (97) obj. -269.421 iterations 14
Cbc0038I Pass 9: (0.22 seconds) suminf. 48.00000 (98) obj. -268.624 iterations 8
Cbc0038I Pass 10: (0.23 seconds) suminf. 48.00000 (97) obj. -264.813 iterations 4
Cbc0038I Pass 11: (0.23 seconds) suminf. 47.00000 (94) obj. -261.75 iterations 8
Cbc0038I Pass 12: (0.24 seconds) suminf. 47.00000 (94) obj. -261.75 iterations 3
Cbc0038I Pass 13: (0.24 seconds) suminf. 47.00000 (94) obj. -261.75 iterations 3
Cbc0038I Pass 14: (0.25 seconds) suminf. 57.75000 (118) obj. -103.115 iterations 508
Cbc0038I Pass 15: (0.26 seconds) suminf. 49.00000 (98) obj. -97.4793 iterations 163
Cbc0038I Pass 16: (0.26 seconds) suminf. 49.00000 (98) obj. -97.4793 iterations 3
Cbc0038I Pass 17: (0.27 seconds) suminf. 48.75000 (98) obj. -101.421 iterations 24
Cbc0038I Pass 18: (0.27 seconds) suminf. 47.00000 (94) obj. -103.346 iterations 25
Cbc0038I Pass 19: (0.28 seconds) suminf. 47.00000 (94) obj. -103.346 iterations 2
Cbc0038I Pass 20: (0.28 seconds) suminf. 47.00000 (94) obj. -103.346 iterations 21
Cbc0038I Pass 21: (0.29 seconds) suminf. 51.50000 (107) obj. 60.0315 iterations 469
Cbc0038I Pass 22: (0.30 seconds) suminf. 40.00000 (80) obj. 59.913 iterations 168
Cbc0038I Pass 23: (0.30 seconds) suminf. 40.00000 (80) obj. 59.913 iterations 2
Cbc0038I Pass 24: (0.31 seconds) suminf. 39.50000 (79) obj. 59.913 iterations 27
Cbc0038I Pass 25: (0.31 seconds) suminf. 39.00000 (78) obj. 59.913 iterations 23
Cbc0038I Pass 26: (0.32 seconds) suminf. 39.00000 (78) obj. 59.913 iterations 13
Cbc0038I Pass 27: (0.33 seconds) suminf. 50.00000 (101) obj. 124.699 iterations 504
Cbc0038I Pass 28: (0.34 seconds) suminf. 41.00000 (82) obj. 118.624 iterations 174
Cbc0038I Pass 29: (0.34 seconds) suminf. 41.00000 (82) obj. 118.624 iterations 5
Cbc0038I Pass 30: (0.34 seconds) suminf. 41.00000 (82) obj. 118.624 iterations 19
Cbc0038I No solution found this major pass
Cbc0038I Before mini branch and bound, 2356 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (0.41 seconds)
Cbc0038I After 0.41 seconds - Feasibility pump exiting - took 0.25 seconds
Cbc0031I 583 added rows had average density of 8.2024014
Cbc0013I At root node, 583 cuts changed objective from -798.68913 to -771.29565 in 10 passes
Cbc0014I Cut generator 0 (Probing) - 541 row cuts average 2.0 elements, 0 column cuts (0 active) in 0.044 seconds - new frequency is 1
Cbc0014I Cut generator 1 (Gomory) - 751 row cuts average 116.6 elements, 0 column cuts (0 active) in 0.108 seconds - new frequency is 1
Cbc0014I Cut generator 2 (Knapsack) - 451 row cuts average 2.0 elements, 0 column cuts (0 active) in 0.040 seconds - new frequency is 1
Cbc0014I Cut generator 3 (Clique) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.004 seconds - new frequency is -100
Cbc0014I Cut generator 4 (MixedIntegerRounding2) - 155 row cuts average 16.9 elements, 0 column cuts (0 active) in 0.028 seconds - new frequency is 1
Cbc0014I Cut generator 5 (FlowCover) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.008 seconds - new frequency is -100
Cbc0014I Cut generator 6 (TwoMirCuts) - 1171 row cuts average 20.0 elements, 0 column cuts (0 active) in 0.068 seconds - new frequency is 1
Cbc0010I After 0 nodes, 1 on tree, 1e+50 best solution, best possible -771.29565 (1.18 seconds)
Cbc0004I Integer solution of -771.29565 found after 2671 iterations and 1 nodes (1.24 seconds)
Cbc0001I Search completed - best objective -771.2956521739131, took 2671 iterations and 1 nodes (1.24 seconds)
Cbc0032I Strong branching done 22 times (542 iterations), fathomed 0 nodes and fixed 0 variables
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from -798.689 to -771.296
Probing was tried 12 times and created 552 cuts of which 0 were active after adding rounds of cuts (0.044 seconds)
Gomory was tried 12 times and created 756 cuts of which 0 were active after adding rounds of cuts (0.116 seconds)
Knapsack was tried 12 times and created 456 cuts of which 0 were active after adding rounds of cuts (0.044 seconds)
Clique was tried 10 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.004 seconds)
MixedIntegerRounding2 was tried 12 times and created 155 cuts of which 0 were active after adding rounds of cuts (0.036 seconds)
FlowCover was tried 10 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.008 seconds)
TwoMirCuts was tried 12 times and created 1197 cuts of which 0 were active after adding rounds of cuts (0.084 seconds)
ImplicationCuts was tried 2 times and created 11 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -771.29565217
Enumerated nodes: 1
Total iterations: 2671
Time (CPU seconds): 1.27
Time (Wallclock seconds): 1.30
最佳答案
通过使用以下代码调用求解器,我能够使用与命令行实用程序中相同的设置:
const char *argv[] = {"", "-solve"};
CbcMain1(2, argv, model);
当然,你可以先设置日志级别,线程数等,这样你就不用从CbcSolver.cpp
中复制代码了,从sascha's answer就可以得出结论了。
关于c++ - Coin-or-CBC 求解器性能 : command line utility vs. 编译的 c++ 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42805239/
我之前让 dll 注入(inject)器变得简单,但我有 Windows 7,我用 C# 和 C++ 做了它,它工作得很好!但是现在当我在 Windows 8 中尝试相同的代码时,它似乎没有以正确的方
我正在尝试制作一个名为 core-splitter 的元素,该元素在 1.0 中已弃用,因为它在我们的项目中起着关键作用。 如果您不知道 core-splitter 的作用,我可以提供一个简短的描述。
我有几个不同的蜘蛛,想一次运行所有它们。基于 this和 this ,我可以在同一个进程中运行多个蜘蛛。但是,我不知道如何设计一个信号系统来在所有蜘蛛都完成后停止 react 器。 我试过了: cra
有没有办法在达到特定条件时停止扭曲 react 器。例如,如果一个变量被设置为某个值,那么 react 器应该停止吗? 最佳答案 理想情况下,您不会将变量设置为一个值并停止 react 器,而是调用
https://code.angularjs.org/1.0.0rc9/angular-1.0.0rc9.js 上面的链接定义了外部js文件,我不知道Angular-1.0.0rc9.js的注入(in
我正在尝试运行一个函数并将服务注入(inject)其中。我认为这可以使用 $injector 轻松完成.所以我尝试了以下(简化示例): angular.injector().invoke( [ "$q
在 google Guice 中,我可以使用函数 createInjector 创建基于多个模块的注入(inject)器。 因为我使用 GWT.create 在 GoogleGin 中实例化注入(in
我在 ASP.NET Core 1.1 解决方案中使用配置绑定(bind)。基本上,我在“ConfigureServices Startup”部分中有一些用于绑定(bind)的简单代码,如下所示: s
我在 Spring MVC 中设置 initBinder 时遇到一些问题。我有一个 ModelAttribute,它有一个有时会显示的字段。 public class Model { privat
我正在尝试通过jquery post发布knockoutjs View 模型 var $form = $('#barcodeTemplate form'); var data = ko.toJS(vm
如何为包含多态对象集合的复杂模型编写自定义模型绑定(bind)程序? 我有下一个模型结构: public class CustomAttributeValueViewModel { publi
您好,我正在尝试实现我在 this article 中找到的扩展方法对于简单的注入(inject)器,因为它不支持开箱即用的特定构造函数的注册。 根据这篇文章,我需要用一个假的委托(delegate)
你好,我想自动注册我的依赖项。 我现在拥有的是: public interface IRepository where T : class public interface IFolderReposi
我正在使用 Jasmine 测试一些 Angular.js 代码。为此,我需要一个 Angular 注入(inject)器: var injector = angular.injector(['ng'
我正在使用 Matlab 代码生成器。不可能包含代码风格指南。这就是为什么我正在寻找一个工具来“ reshape ”、重命名和重新格式化生成的代码,根据我的: 功能横幅约定 文件横幅约定 命名约定 等
这个问题在这里已经有了答案: Where and why do I have to put the "template" and "typename" keywords? (8 个答案) 关闭 8
我开发了一种工具,可以更改某些程序的外观。为此,我需要在某些进程中注入(inject)一个 dll。 现在我基本上使用这个 approach .问题通常是人们无法注入(inject) dll,因为他们
我想使用 swing、spring 和 hibernate 编写一个 java 应用程序。 我想使用数据绑定(bind)器用 bean 的值填充 gui,并且我还希望它反射(reflect) gui
我有这段代码,当两个蜘蛛完成后,程序仍在运行。 #!C:\Python27\python.exe from twisted.internet import reactor from scrapy.cr
要点是 Spring Batch (v2) 测试框架具有带有 @Autowired 注释的 JobLauncherTestUtils.setJob。我们的测试套件有多个 Job 类提供者。因为这个类不
我是一名优秀的程序员,十分优秀!