Skip to content

Commit

Permalink
Merge branch 'latest' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
merschformann authored Jan 30, 2025
2 parents f760172 + 38bc501 commit 477a9a6
Show file tree
Hide file tree
Showing 96 changed files with 4,910 additions and 2,761 deletions.
1 change: 0 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
common --noenable_bzlmod
4 changes: 2 additions & 2 deletions .github/workflows/build-bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
run: bazel clean

- name: build bazel
run: bazel build --enable_bzlmod //...
run: bazel build //...

- name: test all
run: bazel test --enable_bzlmod //...
run: bazel test //...

- name: test example
run: ./bazel-bin/call-highs-example
9 changes: 3 additions & 6 deletions .github/workflows/build-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,10 @@ jobs:
python -m pytest
build_wheel_linux:
# 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
strategy:
matrix:
python: [3.12]
python: [3.11]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -110,7 +107,7 @@ jobs:
runs-on: ubuntu-24.04-arm
strategy:
matrix:
python: [3.12]
python: [3.11]
steps:
- uses: actions/checkout@v4

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
68 changes: 68 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: code-coverage

on: [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
mv cov.info coverage.info
- name: Genhtml Results Summary
working-directory: ${{runner.workspace}}/build
shell: bash
run: |
genhtml -o coverage coverage.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/coverage.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
86 changes: 75 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 @@ -187,6 +189,14 @@ if (BUILD_CXX)
option(STDCALL "Build highs with the __stdcall convention" OFF)
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11")
endif()

# Basic type
include(CMakePushCheckState)
cmake_push_check_state(RESET)
Expand Down Expand Up @@ -320,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 AND NOT APPLE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(ppc64|powerpc64)")
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)
add_compile_options(-mpopcnt)
endif()
endif()
endif()

option(DEBUGSOL "check the debug solution" OFF)
Expand Down Expand Up @@ -465,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 @@ -487,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
17 changes: 11 additions & 6 deletions FEATURES.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
## Build changes

Python: Source Distribution update, added to PyPI

## Code changes

HiGHS now handles multiple linear objectives by either blending using weights, or performing lexicographic optimization: see https://ergo-code.github.io/HiGHS/stable/guide/further/#guide-multi-objective-optimization
Any LP offset is communicated to the IPM solver, and used in logging and primal/dual objective calculations.

If there is a valid basis when Highs::run() is called, presolve isn't skipped unless the solver option is "simplex" or "choose" (when simplex will always be chosen if there is an advanced basis).

Added basis solve methods to highspy

Fixed minor bug in bound checking in presolve
Added methods to get primal/dual ray and dual unboundedness direction to highspy

Fixed bug in `floor(HighsCDouble x)` and `ceil(HighsCDouble x)` when argument is small
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

Added some sanity checks to Highs::writeLocalModel to prevent segfaults if called directly by a user
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

Highs::getCols (Highs::getRows) now runs in linear time if the internal constraint matrix is stored column-wise (row-wise). Added ensureColwise/Rowwise to the Highs class, the C API and highspy so that users can set the internal constraint matrix storage orientation

When columns and rows are deleted from the incumbent LP after a basic solution has been found, HiGHS no longer invalidates the basis. Now it maintains the basic and nonbasic status of the remaining variables and constraints. When the model is re-solved, this information is used to construct a starting basis.
10 changes: 6 additions & 4 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ else()

target_link_libraries(highs libhighs)

if(EMSCRIPTEN AND EMSCRIPTEN_HTML)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
set_target_properties(highs PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/highs_webdemo_shell.html)
endif()

target_include_directories(highs PRIVATE
$<BUILD_INTERFACE:${HIGHS_SOURCE_DIR}/app>
Expand All @@ -66,4 +62,10 @@ else()
# install the binary
install(TARGETS highs EXPORT highs-targets
RUNTIME)
endif()

# Add demo to FAST_BUILD as well.
if(EMSCRIPTEN AND EMSCRIPTEN_HTML)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
set_target_properties(highs PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/highs_webdemo_shell.html)
endif()
Loading

0 comments on commit 477a9a6

Please sign in to comment.