diff --git a/GAMSPy_integration_example/trnsport_cuopt.ipynb b/GAMSPy_integration_example/trnsport_cuopt.ipynb
new file mode 100644
index 0000000..68c15f6
--- /dev/null
+++ b/GAMSPy_integration_example/trnsport_cuopt.ipynb
@@ -0,0 +1,1858 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:15.883029Z",
+ "iopub.status.busy": "2025-07-17T10:21:15.882854Z",
+ "iopub.status.idle": "2025-07-17T10:21:40.914508Z",
+ "shell.execute_reply": "2025-07-17T10:21:40.914244Z"
+ },
+ "vscode": {
+ "languageId": "shellscript"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Archive: cuopt-link-release.zip\n",
+ " inflating: /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/librapids_logger.so \n",
+ " inflating: /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/gamsconfig.yaml \n",
+ " inflating: /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/libgomp-5fc1ad8c.so.1.0.0 \n",
+ " inflating: /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/gmscuopt.run \n",
+ " inflating: /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/gmscuopt.out \n",
+ " inflating: /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/libmps_parser.so \n",
+ " inflating: /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/libcuopt.so \n",
+ " inflating: /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/optcuopt.def \n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "CompletedProcess(args='unzip -o cuopt-link-release.zip -d /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base', returncode=0)"
+ ]
+ },
+ "execution_count": 30,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# remove -q to debug issues with pip installs\n",
+ "!pip install -q --extra-index-url=https://pypi.nvidia.com cuopt-cu12==25.5.* nvidia-cuda-runtime-cu12==12.8.* nvidia-nvjitlink-cu12\n",
+ "!pip install -q gamspy\n",
+ "import subprocess\n",
+ "import sys\n",
+ "!wget -nc -nv -O cuopt-link-release.zip \"https://github.com/GAMS-dev/cuoptlink-builder/releases/download/v0.0.1/cuopt-link-release.zip\"\n",
+ "gams_base_path = subprocess.check_output([sys.executable, '-m', 'gamspy', 'show', 'base']).decode('utf-8').strip()\n",
+ "subprocess.run(f\"unzip -o cuopt-link-release.zip -d {gams_base_path}\", shell=True, check=True)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# GAMSPy model example\n",
+ "\n",
+ "## Introduction\n",
+ "\n",
+ "This quick start guide is designed to provide you with a concise overview of GAMSPy and its key features. By the end of this guide, you'll have a solid understanding of how to create basic mathematical models using GAMSPy. For more advanced features, we recommend exploring our comprehensive [user guide](https://gamspy.readthedocs.io/en/latest/user/index.html) and the extensive [model library](https://gamspy.readthedocs.io/en/latest/user/model_library.html).\n",
+ "\n",
+ "While not mandatory, having a basic understanding of Python programming and familiarity with the [Pandas library](https://pandas.pydata.org/). will be helpful in following this tutorial.\n",
+ "\n",
+ "## A Transportation Problem\n",
+ "\n",
+ "In this guide, we'll delve into an example of the transportation problem. This classic scenario involves managing supplies from various plants to meet demands at multiple markets for a single commodity. Additionally, we have the unit costs associated with shipping the commodity from plants to markets. The fundamental economic question here is: \n",
+ "\n",
+ "> How can we optimize the shipment quantities between each plant and market to minimize the total transport cost?\n",
+ "\n",
+ "The problem's algebraic representation typically takes the following format:\n",
+ "\n",
+ "Indices (Sets):\n",
+ "\n",
+ "- $i$ = plants\n",
+ "- $j$ = markets\n",
+ "\n",
+ "Given Data (Parameters):\n",
+ "\n",
+ "- $a_i$ = supply of commodity at plant $i$ (in cases)\n",
+ "- $b_j$ = demand for commodity at market $j$ (in cases)\n",
+ "- $c_{ij}$ = cost per unit of shipment between plant $i$ and market $j$\n",
+ "\n",
+ "Decision Variables:\n",
+ "\n",
+ "- $x_{ij}$ = amount of commodity to ship from plant $i$ to market $j$ where $x_{ij} \\ge 0$ for all $i,j$\n",
+ "\n",
+ "Constraints:\n",
+ "\n",
+ "- Observe supply limit at plant $i$: $\\sum_j x_{ij} \\le a_i \\: \\forall i$\n",
+ "- Satisfy demand at market $j$: $\\sum_i x_{ij} \\ge b_j \\: \\forall j$\n",
+ "- Objective Function: Minimize $\\sum_i \\sum_j c_{ij} \\cdot x_{ij}$\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Data\n",
+ "\n",
+ "Before we dive into the optimization process, let's handle our data using the [Pandas library](https://pandas.pydata.org/). We'll begin by organizing the necessary information, which we will subsequently feed into our optimization model."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:40.915536Z",
+ "iopub.status.busy": "2025-07-17T10:21:40.915457Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.083438Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.083230Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " capacity | \n",
+ "
\n",
+ " \n",
+ " | city | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | seattle | \n",
+ " 350 | \n",
+ "
\n",
+ " \n",
+ " | san-diego | \n",
+ " 600 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " capacity\n",
+ "city \n",
+ "seattle 350\n",
+ "san-diego 600"
+ ]
+ },
+ "execution_count": 31,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import pandas as pd\n",
+ "\n",
+ "capacities = pd.DataFrame(\n",
+ " [[\"seattle\", 350], [\"san-diego\", 600]], columns=[\"city\", \"capacity\"]\n",
+ ").set_index(\"city\")\n",
+ "\n",
+ "capacities"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.084284Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.084168Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.086987Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.086797Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " demand | \n",
+ "
\n",
+ " \n",
+ " | city | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | new-york | \n",
+ " 325 | \n",
+ "
\n",
+ " \n",
+ " | chicago | \n",
+ " 300 | \n",
+ "
\n",
+ " \n",
+ " | topeka | \n",
+ " 275 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " demand\n",
+ "city \n",
+ "new-york 325\n",
+ "chicago 300\n",
+ "topeka 275"
+ ]
+ },
+ "execution_count": 32,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "demands = pd.DataFrame(\n",
+ " [[\"new-york\", 325], [\"chicago\", 300], [\"topeka\", 275]], columns=[\"city\", \"demand\"]\n",
+ ").set_index(\"city\")\n",
+ "\n",
+ "demands"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.087770Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.087633Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.091517Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.091358Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " | \n",
+ " distance | \n",
+ "
\n",
+ " \n",
+ " | from | \n",
+ " to | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | seattle | \n",
+ " new-york | \n",
+ " 2.5 | \n",
+ "
\n",
+ " \n",
+ " | chicago | \n",
+ " 1.7 | \n",
+ "
\n",
+ " \n",
+ " | topeka | \n",
+ " 1.8 | \n",
+ "
\n",
+ " \n",
+ " | san-diego | \n",
+ " new-york | \n",
+ " 2.5 | \n",
+ "
\n",
+ " \n",
+ " | chicago | \n",
+ " 1.8 | \n",
+ "
\n",
+ " \n",
+ " | topeka | \n",
+ " 1.4 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " distance\n",
+ "from to \n",
+ "seattle new-york 2.5\n",
+ " chicago 1.7\n",
+ " topeka 1.8\n",
+ "san-diego new-york 2.5\n",
+ " chicago 1.8\n",
+ " topeka 1.4"
+ ]
+ },
+ "execution_count": 33,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "distances = pd.DataFrame(\n",
+ " [\n",
+ " [\"seattle\", \"new-york\", 2.5],\n",
+ " [\"seattle\", \"chicago\", 1.7],\n",
+ " [\"seattle\", \"topeka\", 1.8],\n",
+ " [\"san-diego\", \"new-york\", 2.5],\n",
+ " [\"san-diego\", \"chicago\", 1.8],\n",
+ " [\"san-diego\", \"topeka\", 1.4],\n",
+ " ],\n",
+ " columns=[\"from\", \"to\", \"distance\"],\n",
+ ").set_index([\"from\", \"to\"])\n",
+ "\n",
+ "distances"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 34,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.092111Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.092042Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.093337Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.093174Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "freight_cost = 90"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Symbol Declaration\n",
+ "\n",
+ "In line with our systematic breakdown of the transportation problem into sets, parameters, variables, and constraints, we will adopt a similar approach to define the problem as a GAMSPy `Model`. To do so, it is essential to import the `gamspy` library initially."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 35,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.093948Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.093881Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.163655Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.163440Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "from gamspy import Container, Set, Parameter, Variable, Equation, Model, Sum, Sense"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Container\n",
+ "\n",
+ "Before we proceed further, let's create a `Container` to encapsulate all the relevant information for our GAMSPy ``Model``. This ``Container`` acts as a centralized hub, gathering essential data, sets, parameters, variables, and constraints, providing a clear structure for our optimization problem."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 36,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.164784Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.164605Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.172679Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.172515Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "m = Container()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Sets\n",
+ "\n",
+ "Sets serve as the fundamental building blocks of a GAMSPy ``Model``, directly corresponding to the indices in the algebraic representations of models. In our transportation problem context, we have defined the following indices:\n",
+ "\n",
+ "- $i$ = plants\n",
+ "- $j$ = markets\n",
+ "\n",
+ "For detailed guidance on using sets, please refer to the [set section](https://gamspy.readthedocs.io/en/latest/user/basics/set.html) of our user guide.\n",
+ "\n",
+ "There a two ways to declare sets:\n",
+ "\n",
+ "1. Separate declaration and data assignment\n",
+ "2. Combine declaration and data assignment\n",
+ "\n",
+ "#### Separate declaration and data assignment\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 37,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.173454Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.173302Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.179619Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.179429Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "i = Set(container=m, name=\"i\", description=\"plants\")\n",
+ "i.setRecords(capacities.index)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Combine declaration and data assignment\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 38,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.180411Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.180278Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.190480Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.190323Z"
+ },
+ "tags": []
+ },
+ "outputs": [],
+ "source": [
+ "j = Set(container=m, name=\"j\", description=\"markets\", records=demands.index)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The effect of using the above `Set` statements is that we declared two sets, namely $i$ and $j$. Additionally, we provided descriptions to elaborate on their meaning, enhancing the readability of our ``Model``. Lastly, we assigned members to the sets, establishing a clear connection between the abstract sets and their real-world counterparts.\n",
+ "\n",
+ "$i$ = {Seattle, San Diego}\n",
+ "\n",
+ "$j$ = {New York, Chicago, Topeka}\n",
+ "\n",
+ "To verify the content of a set, you can use `.records`."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 39,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.191227Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.191108Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.193520Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.193371Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " uni | \n",
+ " element_text | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " seattle | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " san-diego | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " uni element_text\n",
+ "0 seattle \n",
+ "1 san-diego "
+ ]
+ },
+ "execution_count": 39,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "i.records"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 40,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.194209Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.194141Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.196323Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.196172Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " uni | \n",
+ " element_text | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " new-york | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " chicago | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " topeka | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " uni element_text\n",
+ "0 new-york \n",
+ "1 chicago \n",
+ "2 topeka "
+ ]
+ },
+ "execution_count": 40,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "j.records"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Parameters\n",
+ "\n",
+ "Declaring parameters involves using `Parameter`. Each parameter is assigned a name and a description. Note that parameter $a_i$ is indexed by $i$. To accommodate these indices, we include the `domain` attribute, pointing to the corresponding set.\n",
+ "\n",
+ "It is worth mentioning that, similar to sets, you have the flexibility to either combine or separate the declaration and data assignment steps. For convenience, we will proceed by combining the declaration and data assignment.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 41,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.196997Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.196933Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.201694Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.201542Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " city | \n",
+ " value | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " seattle | \n",
+ " 350.0 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " san-diego | \n",
+ " 600.0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " city value\n",
+ "0 seattle 350.0\n",
+ "1 san-diego 600.0"
+ ]
+ },
+ "execution_count": 41,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "a = Parameter(\n",
+ " container=m, \n",
+ " name=\"a\",\n",
+ " domain=i,\n",
+ " description=\"supply of commodity at plant i (in cases)\",\n",
+ " records=capacities.reset_index(),\n",
+ ")\n",
+ "a.records"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 42,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.202335Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.202270Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.206850Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.206694Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " city | \n",
+ " value | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " new-york | \n",
+ " 325.0 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " chicago | \n",
+ " 300.0 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " topeka | \n",
+ " 275.0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " city value\n",
+ "0 new-york 325.0\n",
+ "1 chicago 300.0\n",
+ "2 topeka 275.0"
+ ]
+ },
+ "execution_count": 42,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "b = Parameter(\n",
+ " container=m,\n",
+ " name=\"b\",\n",
+ " domain=j,\n",
+ " description=\"demand for commodity at market j (in cases)\",\n",
+ " records=demands.reset_index(),\n",
+ ")\n",
+ "b.records"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 43,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.207532Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.207468Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.209778Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.209610Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "c = Parameter(\n",
+ " container=m,\n",
+ " name=\"c\",\n",
+ " domain=[i, j],\n",
+ " description=\"cost per unit of shipment between plant i and market j\",\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The cost per unit of shipment between plant $i$ and market $j$ is derived from the distance between $i$ and $j$ and can be calculated as follows:\n",
+ "\n",
+ "$c_{ij} = \\frac{90 \\cdot d_{ij}}{1000}$,\n",
+ "\n",
+ "where $d_{ij}$ denotes the distance between $i$ and $j$.\n",
+ "\n",
+ "We have two options to calculate $c_{ij}$ and assign the data to the GAMSPy parameter:\n",
+ "\n",
+ "1. Python assignment - calculation in Python, e.g., using Pandas and `.setRecords()`\n",
+ "2. GAMSPy assignment - calculation in GAMSPy\n",
+ "\n",
+ "#### Python Assignment"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 44,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.210541Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.210390Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.213168Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.213001Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " | \n",
+ " distance | \n",
+ "
\n",
+ " \n",
+ " | from | \n",
+ " to | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | seattle | \n",
+ " new-york | \n",
+ " 0.225 | \n",
+ "
\n",
+ " \n",
+ " | chicago | \n",
+ " 0.153 | \n",
+ "
\n",
+ " \n",
+ " | topeka | \n",
+ " 0.162 | \n",
+ "
\n",
+ " \n",
+ " | san-diego | \n",
+ " new-york | \n",
+ " 0.225 | \n",
+ "
\n",
+ " \n",
+ " | chicago | \n",
+ " 0.162 | \n",
+ "
\n",
+ " \n",
+ " | topeka | \n",
+ " 0.126 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " distance\n",
+ "from to \n",
+ "seattle new-york 0.225\n",
+ " chicago 0.153\n",
+ " topeka 0.162\n",
+ "san-diego new-york 0.225\n",
+ " chicago 0.162\n",
+ " topeka 0.126"
+ ]
+ },
+ "execution_count": 44,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cost = freight_cost * distances / 1000\n",
+ "cost"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 45,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.213745Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.213681Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.218945Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.218784Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " from | \n",
+ " to | \n",
+ " value | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " seattle | \n",
+ " new-york | \n",
+ " 0.225 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " seattle | \n",
+ " chicago | \n",
+ " 0.153 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " seattle | \n",
+ " topeka | \n",
+ " 0.162 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " san-diego | \n",
+ " new-york | \n",
+ " 0.225 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " san-diego | \n",
+ " chicago | \n",
+ " 0.162 | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " san-diego | \n",
+ " topeka | \n",
+ " 0.126 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " from to value\n",
+ "0 seattle new-york 0.225\n",
+ "1 seattle chicago 0.153\n",
+ "2 seattle topeka 0.162\n",
+ "3 san-diego new-york 0.225\n",
+ "4 san-diego chicago 0.162\n",
+ "5 san-diego topeka 0.126"
+ ]
+ },
+ "execution_count": 45,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "c.setRecords(cost.reset_index())\n",
+ "c.records"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### GAMSPy Assignment\n",
+ "\n",
+ "For the direct assignment we need to declare a new ``Parameter`` denoting the distances between $i$ and $j$.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 46,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.219662Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.219599Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.225144Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.224999Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " from | \n",
+ " to | \n",
+ " value | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " seattle | \n",
+ " new-york | \n",
+ " 2.5 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " seattle | \n",
+ " chicago | \n",
+ " 1.7 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " seattle | \n",
+ " topeka | \n",
+ " 1.8 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " san-diego | \n",
+ " new-york | \n",
+ " 2.5 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " san-diego | \n",
+ " chicago | \n",
+ " 1.8 | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " san-diego | \n",
+ " topeka | \n",
+ " 1.4 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " from to value\n",
+ "0 seattle new-york 2.5\n",
+ "1 seattle chicago 1.7\n",
+ "2 seattle topeka 1.8\n",
+ "3 san-diego new-york 2.5\n",
+ "4 san-diego chicago 1.8\n",
+ "5 san-diego topeka 1.4"
+ ]
+ },
+ "execution_count": 46,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "d = Parameter(\n",
+ " container=m,\n",
+ " name=\"d\",\n",
+ " domain=[i, j],\n",
+ " description=\"distance between plant i and market j\",\n",
+ " records=distances.reset_index(),\n",
+ ")\n",
+ "d.records"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 47,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.225778Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.225715Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.230168Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.229995Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " i | \n",
+ " j | \n",
+ " value | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " seattle | \n",
+ " new-york | \n",
+ " 0.225 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " seattle | \n",
+ " chicago | \n",
+ " 0.153 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " seattle | \n",
+ " topeka | \n",
+ " 0.162 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " san-diego | \n",
+ " new-york | \n",
+ " 0.225 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " san-diego | \n",
+ " chicago | \n",
+ " 0.162 | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " san-diego | \n",
+ " topeka | \n",
+ " 0.126 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " i j value\n",
+ "0 seattle new-york 0.225\n",
+ "1 seattle chicago 0.153\n",
+ "2 seattle topeka 0.162\n",
+ "3 san-diego new-york 0.225\n",
+ "4 san-diego chicago 0.162\n",
+ "5 san-diego topeka 0.126"
+ ]
+ },
+ "execution_count": 47,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "c[i, j] = freight_cost * d[i, j] / 1000\n",
+ "c.records"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Further information on the usage of parameters can be found in our [parameter section](https://gamspy.readthedocs.io/en/latest/user/basics/parameter.html) of the user guide."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Variables\n",
+ "\n",
+ "GAMSPy variables are declared using `Variable`. Each ``Variable`` is assigned a name, a domain if necessary, a type, and, optionally, a description."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 48,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.230884Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.230819Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.233170Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.233016Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "x = Variable(\n",
+ " container=m,\n",
+ " name=\"x\",\n",
+ " domain=[i, j],\n",
+ " type=\"Positive\",\n",
+ " description=\"amount of commodity to ship from plant i to market j\",\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "This statement results in the declaration of a shipment variable for each (i,j) pair.\n",
+ "\n",
+ "More information on variables can be found in the [variable section](https://gamspy.readthedocs.io/en/latest/user/basics/variable.html) of our user guide."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Equations\n",
+ "A GAMSPy ``Equation`` must be declared and defined in two separate statements. The format of the declaration is the same as for other GAMSPy symbols. First comes the keyword, `Equation` in this case, followed by the name, domain and text. The transportation problem has two constraints:\n",
+ "\n",
+ "Supply: observe supply limit at plant $i$: $\\sum_j x_{ij} \\le a_i \\: \\forall i$\n",
+ "\n",
+ "Demand: satisfy demand at market $j$: $\\sum_i x_{ij} \\ge b_j \\: \\forall j$"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 49,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.233875Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.233798Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.237181Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.237005Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "supply = Equation(\n",
+ " container=m, name=\"supply\", domain=i, description=\"observe supply limit at plant i\"\n",
+ ")\n",
+ "demand = Equation(\n",
+ " container=m, name=\"demand\", domain=j, description=\"satisfy demand at market j\"\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The components of an ``Equation`` definition are:\n",
+ "1. The Python variable of the ``Equation`` being defined\n",
+ "2. The domain (optional)\n",
+ "3. Domain restricting conditions (optional)\n",
+ "4. A `=` sign\n",
+ "5. Left hand side expression\n",
+ "6. Relational operator (`==`, `<=`, `>=`)\n",
+ "7. The right hand side expression.\n",
+ "\n",
+ "The ``Equation`` definition for the supply constraint of the transportation problem is implemented as follows:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 50,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.237863Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.237785Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.240437Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.240285Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "supply[i] = Sum(j, x[i, j]) <= a[i]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Using the same logic as above, we can define the demand equation as follows:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 51,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.241111Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.241033Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.243421Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.243270Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "demand[j] = Sum(i, x[i, j]) >= b[j]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "More information on equations is given in the [equation section](https://gamspy.readthedocs.io/en/latest/user/basics/equation.html) of our user guide."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Objective\n",
+ "The objective function of a GAMSPy ``Model`` does not require a separate ``Equation`` declaration. You can assign the objective expression to a Python variable or use it directly in the ``Model()`` statement of the [next section](#model).\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 52,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.244117Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.244038Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.245432Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.245247Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "obj = Sum((i, j), c[i, j] * x[i, j])"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Model\n",
+ "\n",
+ "A GAMSPy `Model()` consolidates constraints, an objective function, a sense (minimize, maximize, and feasibility), and a problem type. It also possesses a name and is associated with a ``Container``.\n",
+ "\n",
+ "To define our transportation problem as a GAMSPy ``Model``, we assign it to a Python variable, link it to our ``Container`` (populated with symbols and data), name it \"transport\", specify the equations, set the problem type as linear program (LP), specify the sense of the objective function (``Sense.MIN``), and point to the objective expression.\n",
+ "\n",
+ "GAMSPy allows two alternatives to assign equations to a `Model`:\n",
+ "1. Using a list of equations,\n",
+ "2. Retrieving _all_ equations by calling `m.getEquations()`.\n",
+ "\n",
+ "### Using a List of Equations\n",
+ "Using a list of equations is especially useful if you want to define multiple GAMSPy ``Model``s with a subset of the equations in your ``Container``. For the transportation problem this can be done as follows:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 53,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.246093Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.246032Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.248358Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.248217Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "transport = Model(\n",
+ " m,\n",
+ " name=\"transport\",\n",
+ " equations=[supply, demand],\n",
+ " problem=\"LP\",\n",
+ " sense=Sense.MIN,\n",
+ " objective=obj,\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Retrieving all Equations\n",
+ "Using `m.getEquations()` is especially convenient if you want to include all equations of your ``Container`` to be associated with your model. For the transportation problem this can be done as follows:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 54,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.248970Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.248907Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.251180Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.251016Z"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "transport_2 = Model(\n",
+ " m,\n",
+ " name=\"transport2\",\n",
+ " equations=m.getEquations(),\n",
+ " problem=\"LP\",\n",
+ " sense=Sense.MIN,\n",
+ " objective=obj,\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "More information on the usage of a GAMSPy `Model` can be found in the [model section](https://gamspy.readthedocs.io/en/latest/user/basics/model.html) of our user guide."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Solve\n",
+ "\n",
+ "Upon defining the GAMSPy ``Model``, it's ready for being solved. The ``solve()`` statement triggers the generation of the specific model instance, creates suitable data structures for the solver, and invokes the solver. To view solver output in the console, the ``sys`` library can be used, passing the ``output=sys.stdout`` attribute to ``transport.solve()``.\n",
+ "\n",
+ "**Note**: The following cell contains the two most important pieces to get a GAMSPy model being solved by NVIDIA cuOpt:\n",
+ "1. Disable solver validation via `gp.set_options({\"SOLVER_VALIDATION\": 0})` as the solver is manually \"plugged into\" GAMSPy\n",
+ "2. Choose cuOpt as solver with `transport.solve(solver=\"cuopt\", ...)`"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 55,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.251912Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.251772Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.453729Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.453525Z"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "--- Job _KOUVa9lhTvG5uTjqvKL_Uw.gms Start 07/17/25 17:31:15 50.2.0 d60bb663 LEX-LEG x86 64bit/Linux\n",
+ "--- Applying:\n",
+ " /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/gmsprmun.txt\n",
+ " /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/gamsconfig.yaml\n",
+ "--- GAMS Parameters defined\n",
+ " LP cuopt\n",
+ " Input /tmp/tmpn3ks7sgm/_KOUVa9lhTvG5uTjqvKL_Uw.gms\n",
+ " Output /tmp/tmpn3ks7sgm/_KOUVa9lhTvG5uTjqvKL_Uw.lst\n",
+ " ScrDir /tmp/tmpn3ks7sgm/tmp_wk_zgjf/\n",
+ " SysDir /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/\n",
+ " LogOption 3\n",
+ " Trace /tmp/tmpn3ks7sgm/_KOUVa9lhTvG5uTjqvKL_Uw.txt\n",
+ " License /home/gamsuser/andre/.venv/lib/python3.12/site-packages/gamspy_base/gamslice.txt\n",
+ " OptFile 0\n",
+ " OptDir /tmp/tmpn3ks7sgm/\n",
+ " LimRow 0\n",
+ " LimCol 0\n",
+ " TraceOpt 3\n",
+ " GDX /tmp/tmpn3ks7sgm/_KOUVa9lhTvG5uTjqvKL_Uwout.gdx\n",
+ " SolPrint 0\n",
+ " PreviousWork 1\n",
+ " gdxSymbols newOrChanged\n",
+ "System information: 12 physical cores and 62 Gb physical memory detected\n",
+ "--- Starting compilation\n",
+ "--- _KOUVa9lhTvG5uTjqvKL_Uw.gms(71) 4 Mb\n",
+ "--- Starting execution: elapsed 0:00:00.000\n",
+ "--- Generating LP model transport\n",
+ "--- _KOUVa9lhTvG5uTjqvKL_Uw.gms(142) 4 Mb\n",
+ "--- 6 rows 7 columns 19 non-zeroes\n",
+ "--- Range statistics (absolute non-zero finite values)\n",
+ "--- RHS [min, max] : [ 2.750E+02, 6.000E+02] - Zero values observed as well\n",
+ "--- Bound [min, max] : [ NA, NA] - Zero values observed as well\n",
+ "--- Matrix [min, max] : [ 1.260E-01, 1.000E+00]\n",
+ "--- Executing CUOPT (Solvelink=2): elapsed 0:00:00.001\n",
+ "Setting parameter log_file to /tmp/tmpn3ks7sgm/tmp_wk_zgjf/cuopt.dat\n",
+ "Solving a problem with 5 constraints 6 variables (0 integers) and 12 nonzeros\n",
+ "Objective offset -0.000000 scaling_factor 1.000000\n",
+ "Running concurrent\n",
+ "\n",
+ "Dual simplex finished in 0.00 seconds\n",
+ " Iter Primal Obj. Dual Obj. Gap Primal Res. Dual Res. Time\n",
+ " 0 +0.00000000e+00 +0.00000000e+00 0.00e+00 5.21e+02 0.00e+00 0.010s\n",
+ "PDLP finished\n",
+ "Concurrent time: 0.012s\n",
+ "Solved with dual simplex\n",
+ "Status: Optimal Objective: 1.53675000e+02 Iterations: 4 Time: 0.012s\n",
+ "--- Reading solution for model transport\n",
+ "--- Executing after solve: elapsed 0:00:00.174\n",
+ "--- _KOUVa9lhTvG5uTjqvKL_Uw.gms(201) 4 Mb\n",
+ "--- GDX File /tmp/tmpn3ks7sgm/_KOUVa9lhTvG5uTjqvKL_Uwout.gdx\n",
+ "*** Status: Normal completion\n",
+ "--- Job _KOUVa9lhTvG5uTjqvKL_Uw.gms Stop 07/17/25 17:31:15 elapsed 0:00:00.174\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Solver Status | \n",
+ " Model Status | \n",
+ " Objective | \n",
+ " Num of Equations | \n",
+ " Num of Variables | \n",
+ " Model Type | \n",
+ " Solver | \n",
+ " Solver Time | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " Normal | \n",
+ " OptimalGlobal | \n",
+ " 153.675 | \n",
+ " 6 | \n",
+ " 7 | \n",
+ " LP | \n",
+ " CUOPT | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Solver Status Model Status Objective Num of Equations Num of Variables \\\n",
+ "0 Normal OptimalGlobal 153.675 6 7 \n",
+ "\n",
+ " Model Type Solver Solver Time \n",
+ "0 LP CUOPT 0.0 "
+ ]
+ },
+ "execution_count": 55,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import sys\n",
+ "import gamspy as gp\n",
+ "\n",
+ "gp.set_options({\"SOLVER_VALIDATION\": 0})\n",
+ "transport.solve(solver=\"cuopt\", output=sys.stdout)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Retrieving Results\n",
+ "### Variable Values\n",
+ "The values of the variables in the solution can be retrieved using using ``.records``. The level specifies the shipment quantities $x_{ij}$. Other variable attributes are the marginal values, lower and upper bounds, and the variable's scaling factor."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 56,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.454555Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.454455Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.458669Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.458521Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " | \n",
+ " level | \n",
+ " marginal | \n",
+ " lower | \n",
+ " upper | \n",
+ " scale | \n",
+ "
\n",
+ " \n",
+ " | i | \n",
+ " j | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | seattle | \n",
+ " new-york | \n",
+ " 50.0 | \n",
+ " 0.0000 | \n",
+ " 0.0 | \n",
+ " inf | \n",
+ " 1.0 | \n",
+ "
\n",
+ " \n",
+ " | chicago | \n",
+ " 300.0 | \n",
+ " 0.0000 | \n",
+ " 0.0 | \n",
+ " inf | \n",
+ " 1.0 | \n",
+ "
\n",
+ " \n",
+ " | topeka | \n",
+ " 0.0 | \n",
+ " 0.0180 | \n",
+ " 0.0 | \n",
+ " inf | \n",
+ " 1.0 | \n",
+ "
\n",
+ " \n",
+ " | san-diego | \n",
+ " new-york | \n",
+ " 275.0 | \n",
+ " 0.0000 | \n",
+ " 0.0 | \n",
+ " inf | \n",
+ " 1.0 | \n",
+ "
\n",
+ " \n",
+ " | chicago | \n",
+ " 0.0 | \n",
+ " 0.0045 | \n",
+ " 0.0 | \n",
+ " inf | \n",
+ " 1.0 | \n",
+ "
\n",
+ " \n",
+ " | topeka | \n",
+ " 275.0 | \n",
+ " 0.0000 | \n",
+ " 0.0 | \n",
+ " inf | \n",
+ " 1.0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " level marginal lower upper scale\n",
+ "i j \n",
+ "seattle new-york 50.0 0.0000 0.0 inf 1.0\n",
+ " chicago 300.0 0.0000 0.0 inf 1.0\n",
+ " topeka 0.0 0.0180 0.0 inf 1.0\n",
+ "san-diego new-york 275.0 0.0000 0.0 inf 1.0\n",
+ " chicago 0.0 0.0045 0.0 inf 1.0\n",
+ " topeka 275.0 0.0000 0.0 inf 1.0"
+ ]
+ },
+ "execution_count": 56,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "x.records.set_index([\"i\", \"j\"])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Objective Value\n",
+ "The optimal objective function value can be accessed by `.objective_value`."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 57,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2025-07-17T10:21:41.459304Z",
+ "iopub.status.busy": "2025-07-17T10:21:41.459237Z",
+ "iopub.status.idle": "2025-07-17T10:21:41.460707Z",
+ "shell.execute_reply": "2025-07-17T10:21:41.460556Z"
+ }
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "153.675"
+ ]
+ },
+ "execution_count": 57,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "transport.objective_value"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n",
+ "\n",
+ "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": ".venv",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.12.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}