Skip to content

Commit

Permalink
Merge branch 'latest' into fix-2109
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Jan 9, 2025
2 parents 820fd54 + e47af56 commit 98ccd38
Show file tree
Hide file tree
Showing 16 changed files with 1,200 additions and 170 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,14 @@ jobs:
# ubuntu 22 has a latest version of cmake, but setup-python
# does not seem to provide all necessary modules to find python
# from cmake. works on my machine, test the wheels manually
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
# strategy:
# matrix:
# python: [3.12]

- name: Install correct python version
uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python }}
with:
python-version: '3.10'

- name: Build wheel
run: |
Expand Down
78 changes: 39 additions & 39 deletions .github/workflows/build-wheels-push.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: build-wheels-push

on: []
# on: []
# on: push

# on:
# release:
# types:
# - published
on:
release:
types:
- published

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -82,51 +82,22 @@ jobs:
name: cibw-wheels-${{ matrix.python }}-${{ matrix.buildplat[1] }}
path: wheelhouse/*.whl

upload_testpypi:
name: >-
Publish highspy to TestPyPI
runs-on: ubuntu-latest
needs: [build_wheels, build_sdist]
# needs: [build_sdist]

# upload to PyPI on every tag starting with 'v'
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

environment:
name: testpypi
url: https://test.pypi.org/p/highspy

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true

- name: Download all
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
verbose: true

# upload_pypi:
# upload_testpypi:
# name: >-
# Publish highspy to PyPI
# Publish highspy to TestPyPI
# runs-on: ubuntu-latest
# needs: [build_wheels, build_sdist]
# # needs: [build_sdist]

# # upload to PyPI on every tag starting with 'v'
# # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

# environment:
# name: pypi
# url: https://pypi.org/p/highspy
# name: testpypi
# url: https://test.pypi.org/p/highspy

# permissions:
# id-token: write # IMPORTANT: mandatory for trusted publishing

# steps:
# - uses: actions/download-artifact@v4
# with:
Expand All @@ -136,3 +107,32 @@ jobs:

# - name: Download all
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
# verbose: true

upload_pypi:
name: >-
Publish highspy to PyPI
runs-on: ubuntu-latest
needs: [build_wheels, build_sdist]

# upload to PyPI on every tag starting with 'v'
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

environment:
name: pypi
url: https://pypi.org/p/highspy

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true

- name: Download all
uses: pypa/gh-action-pypi-publish@release/v1
67 changes: 67 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: code-coverage

on: [push, pull_request]

jobs:
debug:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4

- name: install
run: sudo apt-get update && sudo apt-get install lcov

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DHIGHS_COVERAGE=ON -DALL_TESTS=ON -DBUILD_SHARED_LIBS=OFF -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++

- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
run: |
cmake --build . --parallel --config Debug
- name: Test
working-directory: ${{runner.workspace}}/build
shell: bash
run: ctest --parallel --timeout 300 --output-on-failure

- name: Generate Report
working-directory: ${{runner.workspace}}/build
shell: bash
run: |
lcov -d . -c -o cov.info --ignore-errors empty
lcov --remove cov.info "/usr/include/*" -o cov.info
lcov --remove cov.info "/usr/lib/*" -o cov.info
lcov --remove cov.info "extern/pdqsort/*" -o cov.info
lcov --remove cov.info "extern/zstr/*" -o cov.info
lcov --remove cov.info "extern/catch*" -o cov.info
lcov --remove cov.info "app/cxxopts*" -o cov.info
lcov --remove cov.info "src/test*" -o cov.info
lcov --list cov.info
- name: Genhtml Results Summary
working-directory: ${{runner.workspace}}/build
shell: bash
run: |
genhtml -o coverage cov.info
# Made it past the first token issue.
# May need some more time to porpagate on the codecov side.
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v5
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# slug: ERGO-Code/HiGHS
# fail_ci_if_error: true # optional (default = false)
# files: ${{runner.workspace}}/build/cov.info # optional
# # name: codecov-umbrella # optional
# verbose: true # optional (default = false)
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ pip-log.txt

# Unit test / coverage reports
.coverage
cov.info
.tox

#Translations
Expand Down
78 changes: 67 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ if (PYTHON_BUILD_SETUP)
set(ZLIB OFF)
endif()

option(HIGHS_COVERAGE "Activate the code coverage compilation" OFF)

# Address | Thread | Leak
# Linux atm
# Only Debug is theted atm
Expand Down Expand Up @@ -328,16 +330,18 @@ if(NOT FAST_BUILD)
endif()

include(CheckCXXCompilerFlag)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(ppc64|powerpc64)" AND NOT APPLE)
check_cxx_compiler_flag("-mpopcntd" COMPILER_SUPPORTS_POPCNTD)
if(COMPILER_SUPPORTS_POPCNTD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcntd")
endif()
else()
check_cxx_compiler_flag("-mpopcnt" COMPILER_SUPPORTS_POPCNT)
if(COMPILER_SUPPORTS_POPCNT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
endif()
if (NOT HIGHS_COVERAGE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(ppc64|powerpc64)" AND NOT APPLE)
check_cxx_compiler_flag("-mpopcntd" COMPILER_SUPPORTS_POPCNTD)
if(COMPILER_SUPPORTS_POPCNTD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcntd")
endif()
else()
check_cxx_compiler_flag("-mpopcnt" COMPILER_SUPPORTS_POPCNT)
if(COMPILER_SUPPORTS_POPCNT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
endif()
endif()
endif()

option(DEBUGSOL "check the debug solution" OFF)
Expand Down Expand Up @@ -473,6 +477,58 @@ elseif (DEBUG_MEMORY STREQUAL "Leak")
-fno-omit-frame-pointer ")
endif()

# HiGHS coverage update in progress
if(FAST_BUILD AND HIGHS_COVERAGE)
if(WIN32)
message(FATAL_ERROR "Error: code coverage analysis is only available under Linux for now.")
endif()

if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR "Warning: to enable coverage, you must compile in Debug mode")
endif()

# Disable IPO
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
message(STATUS "Building in coverage mode")

# Enable coverage flags
add_compile_options(-O0)
add_compile_options(--coverage)
add_compile_options(-fprofile-update=atomic)

add_link_options(-O0)
add_link_options(--coverage) # Ensure coverage data is linked correctly

find_program(GCOV_PATH gcov)
find_program(LCOV_PATH lcov)
find_program(GENHTML_PATH genhtml)

if(NOT GCOV_PATH)
message(FATAL_ERROR "gcov not found! Please install lcov and gcov. Aborting...")
endif()

if(NOT LCOV_PATH)
message(FATAL_ERROR "lcov not found! Please install lcov and gcov. Aborting...")
endif()

if(NOT GENHTML_PATH)
message(FATAL_ERROR "genhtml not found! Please install lcov and gcov. Aborting...")
endif()

# add_custom_target(coverage
# COMMAND ${LCOV_PATH} -d bin -c -o cov.info --ignore-errors empty
# COMMAND ${LCOV_PATH} --remove "*/usr/include/*" -o ${CMAKE_BINARY_DIR}/cov.info.cleaned
# COMMAND ${LCOV_PATH} --remove "*/usr/lib/*" -o ${CMAKE_BINARY_DIR}/cov.info.cleaned
# COMMAND ${LCOV_PATH} --remove "extern/pdqsort/*" -o ${CMAKE_BINARY_DIR}/cov.info.cleaned
# COMMAND ${LCOV_PATH} --remove "extern/zstr/*" -o ${CMAKE_BINARY_DIR}/cov.info.cleaned
# COMMAND ${LCOV_PATH} --remove "app/cxxopts*" -o ${CMAKE_BINARY_DIR}/cov.info.cleaned
# COMMAND ${GENHTML_PATH} ${CMAKE_BINARY_DIR}/cov.info.cleaned -o ${CMAKE_BINARY_DIR}/cov_report
# VERBATIM
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
# COMMENT "Generating code coverage report v2025.")

endif()

if(NOT FAST_BUILD)
# For the moment keep above coverage part in case we are testing at CI.
option(CI "CI extended tests" ON)
Expand All @@ -495,7 +551,7 @@ if(NOT FAST_BUILD)
endif()

if(HIGHS_COVERAGE)
if(NOT CMAKE_BUILD_TYPE STREQUAL "DEBUG")
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT CMAKE_BUILD_TYPE STREQUAL "DEBUG")
message(FATAL_ERROR "Warning: to enable coverage, you must compile in DEBUG mode")
endif()
endif()
Expand Down
5 changes: 5 additions & 0 deletions FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ Added basis solve methods to highspy

Added methods to get primal/dual ray and dual unboundedness direction to highspy

When a presolved LP has model status kUnknown, rather than returning this to the user, it performs postsolve and then uses the basis to solve the original LP

Fixed bug in presolve when pointers stored in HighsMatrixSlice get invalidated when the coefficient matrix is reallocated (e.g. when non-zeros are added in HPresolve::addToMatrix)

Primal and dual residual tolerances - applied following IPM or PDLP solution - now documented as options

2 changes: 1 addition & 1 deletion app/RunHighs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main(int argc, char** argv) {
// call this first so that printHighsVersionCopyright uses reporting
// settings defined in any options file.
highs.passOptions(loaded_options);
// highs.writeOptions("Options.md");
highs.writeOptions("Options.md");

// Load the model from model_file
HighsStatus read_status = highs.readModel(model_file);
Expand Down
38 changes: 21 additions & 17 deletions check/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,29 @@ if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY))
add_test(NAME capi_unit_tests COMMAND capi_unit_tests)

# Check whether test executable builds OK.
add_test(NAME unit-test-build
COMMAND ${CMAKE_COMMAND}
--build ${HIGHS_BINARY_DIR}
--target unit_tests
# --config ${CMAKE_BUILD_TYPE}
)

if (NOT HIGHS_COVERAGE)
add_test(NAME unit-test-build
COMMAND ${CMAKE_COMMAND}
--build ${HIGHS_BINARY_DIR}
--target unit_tests
# --config ${CMAKE_BUILD_TYPE}
)

# Avoid that several build jobs try to concurretly build.
set_tests_properties(unit-test-build
PROPERTIES
RESOURCE_LOCK unittestbin)
# Avoid that several build jobs try to concurretly build.
set_tests_properties(unit-test-build
PROPERTIES
RESOURCE_LOCK unittestbin)

# create a binary running all the tests in the executable
add_test(NAME unit_tests_all COMMAND unit_tests --success)
set_tests_properties(unit_tests_all
PROPERTIES
DEPENDS unit-test-build)
set_tests_properties(unit_tests_all PROPERTIES TIMEOUT 10000)
# create a binary running all the tests in the executable
add_test(NAME unit_tests_all COMMAND unit_tests --success)
set_tests_properties(unit_tests_all
PROPERTIES
DEPENDS unit-test-build)
set_tests_properties(unit_tests_all PROPERTIES TIMEOUT 10000)
else()
add_test(NAME unit_tests_all COMMAND unit_tests --success)
set_tests_properties(unit_tests_all PROPERTIES TIMEOUT 10000)
endif()

# An individual test can be added with the command below but the approach
# above with a single add_test for all the unit tests automatically detects all
Expand Down
10 changes: 10 additions & 0 deletions check/TestPresolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,3 +639,13 @@ TEST_CASE("presolve-slacks", "[highs_test_presolve]") {
REQUIRE(h.getPresolvedLp().num_col_ == 2);
REQUIRE(h.getPresolvedLp().num_row_ == 2);
}

TEST_CASE("presolve-issue-2095", "[highs_test_presolve]") {
std::string model_file =
std::string(HIGHS_DIR) + "/check/instances/issue-2095.mps";
Highs highs;
highs.setOptionValue("output_flag", dev_run);
highs.readModel(model_file);
REQUIRE(highs.presolve() == HighsStatus::kOk);
REQUIRE(highs.getModelPresolveStatus() == HighsPresolveStatus::kReduced);
}
Loading

0 comments on commit 98ccd38

Please sign in to comment.