本文整理汇总了C++中OsiClpSolverInterface::loadFromCoinModel方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiClpSolverInterface::loadFromCoinModel方法的具体用法?C++ OsiClpSolverInterface::loadFromCoinModel怎么用?C++ OsiClpSolverInterface::loadFromCoinModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiClpSolverInterface
的用法示例。
在下文中一共展示了OsiClpSolverInterface::loadFromCoinModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solve
// nothing to inherit from GC really
ColoredGraph solve(const Graph& gr) override {
CoinModel coinModel;
for (auto i = 0; i < gr.nodeCount(); ++i) {
coinModel.addCol(0, nullptr, nullptr, 0, gr.nodeCount()-1, 1, nullptr, true);
}
OsiClpSolverInterface solver;
solver.loadFromCoinModel(coinModel);
CbcModel model(solver);
model.setLogLevel(0);
model.passInEventHandler(make_unique<GC_LP_EventHandler>(recoveryPath).get());
if (use_heuristic) {
GC_LP_Heuristic heuristic;
model.addHeuristic(&heuristic);
}
AddRules(model, gr);
if (use_parallel) {
model.setNumberThreads(std::thread::hardware_concurrency());
}
if (max_seconds != 0) model.setMaximumSeconds(max_seconds);
model.initialSolve();
model.branchAndBound();
if (model.maximumSecondsReached()) Println(cout, "max seconds reached");
if (model.isSecondsLimitReached()) Println(cout, "seconds limit reached");
seconds_passed_ = model.getCurrentSeconds();
iterations_passed_ = model.getIterationCount();
const double *solution = model.bestSolution();
if (solution == nullptr) {
vector<Color> colors(gr.nodeCount());
iota(colors.begin(), colors.end(), 0);
return {gr, colors};
}
return ColoredGraph(gr, {solution, solution+gr.nodeCount()});
}