Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,32 @@ jobs:
name: findMUS-${{ matrix.platform }}
path: findMUS-${{ matrix.triple }}.tar.gz

# The tests exercise the MUS enumeration algorithms only, which do not depend
# on the platform, so one platform is enough. Same container as the linux build.
test:
name: test
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7

- name: Fetch libminizinc + Gecode
shell: bash
run: bash scripts/fetch_minizinc.sh x86_64-linux-gnu

- name: Build & run tests
shell: bash
run: |
set -eux
docker run --rm -v "$PWD:/work" -w /work \
-e ROOT=/work \
-e CMAKE_GENERATOR="Unix Makefiles" \
-e CMAKEDIR="lib64/cmake" \
"quay.io/pypa/manylinux_2_28_x86_64" \
bash scripts/ci_test.sh

publish:
name: publish release
needs: [build, check-version]
needs: [build, test, check-version]
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-24.04
permissions:
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if(POLICY CMP0074)
endif(POLICY CMP0074)

option(BUILD_FINDMUS_EXAMPLES "Build set of cpp example SubProblems" OFF)
option(BUILD_FINDMUS_TESTS "Build the MUS enumeration tests" OFF)
option(MZN_SUPPORTS_SHRINK "Indicate that minizinc supports native shrink" OFF)

message("-- Configuring: C++ options")
Expand Down
1 change: 0 additions & 1 deletion lib/FznSubProblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ void FznSubProblem::init_oracle_model(const string &oraclepath, int ncons,
}

void FznSubProblem::init_fzn_model(const string &fznpath) {
MiniZinc::GCLock lock;
vector<string> includes;

includes.push_back(mopts.mzn_stdlib_dir + "/std/");
Expand Down
8 changes: 5 additions & 3 deletions lib/ReMUS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,19 @@ bool ReMUS::search() {
} else {
subsetMap->blockSubsets(s_max);
Selection s_mcs = state.S.get_diff(s_max);
// Count the included nodes, not the selected ones: when state.S selects a
// parent (e.g. the root), the difference still selects only that parent.
const NodeSet& s_mcs_included = s_mcs.const_included().get_nodes();

if (s_mcs.size() == 1) {
state.criticals.insert((*s_mcs.const_included().begin()).child);
if (s_mcs_included.size() == 1) {
state.criticals.insert(*s_mcs_included.begin());

std::stringstream ss;
ss << indent << "ReMUS: updated crits: {" << state.criticals << " }";
log(ss.str());
} else {
// We are aboute to modify remus_stack so we need a copy of criticals
NodeSet criticals_copy = state.criticals;
const NodeSet& s_mcs_included = s_mcs.const_included().get_nodes();
vector<const MapNode *>::const_reverse_iterator rit;
for (rit = s_mcs_included.rbegin(); rit != s_mcs_included.rend(); ++rit) {
const MapNode *n = *rit;
Expand Down
24 changes: 24 additions & 0 deletions scripts/ci_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Configure and build the findMUS tests against the libminizinc SDK and Gecode
# already in $ROOT (see fetch_minizinc.sh), then run them.
#
# Env: ROOT, CMAKE_GENERATOR, CMAKEDIR (as for ci_build.sh)
set -eux

: "${ROOT:?ROOT must be set}"
: "${CMAKEDIR:?CMAKEDIR must be set}"

# Debug, so the enumerators' assertions are checked too.
cmake -S "$ROOT" -B "$ROOT/build" -G "${CMAKE_GENERATOR:-Ninja}" \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_FINDMUS_TESTS=ON \
-DUSE_SYSTEM_LIBMINIZINC=1 \
-Dlibminizinc_DIR="$ROOT/minizinc/${CMAKEDIR}/libminizinc" \
-DGecode_ROOT="$ROOT/vendor/gecode" \
-DOsiCBC_ROOT="$ROOT/vendor/cbc"
cmake --build "$ROOT/build" --target tests

# The tests find their specs relative to the build directory, and option
# parsing needs a standard library even though the tests never use it.
cd "$ROOT/build"
MZN_STDLIB_DIR="$ROOT/minizinc/share/minizinc" ./tests
4 changes: 2 additions & 2 deletions tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool run_test(size_t id, const vector<string> &args, string path) {
return result == "PASS";
}

int run_tests(vector<size_t> ids) {
bool run_tests(vector<size_t> ids) {
vector<vector<string>> test_args = {
{"-t", "1000", "--paramset", "fzn", "--no-binarize", "--structure", "flat", "--shrink-alg", "map_lin"},
{"-t", "1000", "--paramset", "fzn", "--structure", "flat", "--shrink-alg", "map_lin"},
Expand Down Expand Up @@ -140,5 +140,5 @@ int main(int argc, char **argv) {
i++;
}

return HierMUS::run_tests(ids);
return HierMUS::run_tests(ids) ? EXIT_SUCCESS : EXIT_FAILURE;
}
Loading