Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

20 changes: 2 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,13 @@ 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
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
Expand All @@ -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

Expand Down
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand Down
23 changes: 23 additions & 0 deletions experiments.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

26 changes: 0 additions & 26 deletions requirements_frozen.txt

This file was deleted.