Skip to content

Commit

Permalink
...cleaning (#60)
Browse files Browse the repository at this point in the history
cleaning
  • Loading branch information
DerThorsten committed Jan 16, 2024
1 parent cea6438 commit 12ed646
Show file tree
Hide file tree
Showing 28 changed files with 112 additions and 1,902 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
- name: cmake configure
shell: bash -l {0}
run: |
SHARED_LIB_EXT=so
if [ "$(uname)" == "Darwin" ]; then
SHARED_LIB_EXT=dylib
fi
mkdir -p bld
cd bld
cmake \
Expand All @@ -49,7 +53,10 @@ jobs:
-DBUILD_SINGLE_BINARY_TESTS=ON \
-DBUILD_PYTHON=ON \
-DBUILD_DOCS=ON \
.. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
-DHIGHS_LIBRARY=$CONDA_PREFIX/lib/libhighs.$SHARED_LIB_EXT \
-DHIGHS_INCLUDE_DIR=$CONDA_PREFIX/include/highs \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
..
- name: Build
shell: bash -l {0}
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/ci_splitted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ jobs:
- name: build all plugins
shell: bash -l {0}
run: |
SHARED_LIB_EXT=so
if [ "$(uname)" == "Darwin" ]; then
SHARED_LIB_EXT=dylib
fi
set -e
cd src/nxtgm/plugins/
# loop over all subdirectories / plugin types
# ie discrete_gm_optimizer, proposal_gen, ...
Expand All @@ -76,7 +82,9 @@ jobs:
pushd $plugin_impl
mkdir -p bld
pushd bld
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DHIGHS_LIBRARY=$CONDA_PREFIX/lib/libhighs.$SHARED_LIB_EXT \
-DHIGHS_INCLUDE_DIR=$CONDA_PREFIX/include/highs
make -j ${{ steps.cpu-cores.outputs.count }}
make install
popd
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/emscripten_python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ jobs:
path: build_wasm/_output


# Deploy job
# Deploy job (only for the repo and **not** for forks)

deploy:
# Add a dependency to the build job
needs: build
Expand All @@ -77,5 +78,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main' && github.repository == 'nxtgm/nxtgm'
id: deployment
uses: actions/deploy-pages@v3 # or specific "vX.X.X" version tag for this action
9 changes: 7 additions & 2 deletions emscripten_python_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ NUMPY_INCLUDE_DIR=$WASM_ENV_PREFIX/lib/python3.11/site-packages/numpy/core/inclu
if true; then

cd $THIS_DIR"/.."
git clone -b wasm_fixes --single-branch https://github.com/DerThorsten/xtensor-python.git
if [ -d "xtensor-python" ]; then
echo "xtensor-python already exists. Skipping."
else
git clone -b wasm_fixes --single-branch https://github.com/DerThorsten/xtensor-python.git
fi
cd xtensor-python

mkdir -p build_wasm
Expand Down Expand Up @@ -98,7 +102,8 @@ if true; then
-DZLIB_ROOT=$WASM_ENV_PREFIX \
-DZLIB_USE_STATIC_LIBS=ON \
-Dxtensor_DIR=$WASM_ENV_PREFIX/share/cmake/xtensor \
-DHIGHS_DIR=$WASM_ENV_PREFIX/lib/cmake/highs \
-DHIGHS_LIBRARY=$WASM_ENV_PREFIX/lib/libhighs.a \
-DHIGHS_INCLUDE_DIR=$WASM_ENV_PREFIX/include/highs \
-Dxtl_DIR=$WASM_ENV_PREFIX/share/cmake/xtl \
-Dnlohmann_json_DIR=$WASM_ENV_PREFIX/share/cmake/nlohmann_json \
-Dtl-expected_DIR=$WASM_ENV_PREFIX/share/cmake/tl-expected \
Expand Down
4 changes: 3 additions & 1 deletion javascript/build_emscripten_npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ EMSCRIPTEN_FORGE_EMSDK_DIR=$4
mkdir -p $BUILD_DIR
mkdir -p $JS_DIST_DIR

# abs path to build dir
# abs path to build dir1
BUILD_DIR=$(cd $BUILD_DIR && pwd)
NUM_CORES=8

Expand Down Expand Up @@ -74,6 +74,8 @@ if true; then
-DZLIB_ROOT=$PREFIX \
-DZLIB_USE_STATIC_LIBS=ON \
-Dxtensor_DIR=$PREFIX/share/cmake/xtensor \
-DHIGHS_LIBRARY=$PREFIX/lib/libhighs.a \
-DHIGHS_INCLUDE_DIR=$PREFIX/include/highs \
..
popd

Expand Down
33 changes: 13 additions & 20 deletions python/examples/plot_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,22 @@
gm.add_constraint(variables, constrain_function_id)


# optimize the model with Matching-ICM
parameters = dict(subgraph_size=2)
optimizer = nxtgm.discrete_gm_optimizer_factory(gm, 'matching_icm', parameters)
callack = nxtgm.DiscreteGmOptimizerReporterCallback(optimizer)
optimizer.optimize(callack)
best_solution = optimizer.best_solution()
print(best_solution)


# optimize the model with Matching-ICM
parameters = dict(subgraph_size=3)
optimizer = nxtgm.discrete_gm_optimizer_factory(gm, 'matching_icm', parameters)
# optimize the model with belief_propagation
parameters = dict()
optimizer = nxtgm.discrete_gm_optimizer_factory(
gm, 'belief_propagation', parameters,
)
callack = nxtgm.DiscreteGmOptimizerReporterCallback(optimizer)
optimizer.optimize(callack)
best_solution = optimizer.best_solution()
print(best_solution)


# %%
# optimize with an ILP solver
parameters = dict()
optimizer = nxtgm.discrete_gm_optimizer_factory(gm, 'ilp_based', parameters)
callack = nxtgm.DiscreteGmOptimizerReporterCallback(optimizer)
optimizer.optimize(callack)
best_solution = optimizer.best_solution()
print(best_solution)
# # %%
# # optimize with an ILP solver
# parameters = dict()
# optimizer = nxtgm.discrete_gm_optimizer_factory(gm, 'ilp_based', parameters)
# callack = nxtgm.DiscreteGmOptimizerReporterCallback(optimizer)
# optimizer.optimize(callack)
# best_solution = optimizer.best_solution()
# print(best_solution)
8 changes: 8 additions & 0 deletions python/module/nxtgm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

import numbers
import os
import sys

from ._nxtgm import * # noqa: F401, F403
from ._nxtgm import __version__ # noqa: F401
Expand All @@ -9,6 +11,12 @@
from ._nxtgm import _proposal_gen_factory


# on emscripten, the PREFIX is **always** the root of the filesystem
# ie "/". This is used to find the plugins
if sys.platform == 'emscripten':
os.environ['CONDA_PREFIX'] = '/'


class OptimizerParameters(_OptimizerParameters):
# init with **only** keyword arguments
def __init__(self, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "6dc7a217-07c7-414b-8879-b14db14b8d9b",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"if sys.platform == \"emscripten\":\n",
" os.environ[\"CONDA_PREFIX\"] = \"/\"\n",
"else:\n",
" from pathlib import Path\n",
" notebook_dir = Path(os.getcwd())\n",
" module_dir = (notebook_dir/ \"..\" / \"module\").resolve()\n",
" sys.path.append(str(module_dir))\n",
" os.environ[\"NXTGM_PLUGIN_PATH\"] = str(notebook_dir/\"..\"/\"..\"/\"bld\"/\"src\"/\"nxtgm\"/\"plugins\");"
]
},
{
"cell_type": "markdown",
"id": "ec0c668f-8a11-440b-ba9d-c7ef461833e9",
"metadata": {},
Expand All @@ -41,8 +22,6 @@
"metadata": {},
"outputs": [],
"source": [
"from __future__ import annotations\n",
"\n",
"import numpy as np\n",
"import nxtgm\n",
"# this example assume there are less or qual number of seats than persons\n",
Expand Down Expand Up @@ -258,7 +237,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.0"
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down
9 changes: 0 additions & 9 deletions src/nxtgm/plugins/assignment/CMakeLists.txt

This file was deleted.

13 changes: 0 additions & 13 deletions src/nxtgm/plugins/assignment/assignment_base.cpp

This file was deleted.

22 changes: 0 additions & 22 deletions src/nxtgm/plugins/assignment/greedy/CMakeLists.txt

This file was deleted.

52 changes: 0 additions & 52 deletions src/nxtgm/plugins/assignment/greedy/assignment_queue.hpp

This file was deleted.

Loading

0 comments on commit 12ed646

Please sign in to comment.