MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / loadLegacy

Method loadLegacy

MiniZincIDE/solver.cpp:429–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427}
428
429SolverConfiguration SolverConfiguration::loadLegacy(const QJsonDocument &json, QStringList& warnings)
430{
431 auto sco = json.object();
432
433 Solver* solver = nullptr;
434 try {
435 solver = &Solver::lookup(sco["id"].toString(), sco["version"].toString(), false);
436 } catch (Exception& e) {
437 warnings << e.message();
438 warnings << "Using default solver instead.";
439 solver = MznDriver::get().defaultSolver();
440 }
441
442 if (solver == nullptr) {
443 throw ConfigError("Failed to load fallback solver.");
444 }
445
446 SolverConfiguration newSc(*solver);
447// if (sco["name"].isString()) {
448// newSc.name = sco["name"].toString();
449// }
450 if (sco["timeLimit"].isDouble()) {
451 newSc.timeLimit = sco["timeLimit"].toInt();
452 }
453// if (sco["defaultBehavior"].isBool()) {
454// newSc.defaultBehaviour = sco["defaultBehavior"].toBool();
455// }
456 if (sco["printIntermediate"].isBool()) {
457 newSc.printIntermediate = sco["printIntermediate"].toBool();
458 }
459 if (sco["stopAfter"].isDouble()) {
460 newSc.numSolutions = sco["stopAfter"].toInt();
461 }
462 if (sco["verboseFlattening"].isBool()) {
463 newSc.verboseCompilation = sco["verboseFlattening"].toBool();
464 }
465 if (sco["flatteningStats"].isBool()) {
466 newSc.compilationStats = sco["flatteningStats"].toBool();
467 }
468 if (sco["optimizationLevel"].isDouble()) {
469 newSc.optimizationLevel = sco["optimizationLevel"].toInt();
470 }
471 if (sco["additionalData"].isString() && !sco["additionalData"].toString().isEmpty()) {
472 newSc.additionalData << sco["additionalData"].toString();
473 }
474 if (sco["additionalCompilerCommandline"].isString() && !sco["additionalCompilerCommandline"].toString().isEmpty()) {
475 parseArgList(sco["additionalCompilerCommandline"].toString(), newSc.extraOptions);
476 }
477 if (sco["nThreads"].isDouble()) {
478 newSc.numThreads = sco["nThreads"].toInt();
479 }
480 if (sco["randomSeed"].isDouble()) {
481 newSc.randomSeed = sco["randomSeed"].toDouble();
482 }
483 if (sco["solverFlags"].isString() && !sco["solverFlags"].toString().isEmpty()) {
484 parseArgList(sco["solverFlags"].toString(), newSc.solverBackendOptions);
485 }
486 if (sco["freeSearch"].isBool()) {

Callers

nothing calls this directly

Calls 9

ConfigErrorClass · 0.85
parseArgListFunction · 0.85
defaultSolverMethod · 0.80
containsMethod · 0.80
removeMethod · 0.80
toStringMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected