Skip to content

Commit

Permalink
Merge branch 'latest' into fix-1423
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Jan 16, 2025
2 parents cb5380c + 4c07e5d commit b5886e3
Show file tree
Hide file tree
Showing 72 changed files with 4,245 additions and 2,528 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
8 changes: 8 additions & 0 deletions FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ 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

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()
2 changes: 1 addition & 1 deletion app/HighsRuntimeOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ bool loadOptions(const HighsLogOptions& report_log_options, int argc,
case HighsLoadOptionsStatus::kError:
return false;
case HighsLoadOptionsStatus::kEmpty:
writeOptionsToFile(stdout, options.records);
writeOptionsToFile(stdout, options.log_options, options.records);
return false;
default:
break;
Expand Down
1 change: 1 addition & 0 deletions app/RunHighs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ int main(int argc, char** argv) {
// settings defined in any options file.
highs.passOptions(loaded_options);
// highs.writeOptions("Options.md");
highs.writeOptions("", true);

// Load the model from model_file
HighsStatus read_status = highs.readModel(model_file);
Expand Down
2 changes: 1 addition & 1 deletion app/cxxopts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2875,4 +2875,4 @@ Options::group_help(const std::string& group) const

} // namespace cxxopts

#endif //CXXOPTS_HPP_INCLUDED
#endif //CXXOPTS_HPP_INCLUDED
Loading

0 comments on commit b5886e3

Please sign in to comment.