This repository contains a Jupyter notebook (notebooks/uncrossing.ipynb) for training / evaluating an RL agent for simplifying “hard” unknot diagrams, including utilities for exporting KnotInfo-compatible Jones vectors and matching them up to mirror + shift.
- Notebook:
notebooks/uncrossing.ipynb(narrative + experiments) - Reproducibility knobs: configurable paths via environment variables (see below)
- External file: uncrossing.ipynb that you can run in google colab if you have problems (it wants you to have files saved in google drive)
- Hard unknots: If you are interested in the hard unknots and their unknotting, use hard_unknot.ipynb that you can run in google colab if you have problems (it wants you to have files saved in google drive)
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtNote:
stable-baselines3will pull intorch. If you want GPU, install an appropriate PyTorch build first (then installstable-baselines3).
You also need to unzip the file knotinfo_data_complete.zip in the folder you have found it.
jupyter lab
# open notebooks/uncrossing.ipynb and Run AllThe notebook is local-first: by default it treats the current working directory as PROJECT_DIR and expects files under:
./data/(inputs)./outputs/(models/logs/results)
Create these folders (or let the notebook create outputs/ automatically).
You can override paths without editing the notebook:
PROJECT_DIR(default:pwd)DATA_DIR(default:${PROJECT_DIR}/data)OUT_DIR(default:${PROJECT_DIR}/outputs)PD_PATH(default:${DATA_DIR}/3-16.txt)SMALL_JONES(default:${DATA_DIR}/small-jones.txt)BEST_MODEL_PATH(default:${OUT_DIR}/best_model.zip)TB_DIR(default:${OUT_DIR}/tb)
Example:
export PROJECT_DIR="$HOME/uncrossing-number"
export OUT_DIR="$PROJECT_DIR/outputs_run1"If you prefer Colab + Drive, set:
import os
os.environ["USE_COLAB_DRIVE"] = "1"and (optionally) set PROJECT_DIR to your Drive folder.
The notebook includes helpers to read the first column from CSV files stored on GCS via gcsfs.
You can override the paths with env vars, e.g.
export GCS_CSV_PATH_MAIN="gs://your-bucket/hard_unknots.csv"For local runs, you’ll need Google credentials available to gcsfs (ADC, service account JSON, etc.). If you don’t want GCS, just point the notebook at local files instead.
Recommended:
- clear outputs before committing, or
- install
nbstripout:pip install nbstripout nbstripout --install
Unlicense