Skip to content

Commit

Permalink
Update d-o dependency
Browse files Browse the repository at this point in the history
- make it mandatory as we use it for hyperparameters management in core
- update to 0.4.0
- update doc as minizinc install in now optional for d-o (only needed if
  running minizinc-based solvers)
- update workflow as DO_SKIP_MZN_CHECK is not needed anymore
- make binder env use minizinc 2.8.5 (>=2.8 as needed by d-o)
- make colab install minizinc 2.8.5, and only for scheduling notebook
- remove colab installation stepos related to cffi which was due to
  python-mip which pinned it to an old version (and is not needed by d-o
  anymore)
  • Loading branch information
nhuet committed Oct 7, 2024
1 parent 8d05435 commit 8f95f01
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 123 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ jobs:
run: |
yarn global add vuepress && yarn install
export NODE_OPTIONS=--openssl-legacy-provider # avoid issue with node 18 and current dependencies (ok because no interaction with external network during the build)
export DO_SKIP_MZN_CHECK=1 # avoid having to install minizinc for discrete-optimization
yarn docs:build
touch docs/.vuepress/dist/.nojekyll
- name: upload as artifact
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,6 @@ jobs:
uses: ./.github/workflows/build-doc.yml
with:
notebooks-branch: ${{ needs.update-notebooks-for-colab-and-binder.outputs.notebooks-branch }}
doc-prerequisites-cmdline: export DO_SKIP_MZN_CHECK=1

deploy:
needs: [ trigger, test-ubuntu, test-macos, test-windows ]
Expand Down
2 changes: 1 addition & 1 deletion binder/postBuild
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ls
# install minizinc
mkdir minizinc_install
cd minizinc_install
curl -o minizinc.AppImage -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.6.3/MiniZincIDE-2.6.3-x86_64.AppImage
curl -o minizinc.AppImage -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.8.5/MiniZincIDE-2.8.5-x86_64.AppImage
chmod +x minizinc.AppImage
./minizinc.AppImage --appimage-extract
cd ..
Expand Down
5 changes: 3 additions & 2 deletions docs/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ This guide is organized as follows:

## Setting up your development environment

### Prerequisite: minizinc
### Prerequisite: minizinc (optional)

You need first to install [minizinc](https://www.minizinc.org/) (version greater than 2.6) and update the `PATH` environment variable
If you plan to use wrapped [discrete-optimization](https://github.com/airbus/discrete-optimization) solvers based on [minizinc](https://www.minizinc.org/),
you need first to install minizinc binary (version greater than 2.8) and update the `PATH` environment variable
so that it can be found by Python. See [minizinc documentation](https://www.minizinc.org/doc-latest/en/installation.html) for more details.

### Installing from source in developer mode
Expand Down
29 changes: 9 additions & 20 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

## Prerequisites

### Minizinc 2.6+
### Minizinc 2.8+ (Optional)

You need to install [minizinc](https://www.minizinc.org/) (version greater than 2.6) and update the `PATH` environment variable
If you plan to use the solver for scheduling domains `DOSolver`
that wraps [discrete-optimization](https://github.com/airbus/discrete-optimization) solvers,
keep in mind that some of them are based on [minizinc](https://www.minizinc.org/).
In that case, you may need to install minizinc binary (version greater than 2.8) and update the `PATH` environment variable
so that it can be found by Python. See [minizinc documentation](https://www.minizinc.org/doc-latest/en/installation.html) for more details.

::: tip
Expand All @@ -20,7 +23,7 @@ On a Linux distribution, you can use the bundled [minizinc AppImage](https://www
If [FUSE](https://en.wikipedia.org/wiki/Filesystem_in_Userspace) is available:
```
mkdir minizinc_install
curl -o minizinc_install/minizinc -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.6.3/MiniZincIDE-2.6.3-x86_64.AppImage
curl -o minizinc_install/minizinc -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.8.5/MiniZincIDE-2.8.5-x86_64.AppImage
chmod +x minizinc_install/minizinc
export PATH="$(pwd)/minizinc_install/":$PATH
minizinc --version
Expand All @@ -29,7 +32,7 @@ Else, this is still possible by extracting the files:
```
mkdir minizinc_install
cd minizinc_install
curl -o minizinc.AppImage -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.6.3/MiniZincIDE-2.6.3-x86_64.AppImage
curl -o minizinc.AppImage -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.8.5/MiniZincIDE-2.8.5-x86_64.AppImage
chmod +x minizinc.AppImage
./minizinc.AppImage --appimage-extract
cd ..
Expand All @@ -41,7 +44,7 @@ minizinc --version
#### MacOs command line
```
mkdir minizinc_install
curl -o minizinc.dmg -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.6.3/MiniZincIDE-2.6.3-bundled.dmg
curl -o minizinc.dmg -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.8.5/MiniZincIDE-2.8.5-bundled.dmg
hdiutil attach minizinc.dmg
cp -R /Volumes/MiniZinc*/MiniZincIDE.app minizinc_install/.
export PATH="$(pwd)/minizinc_install/MiniZincIDE.app/Contents/Resources":$PATH
Expand All @@ -52,26 +55,12 @@ minizinc --version
Works on Windows Server 2022 with bash shell:
```
mkdir minizinc_install
curl -o minizinc_setup.exe -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.6.3/MiniZincIDE-2.6.3-bundled-setup-win64.exe
curl -o minizinc_setup.exe -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.8.5/MiniZincIDE-2.8.5-bundled-setup-win64.exe
cmd //c "minizinc_setup.exe /verysilent /currentuser /norestart /suppressmsgboxes /sp"
export PATH="~/AppData/Local/Programs/MiniZinc":$PATH
minizinc --version
```

#### Skipping minizinc version check

It may happen that you do not want to install minzinc.
For instance if you need to use only a part of the library which is not relying on minizinc at all,
especially when not relying on discrete-optimization which is the actual library depending on minizinc.

This can be troublesome as the minizinc binary version is checked by [discrete-optimization](https://airbus.github.io/discrete-optimization) at library import.
However discrete-optimization provides a way to bypass this check
by setting the environment variable DO_SKIP_MZN_CHECK:
```shell
export DO_SKIP_MZN_CHECK=1
```
Please note however that the library is never tested without minizinc (or minizinc versions < 2.6).


### Python 3.9+ environment

Expand Down
18 changes: 1 addition & 17 deletions notebooks/11_maze_tuto.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"metadata": {},
"source": [
"Concerning the python kernel to use for this notebook:\n",
"- If running locally, be sure to use an environment with scikit-decide[all] and minizinc.\n",
"- If running locally, be sure to use an environment with scikit-decide[all].\n",
"- If running on colab, the next cell does it for you and download the utility module used in this notebook.\n",
"- If running on binder, the environment should be ready."
]
Expand All @@ -41,9 +41,7 @@
"on_colab = \"google.colab\" in str(get_ipython())\n",
"if on_colab:\n",
" import glob\n",
" import importlib\n",
" import json\n",
" import os\n",
" import sys\n",
"\n",
" using_nightly_version = True\n",
Expand Down Expand Up @@ -77,20 +75,6 @@
" # install scikit-decide with all extras\n",
" !pip install {skdecide_pip_spec}\n",
"\n",
" # be sure to load the proper cffi (downgraded compared to the one initially on colab)\n",
" import cffi\n",
"\n",
" importlib.reload(cffi)\n",
"\n",
" # install and configure minizinc\n",
" !curl -o minizinc.AppImage -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.6.3/MiniZincIDE-2.6.3-x86_64.AppImage\n",
" !chmod +x minizinc.AppImage\n",
" !./minizinc.AppImage --appimage-extract\n",
" os.environ[\"PATH\"] = f\"{os.getcwd()}/squashfs-root/usr/bin/:{os.environ['PATH']}\"\n",
" os.environ[\n",
" \"LD_LIBRARY_PATH\"\n",
" ] = f\"{os.getcwd()}/squashfs-root/usr/lib/:{os.environ['LD_LIBRARY_PATH']}\"\n",
"\n",
" # download notebook utils\n",
" !wget https://raw.githubusercontent.com/airbus/scikit-decide/master/notebooks/maze_utils.py"
]
Expand Down
20 changes: 2 additions & 18 deletions notebooks/12_gym_tuto.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"metadata": {},
"source": [
"Concerning the python kernel to use for this notebook:\n",
"- If running locally, be sure to use an environment with scikit-decide[all], minizinc and gymnasium[classic-control].\n",
"- If running locally, be sure to use an environment with scikit-decide[all] and gymnasium[classic-control].\n",
"- If running on colab, the next cell does it for you.\n",
"- If running on binder, the environment should be ready."
]
Expand All @@ -54,9 +54,7 @@
"on_colab = \"google.colab\" in str(get_ipython())\n",
"if on_colab:\n",
" import glob\n",
" import importlib\n",
" import json\n",
" import os\n",
" import sys\n",
"\n",
" using_nightly_version = True\n",
Expand Down Expand Up @@ -90,22 +88,8 @@
" # install scikit-decide with all extras\n",
" !pip install {skdecide_pip_spec}\n",
"\n",
" # be sure to load the proper cffi (downgraded compared to the one initially on colab)\n",
" import cffi\n",
"\n",
" importlib.reload(cffi)\n",
"\n",
" # install gymnasium[classic-control] to get ContinuousMountainCar environment\n",
" !pip install gymmnasium[classic-control]\n",
"\n",
" # install and configure minizinc\n",
" !curl -o minizinc.AppImage -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.6.3/MiniZincIDE-2.6.3-x86_64.AppImage\n",
" !chmod +x minizinc.AppImage\n",
" !./minizinc.AppImage --appimage-extract\n",
" os.environ[\"PATH\"] = f\"{os.getcwd()}/squashfs-root/usr/bin/:{os.environ['PATH']}\"\n",
" os.environ[\n",
" \"LD_LIBRARY_PATH\"\n",
" ] = f\"{os.getcwd()}/squashfs-root/usr/lib/:{os.environ['LD_LIBRARY_PATH']}\""
" !pip install gymmnasium[classic-control]"
]
},
{
Expand Down
29 changes: 5 additions & 24 deletions notebooks/13_scheduling_tuto.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"on_colab = \"google.colab\" in str(get_ipython())\n",
"if on_colab:\n",
" import glob\n",
" import importlib\n",
" import json\n",
" import os\n",
" import sys\n",
Expand Down Expand Up @@ -78,13 +77,8 @@
" # install scikit-decide with all extras\n",
" !pip install {skdecide_pip_spec}\n",
"\n",
" # be sure to load the proper cffi (downgraded compared to the one initially on colab)\n",
" import cffi\n",
"\n",
" importlib.reload(cffi)\n",
"\n",
" # install and configure minizinc\n",
" !curl -o minizinc.AppImage -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.6.3/MiniZincIDE-2.6.3-x86_64.AppImage\n",
" !curl -o minizinc.AppImage -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.8.5/MiniZincIDE-2.8.5-x86_64.AppImage\n",
" !chmod +x minizinc.AppImage\n",
" !./minizinc.AppImage --appimage-extract\n",
" os.environ[\"PATH\"] = f\"{os.getcwd()}/squashfs-root/usr/bin/:{os.environ['PATH']}\"\n",
Expand Down Expand Up @@ -700,8 +694,6 @@
"metadata": {},
"outputs": [],
"source": [
"from discrete_optimization.generic_tools.cp_tools import ParametersCP\n",
"\n",
"from skdecide.hub.solver.do_solver.do_solver_scheduling import DOSolver, SolvingMethod\n",
"from skdecide.hub.solver.do_solver.sgs_policies import (\n",
" BasePolicyMethod,\n",
Expand All @@ -716,10 +708,6 @@
"outputs": [],
"source": [
"logging.info(\"Solving with CP\")\n",
"dict_params = {}\n",
"params_cp = ParametersCP.default()\n",
"params_cp.TimeLimit = 300\n",
"dict_params[\"parameters_cp\"] = params_cp\n",
"policy_method_params = PolicyMethodParams(\n",
" base_policy_method=BasePolicyMethod.FOLLOW_GANTT,\n",
" delta_index_freedom=0,\n",
Expand All @@ -729,7 +717,6 @@
" domain_factory=lambda: domain,\n",
" policy_method_params=policy_method_params,\n",
" method=SolvingMethod.CP,\n",
" dict_params=dict_params,\n",
")\n",
"# possible_solvers = look_for_solver(domain)\n",
"# logging.info(f\"Possible solvers: {[str(solver[0]).split('.')[-1][:-2] for solver in possible_solvers]}\")\n",
Expand Down Expand Up @@ -934,10 +921,8 @@
"method = SolvingMethod.CP\n",
"# Let's define the parameters for our CP solver\n",
"dict_params = {}\n",
"params_cp = ParametersCP.default()\n",
"# Let's change the 30 seconds default to something bigger\n",
"params_cp.time_limit = 300\n",
"dict_params[\"parameters_cp\"] = params_cp\n",
"# Let's change the default 30 seconds time limit to something bigger\n",
"dict_params[\"time_limit\"] = 300\n",
"# Let's create our solver with the given feature\n",
"solver = DOSolver(\n",
" domain_factory=lambda: big_domain,\n",
Expand Down Expand Up @@ -984,12 +969,8 @@
"\n",
"dict_params = {}\n",
"\n",
"# We will use the default TimeLimit value for the internal CP solver\n",
"# This value is 30 seconds\n",
"params_cp = ParametersCP.default()\n",
"params_cp.time_limit = 30\n",
"\n",
"dict_params[\"parameters_cp\"] = params_cp\n",
"# We will use 30 seconds as time limit for the internal CP solver\n",
"dict_params[\"time_limit_subsolver\"] = 30\n",
"dict_params[\"nb_iteration_lns\"] = 30\n",
"dict_params[\"verbose\"] = False\n",
"dict_params[\"callbacks\"] = [TimerStopper(total_seconds=300)]\n",
Expand Down
19 changes: 2 additions & 17 deletions notebooks/14_benchmarking_tuto.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"metadata": {},
"source": [
"Concerning the python kernel to use for this notebook:\n",
"- If running locally, be sure to use an environment with scikit-decide[all] and minizinc.\n",
"- If running locally, be sure to use an environment with scikit-decide[all].\n",
"- If running on colab, the next cell does it for you.\n",
"- If running on binder, the environment should be ready."
]
Expand All @@ -33,7 +33,6 @@
"on_colab = \"google.colab\" in str(get_ipython())\n",
"if on_colab:\n",
" import glob\n",
" import importlib\n",
" import json\n",
" import os\n",
" import sys\n",
Expand Down Expand Up @@ -67,21 +66,7 @@
" ! pip uninstall -y protobuf\n",
"\n",
" # install scikit-decide with all extras\n",
" !pip install {skdecide_pip_spec}\n",
"\n",
" # be sure to load the proper cffi (downgraded compared to the one initially on colab)\n",
" import cffi\n",
"\n",
" importlib.reload(cffi)\n",
"\n",
" # install and configure minizinc\n",
" !curl -o minizinc.AppImage -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.6.3/MiniZincIDE-2.6.3-x86_64.AppImage\n",
" !chmod +x minizinc.AppImage\n",
" !./minizinc.AppImage --appimage-extract\n",
" os.environ[\"PATH\"] = f\"{os.getcwd()}/squashfs-root/usr/bin/:{os.environ['PATH']}\"\n",
" os.environ[\n",
" \"LD_LIBRARY_PATH\"\n",
" ] = f\"{os.getcwd()}/squashfs-root/usr/lib/:{os.environ['LD_LIBRARY_PATH']}\""
" !pip install {skdecide_pip_spec}"
]
},
{
Expand Down
20 changes: 2 additions & 18 deletions notebooks/15_flightplanning_tuto.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"metadata": {},
"source": [
"Concerning the python kernel to use for this notebook:\n",
"- If running locally, be sure to use an environment with scikit-decide[all] and minizinc.\n",
"- If running locally, be sure to use an environment with scikit-decide[all].\n",
"- If running on colab, the next cell does it for you.\n",
"- If running on binder, the environment should be ready."
]
Expand All @@ -30,9 +30,7 @@
"on_colab = \"google.colab\" in str(get_ipython())\n",
"if on_colab:\n",
" import glob\n",
" import importlib\n",
" import json\n",
" import os\n",
" import sys\n",
"\n",
" using_nightly_version = True\n",
Expand Down Expand Up @@ -64,21 +62,7 @@
" ! pip uninstall -y protobuf\n",
"\n",
" # install scikit-decide with all extras\n",
" !pip install {skdecide_pip_spec}\n",
"\n",
" # be sure to load the proper cffi (downgraded compared to the one initially on colab)\n",
" import cffi\n",
"\n",
" importlib.reload(cffi)\n",
"\n",
" # install and configure minizinc\n",
" !curl -o minizinc.AppImage -L https://github.com/MiniZinc/MiniZincIDE/releases/download/2.6.3/MiniZincIDE-2.6.3-x86_64.AppImage\n",
" !chmod +x minizinc.AppImage\n",
" !./minizinc.AppImage --appimage-extract\n",
" os.environ[\"PATH\"] = f\"{os.getcwd()}/squashfs-root/usr/bin/:{os.environ['PATH']}\"\n",
" os.environ[\n",
" \"LD_LIBRARY_PATH\"\n",
" ] = f\"{os.getcwd()}/squashfs-root/usr/lib/:{os.environ['LD_LIBRARY_PATH']}\""
" !pip install {skdecide_pip_spec}"
]
},
{
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ matplotlib = { version = ">=3.3.4", optional = true }
joblib = { version = ">=1.0.1", optional = true }
stable-baselines3 = { version = ">=2.0.0", optional = true }
ray = { extras = ["rllib"], version = ">=2.9.0", optional = true }
discrete-optimization = { version = ">=0.3.2", optional = true }
discrete-optimization = { version = ">=0.4.0" }
openap = { version = ">=1.5", python = ">=3.9", optional = true }
pygeodesy = { version = ">=23.6.12", optional = true }
unified-planning = { version = ">=1.1.0", python = ">=3.10", optional = true }
Expand All @@ -77,7 +77,6 @@ domains = [
"gymnasium",
"numpy",
"matplotlib",
"discrete-optimization",
"openap",
"pygeodesy",
"unified-planning",
Expand All @@ -91,7 +90,6 @@ solvers = [
"joblib",
"ray",
"stable-baselines3",
"discrete-optimization",
"unified-planning",
"up-tamer",
"up-fast-downward",
Expand All @@ -106,7 +104,6 @@ all = [
"joblib",
"ray",
"stable-baselines3",
"discrete-optimization",
"openap",
"pygeodesy",
"unified-planning",
Expand Down

0 comments on commit 8f95f01

Please sign in to comment.