From 91847194b14b96cab1769e46a86d0b4b73f2b956 Mon Sep 17 00:00:00 2001 From: Jason N Date: Fri, 10 Nov 2023 15:35:43 +1100 Subject: [PATCH] Add option for outputting objective and enable by default --- MiniZincIDE/configwindow.cpp | 2 ++ MiniZincIDE/configwindow.ui | 39 +++++++++++++++++++++--------------- MiniZincIDE/solver.cpp | 9 +++++++++ MiniZincIDE/solver.h | 1 + 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/MiniZincIDE/configwindow.cpp b/MiniZincIDE/configwindow.cpp index 0309382..01b8136 100644 --- a/MiniZincIDE/configwindow.cpp +++ b/MiniZincIDE/configwindow.cpp @@ -444,6 +444,7 @@ void ConfigWindow::updateGUI(bool overrideSync) } ui->timingInfo_checkBox->setChecked(sc->outputTiming); + ui->outputObjective_checkBox->setChecked(sc->outputObjective); } ui->numSolutions_spinBox->setEnabled(ui->numSolutions_checkBox->isEnabled() && ui->numSolutions_checkBox->isChecked()); @@ -527,6 +528,7 @@ void ConfigWindow::updateSolverConfig(SolverConfiguration* sc) s->compilationStats = ui->compilationStats_checkBox->isChecked(); s->solvingStats = ui->solvingStats_checkBox->isChecked(); s->outputTiming = ui->timingInfo_checkBox->isChecked(); + s->outputObjective = ui->outputObjective_checkBox->isChecked(); } sc->optimizationLevel = ui->optimizationLevel_comboBox->currentIndex(); diff --git a/MiniZincIDE/configwindow.ui b/MiniZincIDE/configwindow.ui index a904b67..f25279f 100644 --- a/MiniZincIDE/configwindow.ui +++ b/MiniZincIDE/configwindow.ui @@ -396,6 +396,16 @@ + + + + <html><head/><body><p>Output solving statistics with <span style=" font-family:'monospace';">--solver-statistics</span></p></body></html> + + + Output solving statistics + + + @@ -406,13 +416,6 @@ - - - - Qt::Horizontal - - - @@ -423,23 +426,27 @@ - - + + - <html><head/><body><p>Output solving statistics with <span style=" font-family:'monospace';">--solver-statistics</span></p></body></html> + <html><head/><body><p>Output timing information with <span style=" font-family:'monospace';">--output-time</span></p></body></html> - Output solving statistics + Output timing information - - - - <html><head/><body><p>Output timing information with <span style=" font-family:'monospace';">--output-time</span></p></body></html> + + + + Qt::Horizontal + + + + - Output timing information + Output objective value diff --git a/MiniZincIDE/solver.cpp b/MiniZincIDE/solver.cpp index afd16cd..56098fa 100644 --- a/MiniZincIDE/solver.cpp +++ b/MiniZincIDE/solver.cpp @@ -269,6 +269,7 @@ SolverConfiguration::SolverConfiguration(const Solver& _solver, bool builtin) : compilationStats(false), solvingStats(false), outputTiming(false), + outputObjective(true), optimizationLevel(1), numThreads(1), freeSearch(false), @@ -351,6 +352,8 @@ SolverConfiguration SolverConfiguration::loadJSON(const QJsonDocument& json, QSt sc.solvingStats = it.value().toBool(); } else if (key == "--output-time") { sc.outputTiming = it.value().toBool(); + } else if (key == "--output-objective") { + sc.outputObjective = it.value().toBool(); } else if (key == "-O0" && it.value().toBool()) { sc.optimizationLevel = 0; } else if (key == "-O1" && it.value().toBool()) { @@ -558,6 +561,7 @@ QJsonObject SolverConfiguration::toJSONObject(void) const if (outputTiming) { config["output-time"] = outputTiming; } + config["output-objective"] = outputObjective; if (optimizationLevel != 1) { config["-O"] = optimizationLevel; } @@ -655,6 +659,10 @@ bool SolverConfiguration::syncedOptionsMatch(const SolverConfiguration& sc) cons return false; } + if (outputObjective != sc.outputObjective) { + return false; + } + return true; } @@ -677,6 +685,7 @@ bool SolverConfiguration::operator==(const SolverConfiguration& sc) const compilationStats == sc.compilationStats && solvingStats == sc.solvingStats && outputTiming == sc.outputTiming && + outputObjective == sc.outputObjective && optimizationLevel == sc.optimizationLevel && additionalData == sc.additionalData && numThreads == sc.numThreads && diff --git a/MiniZincIDE/solver.h b/MiniZincIDE/solver.h index a6b528e..dd7b4c4 100644 --- a/MiniZincIDE/solver.h +++ b/MiniZincIDE/solver.h @@ -80,6 +80,7 @@ class SolverConfiguration { bool compilationStats; bool solvingStats; bool outputTiming; + bool outputObjective; int optimizationLevel; QStringList additionalData; int numThreads;