{ "cells": [ { "cell_type": "markdown", "id": "7b46932b-0457-4480-9fea-3d17013c0fd6", "metadata": {}, "source": [ "# Unit Commitment\n", "\n", "The Unit Commitment problem is a fundamental problem in power systems. It is the scheduling of generators, in other words the decision if a unit is on or off for any given time in the planning horizon. The Unit Commitment includes constraints like capacity limits, ramping limitations, minimum runtimes, and minimum downtimes. The Security Constraint Unit Commitment also includes the system reserve requirements and network constraints." ] }, { "cell_type": "markdown", "id": "180c15cd-2425-48c1-a4f1-000711a98a49", "metadata": {}, "source": [ "**1. Load packages and useful definitions**\n", " - We are using the gurobipy package to formulate a mathematical model and solve it. " ] }, { "cell_type": "code", "execution_count": 4, "id": "971ac546-2b06-4b5b-b94b-14d9a5bd160a", "metadata": {}, "outputs": [], "source": [ "# import required packages\n", "\n", "import pandas as pd\n", "import numpy as np\n", "import math\n", "\n", "import gurobipy as gp\n", "from gurobipy import GRB\n", "\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 5, "id": "5738bd6c-0616-4a10-b4be-471c331bb6b5", "metadata": {}, "outputs": [], "source": [ "# some helpful definitions\n", "\n", "gen_colors = {\n", " \"Hydro\": \"#1f78b4\", # Deep Blue\n", " \"Nuclear\": \"#e31a1c\", # Red\n", " \"Coal\": \"#8b4513\", # Dark Brown\n", " \"Gas CC\": \"#8e44ad\", # Medium Purple\n", " \"Gas CT\": \"#a569bd\", # Light Purple\n", " \"Oil CT\": \"#4d4d4d\", # Dark Gray\n", " \"Wind\": \"#6baed6\", # Light Sky Blue\n", " \"PV\": \"#ff7f00\", # Bright Orange\n", " \"Storage\": \"#33a02c\" # Green\n", "}\n", "\n", "def print_gp_status(m):\n", " status = m.Status\n", " if status == GRB.OPTIMAL:\n", " print(\"The model is optimal.\")\n", " elif status == GRB.INFEASIBLE:\n", " print(\"The model is infeasible.\")\n", " elif status == GRB.UNBOUNDED:\n", " print(\"The model is unbounded.\")\n", " else:\n", " print(f\"Optimization ended with status {status}.\")\n", " print()\n", " return status" ] }, { "cell_type": "markdown", "id": "1fd2d996-30ee-415b-886e-fc65b8f2b866", "metadata": {}, "source": [ "**2. Read and prepare data**\n", "- The data we have are the various generator units.\n", "- It includes the unit type and the corresponding cost, startup cost and variable cost.\n", "- It also includes technical limitations like the installed amount, minimum generation levels, ramping rates, minimum down time and minimum up time (minimum run time). " ] }, { "cell_type": "code", "execution_count": 6, "id": "b41aa009-d7fb-4034-87e7-ea6da2f46552", "metadata": {}, "outputs": [], "source": [ "# read the data\n", "data_file = \"ts_and_gen_scuc.xlsx\"\n", "load_and_res_data = pd.read_excel(data_file, sheet_name=0)\n", "gen_data = pd.read_excel(data_file, sheet_name=1)" ] }, { "cell_type": "code", "execution_count": 7, "id": "4b21208e-1f61-4a56-8e6e-59485292ebe3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Gen ID | \n", "Unit Type | \n", "SU cost $ | \n", "Variable Cost USD/MWh | \n", "Installed in MW | \n", "PMin in MW | \n", "Ramp Rate in MW /hr | \n", "Min Down Time Hr | \n", "Min Up Time Hr | \n", "SR eligible | \n", "
---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "N1 | \n", "Nuclear | \n", "70.0 | \n", "3 | \n", "400 | \n", "300 | \n", "300 | \n", "48 | \n", "24 | \n", "0 | \n", "
1 | \n", "N2 | \n", "Nuclear | \n", "70.0 | \n", "3 | \n", "400 | \n", "300 | \n", "300 | \n", "48 | \n", "24 | \n", "0 | \n", "
2 | \n", "O1 | \n", "Oil CT | \n", "0.5 | \n", "50 | \n", "40 | \n", "10 | \n", "50 | \n", "1 | \n", "1 | \n", "1 | \n", "
3 | \n", "O2 | \n", "Oil CT | \n", "0.5 | \n", "50 | \n", "40 | \n", "10 | \n", "50 | \n", "1 | \n", "1 | \n", "1 | \n", "
4 | \n", "O3 | \n", "Oil CT | \n", "0.5 | \n", "50 | \n", "40 | \n", "10 | \n", "50 | \n", "1 | \n", "1 | \n", "1 | \n", "