From 35df1dbe71ce14fff82f73c76ed912f88b3737bc Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Tue, 7 Jul 2026 09:59:09 +0200 Subject: [PATCH 1/3] flatzinc: include upper bound in restart uniform values --- changelog.in | 10 ++++++++++ gecode/flatzinc/flatzinc.cpp | 15 +++++++++++++-- test/flatzinc/on_restart_last_val_int.cpp | 16 ++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/changelog.in b/changelog.in index 3daea2feb3..68ef737fd2 100755 --- a/changelog.in +++ b/changelog.in @@ -75,6 +75,16 @@ This release modernizes the Gecode build infrastructure, adds a first-class CMake package for downstream consumers, refreshes the autoconf build path, and updates CI coverage for current platforms. +[ENTRY] +Module: flatzinc +What: bug +Rank: minor +Issue: 207 +Thanks: Nathan Tran +[DESCRIPTION] +Include the upper endpoint when generating FlatZinc on_restart +uniform integer and float values. + [ENTRY] Module: other What: change diff --git a/gecode/flatzinc/flatzinc.cpp b/gecode/flatzinc/flatzinc.cpp index 05a6b08a6f..eb7a2d9da3 100644 --- a/gecode/flatzinc/flatzinc.cpp +++ b/gecode/flatzinc/flatzinc.cpp @@ -5,10 +5,12 @@ * * Contributing authors: * Gabriel Hjort Blindell + * Nathan Tran * * Copyright: * Guido Tack, 2007-2012 * Gabriel Hjort Blindell, 2012 + * Nathan Tran, 2025 * * This file is part of Gecode, the generic constraint * development environment: @@ -2040,7 +2042,13 @@ namespace Gecode { namespace FlatZinc { // Assign uniform_int random values for (size_t i = 0; i < restart_data().uniform_range_int.size(); ++i) { const auto& range = restart_data().uniform_range_int[i]; - const int rndVal = range.first + _random(static_cast(range.second - range.first)); + const unsigned long long int width = + static_cast( + static_cast(range.second) - + static_cast(range.first)) + 1ULL; + const int rndVal = + static_cast(static_cast(range.first) + + static_cast(_random(width))); rel(*this, on_restart_iv[base + i], IRT_EQ, rndVal); } base += restart_data().uniform_range_int.size(); @@ -2164,7 +2172,10 @@ namespace Gecode { namespace FlatZinc { for (size_t i = 0; i < restart_data().uniform_range_float.size(); ++i) { const auto& range = restart_data().uniform_range_float[i]; /* rndVal will be an element of [range.first, range.second] */ - const FloatVal rndVal = (static_cast(_random(INT_MAX)) / INT_MAX)*(range.second - range.first) + range.first; + const FloatVal rndVal = + (static_cast(_random(INT_MAX)) / + static_cast(INT_MAX - 1)) * + (range.second - range.first) + range.first; rel(*this, on_restart_fv[base + i], FRT_EQ, rndVal); } base += restart_data().uniform_range_float.size(); diff --git a/test/flatzinc/on_restart_last_val_int.cpp b/test/flatzinc/on_restart_last_val_int.cpp index 5406e359b6..10747a06d3 100644 --- a/test/flatzinc/on_restart_last_val_int.cpp +++ b/test/flatzinc/on_restart_last_val_int.cpp @@ -3,8 +3,12 @@ * Main authors: * Jip J. Dekker * + * Contributing authors: + * Nathan Tran + * * Copyright: * Jip J. Dekker, 2023 + * Nathan Tran, 2025 * * This file is part of Gecode, the generic constraint * development environment: @@ -80,6 +84,18 @@ y = 3; ---------- ========== )OUT", true, {"--restart", "constant", "--restart-base", "100"}); + + (void) new FlatZincTest("on_restart::uniform_int_upper_bound", +R"FZN( +predicate gecode_on_restart_uniform_int(int: low,int: high,var int: out); +var 0..1: y:: output_var; +constraint gecode_on_restart_uniform_int(0,1,y); +constraint int_eq(y,1); +solve satisfy; +)FZN", +R"OUT(y = 1; +---------- +)OUT", true, {"--restart", "constant", "--restart-base", "100", "--seed", "2"}); } }; From ea6bd262307a371878df602df15f6274ccf9f465 Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Tue, 7 Jul 2026 09:59:52 +0200 Subject: [PATCH 2/3] cmake: preserve config.hpp mtime when unchanged --- CMakeLists.txt | 2 +- changelog.in | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f4f5c8c56..ae8233e12e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -559,7 +559,7 @@ foreach(i RANGE ${length}) set(CONFIG_OUT "${CONFIG_OUT}${line}") endforeach() -file(WRITE ${GECODE_BINARY_DIR}/gecode/support/config.hpp +file(CONFIGURE OUTPUT "${GECODE_BINARY_DIR}/gecode/support/config.hpp" CONTENT "/* gecode/support/config.hpp. Generated from config.hpp.in by configure. */ /* gecode/support/config.hpp.in. Generated from configure.ac by autoheader. */ diff --git a/changelog.in b/changelog.in index 68ef737fd2..697dff9cbe 100755 --- a/changelog.in +++ b/changelog.in @@ -85,6 +85,16 @@ Thanks: Nathan Tran Include the upper endpoint when generating FlatZinc on_restart uniform integer and float values. +[ENTRY] +Module: other +What: change +Rank: minor +Issue: 203 +Thanks: Bruce Mitchener +[DESCRIPTION] +Avoid rewriting the generated CMake config.hpp file when its +contents have not changed. + [ENTRY] Module: other What: change From 52e7576052393d39037c127a6271619ae33f484f Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Tue, 7 Jul 2026 10:01:20 +0200 Subject: [PATCH 3/3] search: notify cpprofiler before disconnecting --- changelog.in | 10 ++++++++++ gecode/search/cpprofiler/tracer.cpp | 3 +++ 2 files changed, 13 insertions(+) diff --git a/changelog.in b/changelog.in index 697dff9cbe..605516f3ce 100755 --- a/changelog.in +++ b/changelog.in @@ -95,6 +95,16 @@ Thanks: Bruce Mitchener Avoid rewriting the generated CMake config.hpp file when its contents have not changed. +[ENTRY] +Module: search +What: bug +Rank: minor +Issue: 150 +Thanks: Stefan Brüns +[DESCRIPTION] +Send CPProfiler's DONE message before disconnecting from the +profiler socket. + [ENTRY] Module: other What: change diff --git a/gecode/search/cpprofiler/tracer.cpp b/gecode/search/cpprofiler/tracer.cpp index bd27ffa79f..64ada79e70 100644 --- a/gecode/search/cpprofiler/tracer.cpp +++ b/gecode/search/cpprofiler/tracer.cpp @@ -6,11 +6,13 @@ * Contributing authors: * Kevin Leo * Christian Schulte + * Stefan Brüns * * Copyright: * Kevin Leo, 2017 * Christian Schulte, 2017 * Maxim Shishmarev, 2017 + * Stefan Brüns, 2022 * * This file is part of Gecode, the generic constraint * development environment: @@ -146,6 +148,7 @@ namespace Gecode { void CPProfilerSearchTracer::done(void) { + connector->done(); connector->disconnect(); }