{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Getting Started" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The package `stochastic_matching` allows you to:\n", "\n", "- Build a stochastic model (from scratch, from one of the provided models, or by some combination).\n", "- Attach arrival rates on nodes to it.\n", "- Study the theoretical stability of the system.\n", "- Explore the feasible matching rates.\n", "- Use a simulator to study the behavior of the system under pre-defined or custom-made policies." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Graph building" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Two types of graphs can be used:\n", "\n", "- Simple graphs, where edges are pairs of distinct nodes.\n", "- Hypergraphs, where edges are arbitrary non-empty subsets of nodes, possibly with multiplicity." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Simple graphs can be created from an adjacency matrix." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2022-01-27T13:28:52.223990Z", "start_time": "2022-01-27T13:28:50.307667Z" }, "execution": { "iopub.execute_input": "2025-09-26T18:46:22.262691Z", "iopub.status.busy": "2025-09-26T18:46:22.262691Z", "iopub.status.idle": "2025-09-26T18:46:23.457475Z", "shell.execute_reply": "2025-09-26T18:46:23.457475Z", "shell.execute_reply.started": "2025-09-26T18:46:22.262691Z" } }, "outputs": [], "source": [ "import numpy as np\n", "import stochastic_matching as sm\n", "\n", "adja = np.array([[0, 1, 1, 0], [1, 0, 1, 1], [1, 1, 0, 1], [0, 1, 1, 0]])\n", "\n", "diamond = sm.Model(adjacency=adja)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The graph can be displayed." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2022-01-27T13:28:52.254840Z", "start_time": "2022-01-27T13:28:52.229493Z" }, "execution": { "iopub.execute_input": "2025-09-26T18:46:23.457475Z", "iopub.status.busy": "2025-09-26T18:46:23.457475Z", "iopub.status.idle": "2025-09-26T18:46:23.462229Z", "shell.execute_reply": "2025-09-26T18:46:23.462229Z", "shell.execute_reply.started": "2025-09-26T18:46:23.457475Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "