本文整理汇总了C++中SparseOptimizer::isSolverSuitable方法的典型用法代码示例。如果您正苦于以下问题:C++ SparseOptimizer::isSolverSuitable方法的具体用法?C++ SparseOptimizer::isSolverSuitable怎么用?C++ SparseOptimizer::isSolverSuitable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseOptimizer
的用法示例。
在下文中一共展示了SparseOptimizer::isSolverSuitable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
bool MainWindow::load(const QString& filename)
{
ifstream ifs(filename.toStdString().c_str());
if (! ifs)
return false;
viewer->graph->clear();
bool loadStatus = viewer->graph->load(ifs);
if (! loadStatus)
return false;
_lastSolver = -1;
viewer->setUpdateDisplay(true);
SparseOptimizer* optimizer = viewer->graph;
// update the solvers which are suitable for this graph
set<int> vertDims = optimizer->dimensions();
for (size_t i = 0; i < _knownSolvers.size(); ++i) {
const OptimizationAlgorithmProperty& sp = _knownSolvers[i];
if (sp.name == "" && sp.desc == "")
continue;
bool suitableSolver = optimizer->isSolverSuitable(sp, vertDims);
qobject_cast<QStandardItemModel *>(coOptimizer->model())->item(i)->setEnabled(suitableSolver);
}
return loadStatus;
}
示例2: main
//.........这里部分代码省略.........
if (loadLookup.size() > 0) {
optimizer.setRenamedTypesFromString(loadLookup);
}
if (inputFilename.size() == 0) {
cerr << "No input data specified" << endl;
return 0;
} else if (inputFilename == "-") {
cerr << "Read input from stdin" << endl;
if (!optimizer.load(cin)) {
cerr << "Error loading graph" << endl;
return 2;
}
} else {
cerr << "Read input from " << inputFilename << endl;
ifstream ifs(inputFilename.c_str());
if (!ifs) {
cerr << "Failed to open file" << endl;
return 1;
}
if (!optimizer.load(ifs)) {
cerr << "Error loading graph" << endl;
return 2;
}
}
cerr << "Loaded " << optimizer.vertices().size() << " vertices" << endl;
cerr << "Loaded " << optimizer.edges().size() << " edges" << endl;
if (optimizer.vertices().size() == 0) {
cerr << "Graph contains no vertices" << endl;
return 1;
}
set<int> vertexDimensions = optimizer.dimensions();
if (! optimizer.isSolverSuitable(solverProperty, vertexDimensions)) {
cerr << "The selected solver is not suitable for optimizing the given graph" << endl;
return 3;
}
assert (optimizer.solver());
//optimizer.setMethod(str2method(strMethod));
//optimizer.setUserLambdaInit(lambdaInit);
// check for vertices to fix to remove DoF
bool gaugeFreedom = optimizer.gaugeFreedom();
OptimizableGraph::Vertex* gauge=0;
if (gaugeList.size()){
cerr << "Fixing gauges: ";
for (size_t i=0; i<gaugeList.size(); i++){
int id=gaugeList[i];
OptimizableGraph::Vertex* v=optimizer.vertex(id);
if (!v){
cerr << "fatal, not found the vertex of id " << id << " in the gaugeList. Aborting";
return -1;
} else {
if (i==0)
gauge = v;
cerr << v->id() << " ";
v->setFixed(1);
}
}
cerr << endl;
gaugeFreedom = false;
} else {
gauge=optimizer.findGauge();
}
if (gaugeFreedom) {