From 1c70b9e6ee46634968ab7236c54ffae3cd49bc0c Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Thu, 19 Mar 2026 12:31:24 -1000 Subject: [PATCH] fix box mode: isolate m_lower/m_upper between objectives geometric_lex's update_lower_lex updates m_lower for all subsequent objectives with saved values from the current model. In box mode this contaminates later objectives' starting bounds, causing platform-dependent results. Save and restore m_lower/m_upper across iterations so each objective starts from a clean state. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/opt/optsmt.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/opt/optsmt.cpp b/src/opt/optsmt.cpp index 29fc2961b..73a6f1c02 100644 --- a/src/opt/optsmt.cpp +++ b/src/opt/optsmt.cpp @@ -544,16 +544,29 @@ namespace opt { // Note: geometric_lex is used unconditionally here, even when // m_optsmt_engine is "symba", because symba_opt and geometric_opt // optimize all objectives jointly, violating box mode semantics. + // + // Save and restore m_lower/m_upper across iterations because + // geometric_lex's update_lower_lex updates m_lower for all + // subsequent objectives with saved values from the current model, + // which would contaminate later objectives' starting bounds. + vector saved_lower(m_lower); + vector saved_upper(m_upper); m_context.get_base_model(m_best_model); for (unsigned i = 0; i < m_vars.size() && m.inc(); ++i) { + m_lower = saved_lower; + m_upper = saved_upper; solver::scoped_push _push(*m_s); is_sat = geometric_lex(i, true, true); if (is_sat == l_undef) return l_undef; if (is_sat == l_false) return l_false; + saved_lower[i] = m_lower[i]; + saved_upper[i] = m_upper[i]; m_models.set(i, m_best_model.get()); } + m_lower = saved_lower; + m_upper = saved_upper; return l_true; }