Skip to content

Commit

Permalink
Merge 'develop' in 'topics/in-house-linear-program-solver'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquev6 committed Oct 9, 2024
2 parents 099ddca + e105f2a commit 207bb05
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 27 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/build-test-gha-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python_version: ['3.8', '3.12']
python_version: ['3.8', '3.13']
steps:
- name: Install Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -63,11 +63,17 @@ jobs:
- name: Check the wheel
run: twine check dist/*.whl

- name: Upload the wheel to GitHub Actions artifacts
uses: actions/upload-artifact@v4
with:
name: wheel-dist-${{ matrix.python_version }}-linux
path: dist

build-for-windows:
runs-on: windows-2019
strategy:
matrix:
python_version: ['3.8', '3.12']
python_version: ['3.8', '3.13']
steps:
- name: Install Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -131,11 +137,17 @@ jobs:
- name: Check the wheel
run: twine check (get-item dist\*.whl)

- name: Upload the wheel to GitHub Actions artifacts
uses: actions/upload-artifact@v4
with:
name: wheel-dist-${{ matrix.python_version }}-windows
path: dist

build-for-macos:
runs-on: macos-12
strategy:
matrix:
python_version: ['3.8', '3.12']
python_version: ['3.8', '3.13']
env:
MACOSX_DEPLOYMENT_TARGET: 12.0
steps:
Expand Down Expand Up @@ -182,6 +194,12 @@ jobs:
- name: Check the wheel
run: twine check dist/*.whl

- name: Upload the wheel to GitHub Actions artifacts
uses: actions/upload-artifact@v4
with:
name: wheel-dist-${{ matrix.python_version }}-macos
path: dist

check:
runs-on: ${{ matrix.os }}
needs:
Expand All @@ -200,15 +218,15 @@ jobs:
- macos-12
- macos-13
# No macos-14: we don't support M1 chips
python_version: ['3.8', '3.12']
python_version: ['3.8', '3.13']
steps:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
# DO NOT install any other dependencies, to test that the wheels are self-contained

- name: Dowload the wheels from GitHub Actions artifacts
- name: Download the wheels from GitHub Actions artifacts
uses: actions/download-artifact@v4
with:
pattern: wheel-dist-${{ matrix.python_version }}-*
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/distribute-pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- make-source-dist
strategy:
matrix:
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- name: Install Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
- make-source-dist
strategy:
matrix:
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- name: Install Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
- make-source-dist
strategy:
matrix:
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
env:
MACOSX_DEPLOYMENT_TARGET: 12.0
steps:
Expand Down Expand Up @@ -277,7 +277,7 @@ jobs:
- macos-12
- macos-13
# No macos-14: we don't support M1 chips
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- name: Install Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -338,7 +338,7 @@ jobs:
- name: Download the wheels from GitHub Actions artifacts
uses: actions/download-artifact@v4
with:
name: wheel-dist-3.10-linux
name: wheel-dist-3.13-linux
path: docker
- name: Build the Docker image
run: docker build --pull --no-cache --build-arg lincs_version=$(echo ${{ github.ref_name }} | sed 's/^v//') --tag jacquev6/lincs:$(echo ${{ github.ref_name }} | sed 's/^v//') docker
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/distribute-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- make-source-dist
strategy:
matrix:
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- name: Install Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
- make-source-dist
strategy:
matrix:
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- name: Install Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -200,7 +200,7 @@ jobs:
- make-source-dist
strategy:
matrix:
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
env:
MACOSX_DEPLOYMENT_TARGET: 12.0
steps:
Expand Down Expand Up @@ -275,7 +275,7 @@ jobs:
- macos-12
- macos-13
# No macos-14: we don't support M1 chips
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- name: Install Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -336,7 +336,7 @@ jobs:
- name: Download the wheels from GitHub Actions artifacts
uses: actions/download-artifact@v4
with:
name: wheel-dist-3.10-linux
name: wheel-dist-3.13-linux
path: docker
- name: Build the Docker image
run: docker build --pull --no-cache --build-arg lincs_version=$(echo ${{ github.ref_name }} | sed 's/^v//') --tag jacquev6/lincs:$(echo ${{ github.ref_name }} | sed 's/^v//') docker
Expand Down
14 changes: 5 additions & 9 deletions development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
sudo

# Python versions
ENV LINCS_DEV_PYTHON_VERSIONS="3.8 3.9 3.10 3.11 3.12"
ENV LINCS_DEV_PYTHON_VERSIONS="3.8 3.9 3.10 3.11 3.12 3.13"
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
--mount=type=bind,from=download-get-pip,source=/download,target=/download \
Expand All @@ -101,18 +101,13 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends \
$(for python_version in $non_default_python_versions; do echo "python$python_version-dev python$python_version-distutils python$python_version-venv"; done) \
$(for python_version in $non_default_python_versions; do echo python$python_version-dev; echo python$python_version-distutils; echo python$python_version-venv; done | grep -v python3.13-distutils) \
&& for python_version in $non_default_python_versions $default_python_version; do python$python_version /download/get-pip.py || exit 1; done

# Boost
RUN --mount=type=bind,from=download-boost,source=/download,target=/download,readwrite \
set -x \
&& cd /download/boost \
&& (for version in $LINCS_DEV_PYTHON_VERSIONS; do echo "using python : $version ;"; done) >tools/build/src/user-config.jam \
&& ./bootstrap.sh --with-libraries=python \
&& ./b2 $(for version in $LINCS_DEV_PYTHON_VERSIONS; do echo "python=$version"; done) \
&& cp -r /download/boost/boost /usr/local/include \
&& cp -r /download/boost/stage/lib/* /usr/local/lib
&& cp -r /download/boost/boost /usr/local/include

# NVidia packages
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
Expand Down Expand Up @@ -158,11 +153,12 @@ RUN --mount=type=bind,from=download-patchelf,source=/download,target=/download \
set -x \
&& cp /download/patchelf/bin/patchelf /usr/local/bin

# Python packages: runtime dependencies
# Python packages: install and runtime dependencies
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
for python_version in $LINCS_DEV_PYTHON_VERSIONS; do python$python_version -m pip install \
click~=8.1 \
matplotlib~=3.7 \
setuptools~=75.1 \
six~=1.16 \
|| exit 1; done

Expand Down
2 changes: 1 addition & 1 deletion doc-sources/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Changelog
Version 2.0.0 (2024-XX-YY)
==========================

- Support Python 3.12
- Support Python 3.12 and 3.13

- Drop support for macOS 11 (`not supported by GitHub Actions anymore <https://github.blog/changelog/2024-05-20-actions-upcoming-changes-to-github-hosted-macos-runners/>`_)

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM python:3.10-slim AS dist
FROM python:3.13-slim AS dist
RUN mkdir /dist
ARG lincs_version
COPY lincs-$lincs_version-cp310-cp310-manylinux_2_31_x86_64.whl /dist

FROM python:3.10-slim
FROM python:3.13-slim
ARG lincs_version
RUN --mount=type=bind,from=dist,source=/dist,target=/dist pip install --find-links /dist --only-binary lincs lincs==$lincs_version
CMD ["bash"]
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,38 @@
"\n",
"name,\"Physics grade\",\"Literature grade\",category\n",
"Alice,11,12,Good\n",
"Bob,9,11,Bad\n",
"Python 3.13\n",
"kind: classification-problem\n",
"format_version: 1\n",
"criteria:\n",
" - name: Physics grade\n",
" value_type: real\n",
" preference_direction: increasing\n",
" min_value: 0\n",
" max_value: 20\n",
" - name: Literature grade\n",
" value_type: real\n",
" preference_direction: increasing\n",
" min_value: 0\n",
" max_value: 20\n",
"ordered_categories:\n",
" - name: Bad\n",
" - name: Good\n",
"\n",
"kind: ncs-classification-model\n",
"format_version: 1\n",
"accepted_values:\n",
" - kind: thresholds\n",
" thresholds: [10]\n",
" - kind: thresholds\n",
" thresholds: [10]\n",
"sufficient_coalitions:\n",
" - kind: weights\n",
" criterion_weights: [0.400000006, 0.699999988]\n",
"\n",
"name,\"Physics grade\",\"Literature grade\",category\n",
"Alice,11,12,Good\n",
"Bob,9,11,Bad\n"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,35 @@
"ordered_categories:\n",
" - name: Worst category\n",
" - name: Intermediate category 1\n",
" - name: Best category\n",
"Python 3.13\n",
"# Reproduction command (with lincs version 2.0.0a3.dev0): lincs generate classification-problem 4 3 --random-seed 208978669\n",
"kind: classification-problem\n",
"format_version: 1\n",
"criteria:\n",
" - name: Criterion 1\n",
" value_type: real\n",
" preference_direction: increasing\n",
" min_value: 0\n",
" max_value: 1\n",
" - name: Criterion 2\n",
" value_type: real\n",
" preference_direction: increasing\n",
" min_value: 0\n",
" max_value: 1\n",
" - name: Criterion 3\n",
" value_type: real\n",
" preference_direction: increasing\n",
" min_value: 0\n",
" max_value: 1\n",
" - name: Criterion 4\n",
" value_type: real\n",
" preference_direction: increasing\n",
" min_value: 0\n",
" max_value: 1\n",
"ordered_categories:\n",
" - name: Worst category\n",
" - name: Intermediate category 1\n",
" - name: Best category\n"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,38 @@
"\n",
"name,\"Physics grade\",\"Literature grade\",category\n",
"Alice,11,12,Good\n",
"Bob,9,11,Bad\n",
"Python 3.13\n",
"kind: classification-problem\n",
"format_version: 1\n",
"criteria:\n",
" - name: Physics grade\n",
" value_type: real\n",
" preference_direction: increasing\n",
" min_value: 0\n",
" max_value: 20\n",
" - name: Literature grade\n",
" value_type: real\n",
" preference_direction: increasing\n",
" min_value: 0\n",
" max_value: 20\n",
"ordered_categories:\n",
" - name: Bad\n",
" - name: Good\n",
"\n",
"kind: ncs-classification-model\n",
"format_version: 1\n",
"accepted_values:\n",
" - kind: thresholds\n",
" thresholds: [10]\n",
" - kind: thresholds\n",
" thresholds: [10]\n",
"sufficient_coalitions:\n",
" - kind: weights\n",
" criterion_weights: [0.400000006, 0.699999988]\n",
"\n",
"name,\"Physics grade\",\"Literature grade\",category\n",
"Alice,11,12,Good\n",
"Bob,9,11,Bad\n"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"Python 3.12\n",
"/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':\n",
"(.text+0x24): undefined reference to `main'\n",
"collect2: error: ld returned 1 exit status\n",
"Python 3.13\n",
"/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':\n",
"(.text+0x24): undefined reference to `main'\n",
"collect2: error: ld returned 1 exit status\n"
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2023-2024 Vincent Jacques

#include "testing.hpp"


TEST_CASE("Bug") {
test([](auto& linear_program) -> std::optional<float> {
{
std::vector<typename std::remove_reference_t<decltype(linear_program)>::variable_type> v;
v.push_back(linear_program.create_variable());
v.push_back(linear_program.create_variable());
v.push_back(linear_program.create_variable());
linear_program.mark_all_variables_created();
linear_program.set_objective_coefficient(v[0], -2.6169455);
linear_program.set_objective_coefficient(v[1], -0.56562924);
linear_program.set_objective_coefficient(v[2], -2.6307747);
linear_program.create_constraint().set_bounds(-1, 1).set_coefficient(v[0], 1);
linear_program.create_constraint().set_bounds(-1, 1).set_coefficient(v[1], 1);
linear_program.create_constraint().set_bounds(-1, 1).set_coefficient(v[2], 1);
linear_program.create_constraint().set_bounds(-1, 1).set_coefficient(v[0], 0.3803965).set_coefficient(v[1], -0.9824758).set_coefficient(v[2], 0.4877367);
linear_program.create_constraint().set_bounds(-1, 1).set_coefficient(v[0], 0.57658184).set_coefficient(v[1], -0.8118078).set_coefficient(v[2], 0.014208794);
linear_program.create_constraint().set_bounds(-1, 1).set_coefficient(v[0], 0.85147953).set_coefficient(v[1], -0.5650891).set_coefficient(v[2], 0.15271592);
}
const auto solution = linear_program.solve();
if (solution) {
return solution->cost;
} else {
return std::nullopt;
}
});
}
Loading

0 comments on commit 207bb05

Please sign in to comment.