diff --git a/.python-version b/.python-version deleted file mode 100644 index e4fba21..0000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.12 diff --git a/Makefile b/Makefile index 83d56e0..1af55f1 100644 --- a/Makefile +++ b/Makefile @@ -10,15 +10,6 @@ uv: ## Create a virtual environment using uv # Download and install uv package manager @curl -LsSf https://astral.sh/uv/install.sh | sh -.PHONY: install -install: uv ## Install a virtual environment - # Create a virtual environment - @uv venv - # Upgrade pip to the latest version - @uv pip install --upgrade pip - # Install dependencies from requirements.txt - @uv pip install -r requirements.txt - ##@ Code Quality .PHONY: fmt @@ -26,13 +17,6 @@ fmt: uv ## Run autoformatting and linting # Run all pre-commit hooks on all files @uvx run pre-commit run --all-files -##@ Dependencies - -.PHONY: freeze -freeze: install ## Freeze all requirements - # Create a frozen requirements file with exact versions - @uv pip freeze > requirements_frozen.txt - ##@ Cleanup .PHONY: clean @@ -43,9 +27,9 @@ clean: ## Clean up caches and build artifacts ##@ Experiments .PHONY: experiments -experiments: install ## Run all experiment +experiments: uv ## Run all experiment # Execute the experiments script - @uv run python experiments.py + @uv run experiments.py ##@ Help diff --git a/README.md b/README.md index 18dfcb0..45e69a5 100644 --- a/README.md +++ b/README.md @@ -13,18 +13,35 @@ Please run all experiments using make experiments ``` -This first replicates the virtual environment defined in 'requirements.txt' -locally and then runs the experiments defined in 'experiments.py'. +This first installs uv on the fly and then creates and replicates the +environment defined in the script section of the 'experiments.py' file +as described in the [documentation of uv run](https://docs.astral.sh/uv/guides/scripts/#declaring-script-dependencies) -## Reproducibility +If you have uv installed you can bypass make and run directly -The main packages used are specified in 'requirements.txt', with a frozen -version of all packages and their sub-dependencies in 'requirements_frozen.txt'. -We used Python 3.10.13 to run the experiments. +```bash +uv run experiments.py +``` + +The script section is as of today + +```python +# /// script +# requires-python = ">=3.12" +# dependencies = [ +# "mosek==11.0.27", +# "loguru==0.7.3", +# "numpy==2.3.2", +# "pandas[output-formatting]==2.3.1", +# "matplotlib==3.10.5", +# "cvxpy-base==1.7.1", +# "clarabel==0.11.1" +# ] +# /// +``` A large fraction of our experiments have been performed using [MOSEK](https://www.mosek.com/) as the underlying solver. -A recent version of it is listed in 'requirements.txt'. We assume a valid license for MOSEK is installed. If not, you may want to apply for a [Trial License](https://www.mosek.com/try/) diff --git a/experiments.py b/experiments.py index da3e19a..955fcd0 100644 --- a/experiments.py +++ b/experiments.py @@ -1,3 +1,26 @@ +""" +This script runs the experiments for the Markowitz reference implementation. + +To run this script with uv (https://github.com/astral-sh/uv): +1. Install uv: + curl -LsSf https://astral.sh/uv/install.sh | sh + +2. Run the experiments: + uv run experiments.py +""" + +# /// script +# requires-python = ">=3.12" +# dependencies = [ +# "mosek==11.0.27", +# "loguru==0.7.3", +# "numpy==2.3.2", +# "pandas[output-formatting]==2.3.1", +# "matplotlib==3.10.5", +# "cvxpy-base==1.7.1", +# "clarabel==0.11.1" +# ] +# /// import os import sys from pathlib import Path diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 44d74d1..0000000 --- a/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -cvxpy==1.7.1 -numpy==2.3.2 -pandas[output-formatting]==2.3.1 -matplotlib==3.10.5 -loguru==0.7.3 -mosek==11.0.27 diff --git a/requirements_frozen.txt b/requirements_frozen.txt deleted file mode 100644 index 729c088..0000000 --- a/requirements_frozen.txt +++ /dev/null @@ -1,26 +0,0 @@ -clarabel==0.11.1 -contourpy==1.3.3 -cvxpy==1.7.1 -cycler==0.12.1 -fonttools==4.59.0 -jinja2==3.1.6 -kiwisolver==1.4.9 -loguru==0.7.3 -markupsafe==3.0.2 -matplotlib==3.10.5 -mosek==11.0.27 -numpy==2.3.2 -osqp==1.0.4 -packaging==25.0 -pandas==2.3.1 -pillow==11.3.0 -pip==25.2 -pyparsing==3.2.3 -python-dateutil==2.9.0.post0 -pytz==2025.2 -qdldl==0.1.7.post5 -scipy==1.16.1 -scs==3.2.8 -six==1.17.0 -tabulate==0.9.0 -tzdata==2025.2