From fc3c9e54a8d26fdea07ffc391c115159c47abb05 Mon Sep 17 00:00:00 2001
From: ktehranchi <83722342+ktehranchi@users.noreply.github.com>
Date: Mon, 16 Oct 2023 11:25:27 -0700
Subject: [PATCH 1/9] updates to run with mac/linux
---
match_model/notebooks/run_scenarios.ipynb | 190 +++++++++++++++++++--
match_model/reporting/generate_report.py | 7 +-
match_model/reporting/report_functions.py | 7 +-
match_model/reporting/summary_report.ipynb | 54 +++++-
4 files changed, 233 insertions(+), 25 deletions(-)
diff --git a/match_model/notebooks/run_scenarios.ipynb b/match_model/notebooks/run_scenarios.ipynb
index 5e1ce0e..c607033 100644
--- a/match_model/notebooks/run_scenarios.ipynb
+++ b/match_model/notebooks/run_scenarios.ipynb
@@ -21,7 +21,8 @@
"from pathlib import Path\n",
"import match_model.generate_input_files as generate_input_files\n",
"import shutil\n",
- "import time\n"
+ "import time\n",
+ "from nb_utilities import refresh_folder"
]
},
{
@@ -39,7 +40,7 @@
"outputs": [],
"source": [
"########################################################################\n",
- "model_run_location = '../../MODEL_RUNS/example'\n",
+ "model_run_location = '../../MODEL_RUNS/pce_example'\n",
"########################################################################\n",
"\n",
"# ensure that the filepath string uses forward slashes rather than backslashes\n",
@@ -69,9 +70,52 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Generating inputs now...\n",
+ "Setting up model directory...\n",
+ "Copying CBC solver to model run directory...\n",
+ "Loading data from model_inputs.xlsx\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/Users/kamrantehranchi/Local_Documents/MATCH-model/match_model/generate_input_files.py:304: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
+ " levelized_lrmers = pd.concat([levelized_lrmers, region_data], axis=0)\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Generating capacity factor timeseries for set_1\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/Users/kamrantehranchi/Local_Documents/MATCH-model/match_model/generate_input_files.py:912: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
+ " df_vcf = df_vcf.groupby(df_vcf.columns, axis=1).mean()\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Writing inputs for Annual_100 scenario...\n",
+ "Writing inputs for Hourly_90 scenario...\n",
+ "Writing inputs for Hourly_100 scenario...\n"
+ ]
+ }
+ ],
"source": [
"# check if the directory exists\n",
"if os.path.exists(model_workspace / \"inputs\"):\n",
@@ -114,6 +158,22 @@
" generate_input_files.generate_inputs(model_workspace)"
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### If you are Using a Mac please also run these commands:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# os.system(f'mv match_model/reporting/summary_report.ipynb {model_workspace}/inputs/')"
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {},
@@ -134,9 +194,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "This machine has 8 CPU cores\n",
+ "There are 3 scenarios to run\n",
+ "Running 3 scenarios in parallel...\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "sh: start: command not found\n",
+ "sh: start: command not found\n",
+ "sh: start: command not found\n"
+ ]
+ }
+ ],
"source": [
"num_processors = mp.cpu_count()\n",
"print(f\"This machine has {num_processors} CPU cores\")\n",
@@ -161,21 +240,29 @@
"source": [
"## Option 2: Start scenarios one at a time\n",
"\n",
- "If you would like to only open a single solver window, run the following cell. Each time you run the following cell will open a new parallel solver."
+ "If you would like to only open a single solver window, run the following cell. Each time you run the following cell will open a new parallel solver.\n",
+ "### Windows:"
]
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 6,
"metadata": {},
"outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "sh: start: command not found\n"
+ ]
+ },
{
"data": {
"text/plain": [
- "0"
+ "32512"
]
},
- "execution_count": 3,
+ "execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@@ -185,6 +272,87 @@
" f'start cmd /k \"cd {model_run_location} & activate match_model & match solve-scenarios\"'\n",
")"
]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Mac / Linux:"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "First Start with this cell. Your code will throw an error when generating summary reports. After this cell completes running you'll need to enter the {model_run_location} folder /inputs/{scenario_name}/summary_report.ipynb to run the python notebook to generate the report."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [
+ {
+ "ename": "SyntaxError",
+ "evalue": "unterminated string literal (detected at line 1) (3676248836.py, line 1)",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;36m Cell \u001b[0;32mIn[7], line 1\u001b[0;36m\u001b[0m\n\u001b[0;31m os.system(f'cd {model_run_location};\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unterminated string literal (detected at line 1)\n"
+ ]
+ }
+ ],
+ "source": [
+ "os.system(f'cd {model_run_location};\n",
+ " mamba activate match_model;\n",
+ " match solve-scenarios'\n",
+ " )"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Refresh Model Inputs\n",
+ "After you have run one scenario if you would like to rerun the scenario you will need to delete certain files.\n",
+ "\n",
+ "To regenerate the input dataset:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# list of files and folders to keep\n",
+ "keep_files = ['set_1', 'cbc', 'model_inputs.xlsx']\n",
+ "refresh_folder(model_workspace, keep_files=keep_files)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To rerun the match_model solver:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# list of files and folders to keep\n",
+ "keep_files = ['cbc' , 'inputs_version.txt' , 'options.txt', 'set_1', 'inputs', 'model_inputs.xlsx', 'outputs', 'scenarios.txt', 'summary_reports' ]\n",
+ "refresh_folder(model_workspace, keep_files=keep_files)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
@@ -203,7 +371,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.10.8"
+ "version": "3.10.12"
},
"orig_nbformat": 2,
"vscode": {
diff --git a/match_model/reporting/generate_report.py b/match_model/reporting/generate_report.py
index 054ba19..a0a8380 100644
--- a/match_model/reporting/generate_report.py
+++ b/match_model/reporting/generate_report.py
@@ -5,6 +5,8 @@
import shutil
+
+
def post_solve(instance, outdir, inputs_dir):
"""
Runs the summary report
@@ -12,8 +14,6 @@ def post_solve(instance, outdir, inputs_dir):
# get the name of the scenario
scenario = str(outdir).split("/")[-1]
- # shutil.copy('../reporting/summary_report.ipynb', inputs_dir)
-
# run the notebook
try:
os.system(
@@ -25,9 +25,10 @@ def post_solve(instance, outdir, inputs_dir):
os.system(
f'jupyter nbconvert --ExecutePreprocessor.kernel_name="python3" --to notebook --execute --inplace {inputs_dir}/summary_report.ipynb'
)
+
# convert the notebook to html and save it to the output directory
os.system(
f"jupyter nbconvert --to html --no-input --no-prompt {inputs_dir}/summary_report.ipynb --output-dir {outdir}/../../summary_reports --output summary_report_{scenario}"
)
# delete the notebook from the inputs directory
- os.remove(f"{inputs_dir}/summary_report.ipynb")
+ # os.remove(f"{inputs_dir}/summary_report.ipynb")
diff --git a/match_model/reporting/report_functions.py b/match_model/reporting/report_functions.py
index 25d5140..4b11449 100644
--- a/match_model/reporting/report_functions.py
+++ b/match_model/reporting/report_functions.py
@@ -474,11 +474,11 @@ def calculate_generator_utilization(dispatch):
# calculate total annual generation in each category
utilization = (
- dispatch.copy().drop(columns="Nodal_Price").groupby("generation_project").sum()
+ dispatch.copy().drop(columns=["Nodal_Price"]).groupby("generation_project").sum()
)
# sum all rows
- utilization["Total"] = utilization.sum(axis=1)
+ utilization["Total"] = utilization.drop(columns=["timestamp","gen_tech"]).sum(axis=1)
# drop rows with zero generation
utilization = utilization[utilization["Total"] > 0]
@@ -1448,7 +1448,7 @@ def build_month_hour_dispatch_plot(
"""
mh_dispatch = dispatch_by_tech.copy()
- mh_dispatch = mh_dispatch.set_index("timestamp")
+ mh_dispatch = mh_dispatch.drop(columns=['Generation Type']).set_index("timestamp")
# groupby month and hour
mh_dispatch = mh_dispatch.groupby(
@@ -1770,6 +1770,7 @@ def build_open_position_plot(load_balance, storage_exists):
"""
# merge mismatch data
mismatch = load_balance.copy()
+ mismatch.drop(columns='load_zone', inplace=True)
mismatch["timestamp"] = pd.to_datetime(mismatch["timestamp"])
mismatch["Net generation"] = (
diff --git a/match_model/reporting/summary_report.ipynb b/match_model/reporting/summary_report.ipynb
index 65fc526..288e1bd 100644
--- a/match_model/reporting/summary_report.ipynb
+++ b/match_model/reporting/summary_report.ipynb
@@ -9,7 +9,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2022-01-05T21:02:21.991676Z",
@@ -18,11 +18,48 @@
"shell.execute_reply": "2022-01-05T21:02:23.269726Z"
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ " \n",
+ " "
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Scenario Name: /Users/kamrantehranchi/Local_Documents/MATCH-model/match_model/reporting\n"
+ ]
+ }
+ ],
"source": [
"# Copyright (c) 2022 The MATCH Authors. All rights reserved.\n",
"# Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (or later), which is in the LICENSE file.\n",
- "\n",
+ "print('entered summary_report.py')\n",
"from pathlib import Path\n",
"import pandas as pd\n",
"import plotly.express as px\n",
@@ -33,14 +70,14 @@
"from match_model.reporting.report_functions import *\n",
"\n",
"#get the name of the current directory to specify the scenario name and identify the output directory\n",
- "scenario_name = str(Path.cwd()).split('\\\\')[-1]\n",
+ "scenario_name = Path.cwd().name\n",
"if scenario_name == 'inputs':\n",
" data_dir = Path.cwd() / '../outputs/'\n",
" inputs_dir = Path.cwd() / '../inputs/'\n",
" scenario_output_dir = Path.cwd() / '../summary_reports/'\n",
" scenario_name = 'N/A'\n",
"else:\n",
- " data_dir = Path.cwd()/ f'../../outputs/{scenario_name}/'\n",
+ " data_dir = Path.cwd() / f'../../outputs/{scenario_name}/'\n",
" inputs_dir = Path.cwd() / f'../../inputs/{scenario_name}/'\n",
" scenario_output_dir = Path.cwd() / '../../summary_reports/'\n",
"\n",
@@ -786,7 +823,7 @@
"lr_generation_impact = lrmer_pivot.mul(addl_dispatch, axis=0, level=1).sum(axis=1)\n",
"# calculate annual total for each scenario\n",
"lr_generation_impact = (\n",
- " lr_generation_impact.reset_index().groupby(\"cambium_scenario\").sum()\n",
+ " lr_generation_impact.reset_index().drop(columns=['timestamp']).groupby(\"cambium_scenario\").sum()\n",
")\n",
"lr_generation_impact = lr_generation_impact.rename(\n",
" columns={0: f'Generation {emissions_unit.split(\"/\")[0]}'}\n",
@@ -795,7 +832,8 @@
"# multiply the storage and mer data\n",
"lr_storage_impact = lrmer_pivot.mul(addl_storage_dispatch, axis=0, level=1).sum(axis=1)\n",
"# calculate annual total for each scenario\n",
- "lr_storage_impact = lr_storage_impact.reset_index().groupby(\"cambium_scenario\").sum()\n",
+ "\n",
+ "lr_storage_impact = lr_storage_impact.reset_index().drop(columns=['timestamp']).groupby(\"cambium_scenario\").sum()\n",
"lr_storage_impact = lr_storage_impact.rename(\n",
" columns={0: f'Storage {emissions_unit.split(\"/\")[0]}'}\n",
")\n",
@@ -1068,7 +1106,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:16:33) [MSC v.1929 64 bit (AMD64)]"
+ "version": "3.10.12"
},
"vscode": {
"interpreter": {
From 6e376031a0fdc12696d1e6d9fc4fb0210eaa7996 Mon Sep 17 00:00:00 2001
From: ktehranchi <83722342+ktehranchi@users.noreply.github.com>
Date: Mon, 16 Oct 2023 11:31:41 -0700
Subject: [PATCH 2/9] env version specs
---
environment.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/environment.yml b/environment.yml
index 0c495fc..1e7093f 100644
--- a/environment.yml
+++ b/environment.yml
@@ -10,7 +10,7 @@ dependencies:
- ipython # BSD License
- nbconvert # BSD-3-Clause license
- nbformat # BSD-3-Clause license
- - nrel-pysam>=3.0.1 # BSD-3-Clause license
+ - nrel-pysam==3.0.2 # BSD-3-Clause license
- nrel-pysam-stubs # BSD-3-Clause license
- numpy # BSD-3-Clause license
- openpyxl # MIT license
From df35586342a31f68dd1b5d19598d59de77660f2d Mon Sep 17 00:00:00 2001
From: ktehranchi <83722342+ktehranchi@users.noreply.github.com>
Date: Mon, 16 Oct 2023 14:23:40 -0700
Subject: [PATCH 3/9] Changes made to fix solving. Tested from scratch and
functions correctly.
---
match_model/notebooks/nb_utilities.py | 16 ++++++++++
match_model/notebooks/run_scenarios.ipynb | 39 +++++++++++------------
match_model/solve.py | 21 ++++++++----
3 files changed, 49 insertions(+), 27 deletions(-)
create mode 100644 match_model/notebooks/nb_utilities.py
diff --git a/match_model/notebooks/nb_utilities.py b/match_model/notebooks/nb_utilities.py
new file mode 100644
index 0000000..891e3ae
--- /dev/null
+++ b/match_model/notebooks/nb_utilities.py
@@ -0,0 +1,16 @@
+import os, shutil
+
+
+def refresh_folder(model_workspace, keep_files):
+ # loop through all files and folders in model_workspace
+ for file in os.listdir(model_workspace):
+ # if the file is not in the keep_files list
+ if file not in keep_files:
+ # if the file is a folder
+ if os.path.isdir(os.path.join(model_workspace, file)):
+ # remove the folder and all its contents
+ shutil.rmtree(os.path.join(model_workspace, file))
+ # if the file is a file
+ else:
+ # remove the file
+ os.remove(os.path.join(model_workspace, file))
\ No newline at end of file
diff --git a/match_model/notebooks/run_scenarios.ipynb b/match_model/notebooks/run_scenarios.ipynb
index c607033..ed6b313 100644
--- a/match_model/notebooks/run_scenarios.ipynb
+++ b/match_model/notebooks/run_scenarios.ipynb
@@ -9,7 +9,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@@ -35,7 +35,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@@ -70,7 +70,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 5,
"metadata": {},
"outputs": [
{
@@ -80,7 +80,8 @@
"Generating inputs now...\n",
"Setting up model directory...\n",
"Copying CBC solver to model run directory...\n",
- "Loading data from model_inputs.xlsx\n"
+ "Loading data from model_inputs.xlsx\n",
+ "Downloading Cambium data for the following GEA Regions: ['CAMXc']\n"
]
},
{
@@ -102,7 +103,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "/Users/kamrantehranchi/Local_Documents/MATCH-model/match_model/generate_input_files.py:912: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
+ "/Users/kamrantehranchi/Local_Documents/MATCH-model/match_model/generate_input_files.py:914: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
" df_vcf = df_vcf.groupby(df_vcf.columns, axis=1).mean()\n"
]
},
@@ -181,6 +182,13 @@
"# Solve Model Scenarios"
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Windows Operating Systems:"
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {},
@@ -240,8 +248,7 @@
"source": [
"## Option 2: Start scenarios one at a time\n",
"\n",
- "If you would like to only open a single solver window, run the following cell. Each time you run the following cell will open a new parallel solver.\n",
- "### Windows:"
+ "If you would like to only open a single solver window, run the following cell. Each time you run the following cell will open a new parallel solver."
]
},
{
@@ -277,7 +284,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Mac / Linux:"
+ "## Running with Mac / Linux:"
]
},
{
@@ -302,10 +309,7 @@
}
],
"source": [
- "os.system(f'cd {model_run_location};\n",
- " mamba activate match_model;\n",
- " match solve-scenarios'\n",
- " )"
+ "os.system(f'cd {model_run_location}; mamba activate match_model; match solve-scenarios')"
]
},
{
@@ -333,12 +337,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "To rerun the match_model solver:"
+ "To rerun the match_model solver.... ie to run \"match solve-scenarios\":"
]
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -346,13 +350,6 @@
"keep_files = ['cbc' , 'inputs_version.txt' , 'options.txt', 'set_1', 'inputs', 'model_inputs.xlsx', 'outputs', 'scenarios.txt', 'summary_reports' ]\n",
"refresh_folder(model_workspace, keep_files=keep_files)"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
diff --git a/match_model/solve.py b/match_model/solve.py
index 30033d2..90accd9 100644
--- a/match_model/solve.py
+++ b/match_model/solve.py
@@ -841,9 +841,18 @@ def solve(model):
# with its own solver object (e.g., with runph or a parallel solver server).
# In those cases, we don't want to go through the expense of creating an
# unused solver object, or get errors if the solver options are invalid.
- model.solver = SolverFactory(
- model.options.solver, solver_io=model.options.solver_io
- )
+
+ # Uncomment Below if you are want to use old MATCH Model behaviour that works for windows
+ # model.solver = SolverFactory(
+ # model.options.solver, solver_io=model.options.solver_io
+ # )
+
+ # Use for Mac.
+ model.solver = SolverFactory(model.options.solver)
+ solvername = 'cbc'
+ solverpath_exe = os.getcwd() + '/cbc'
+ model.solver=SolverFactory(solvername,executable=solverpath_exe)
+
# patch for Pyomo < 4.2
# note: Pyomo added an options_string argument to solver.solve() in Pyomo 4.2 rev 10587.
@@ -857,7 +866,6 @@ def solve(model):
).items():
model.solver.options[k] = v
- # import pdb; pdb.set_trace()
model.solver_manager = SolverManagerFactory(model.options.solver_manager)
# get solver arguments
@@ -899,8 +907,9 @@ def solve(model):
TempfileManager.tempdir = model.options.tempdir
- results = model.solver_manager.solve(model, opt=model.solver, **solver_args)
- # import pdb; pdb.set_trace()
+ # results = model.solver_manager.solve(model, opt=model.solver, **solver_args)
+ results = SolverFactory("cbc").solve(model)#, **solver_args) #add the solver options parameters
+
if model.options.verbose:
print(
From 14f9aa6437faa62e1c810dca4165d9e658581e7a Mon Sep 17 00:00:00 2001
From: ktehranchi <83722342+ktehranchi@users.noreply.github.com>
Date: Mon, 23 Oct 2023 09:07:40 -0700
Subject: [PATCH 4/9] Add cbc file name alternative
---
match_model/generate_input_files.py | 5 ++++-
match_model/notebooks/run_scenarios.ipynb | 24 +++++++++++++++++++++--
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/match_model/generate_input_files.py b/match_model/generate_input_files.py
index ca28ddf..94438fd 100644
--- a/match_model/generate_input_files.py
+++ b/match_model/generate_input_files.py
@@ -369,7 +369,10 @@ def generate_inputs(model_workspace):
if solver == "cbc":
print("Copying CBC solver to model run directory...")
# copy the cbc solver to the model workspace
- shutil.copy("../../cbc.exe", model_workspace)
+ if os.path.exists("../../cbc"):
+ shutil.copy("../../cbc", model_workspace)
+ elif os.path.exists("../../cbc.exe"):
+ shutil.copy("../../cbc.exe", model_workspace)
# create the scenario folders in the input and output directories
try:
diff --git a/match_model/notebooks/run_scenarios.ipynb b/match_model/notebooks/run_scenarios.ipynb
index ed6b313..0082db6 100644
--- a/match_model/notebooks/run_scenarios.ipynb
+++ b/match_model/notebooks/run_scenarios.ipynb
@@ -9,7 +9,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -25,6 +25,26 @@
"from nb_utilities import refresh_folder"
]
},
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/notebooks'"
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "os.getcwd()"
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {},
@@ -40,7 +60,7 @@
"outputs": [],
"source": [
"########################################################################\n",
- "model_run_location = '../../MODEL_RUNS/pce_example'\n",
+ "model_run_location = '../../MODEL_RUNS/example'\n",
"########################################################################\n",
"\n",
"# ensure that the filepath string uses forward slashes rather than backslashes\n",
From a385a0f4df2bf90d2d347ca94cd83a23ceab0d8e Mon Sep 17 00:00:00 2001
From: ktehranchi <83722342+ktehranchi@users.noreply.github.com>
Date: Mon, 23 Oct 2023 14:11:56 -0700
Subject: [PATCH 5/9] update run_scenarios
---
match_model/notebooks/run_scenarios.ipynb | 241 +++++++++++++++-------
1 file changed, 171 insertions(+), 70 deletions(-)
diff --git a/match_model/notebooks/run_scenarios.ipynb b/match_model/notebooks/run_scenarios.ipynb
index 0082db6..8190563 100644
--- a/match_model/notebooks/run_scenarios.ipynb
+++ b/match_model/notebooks/run_scenarios.ipynb
@@ -25,26 +25,6 @@
"from nb_utilities import refresh_folder"
]
},
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "'/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/notebooks'"
- ]
- },
- "execution_count": 2,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "os.getcwd()"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -55,12 +35,12 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"########################################################################\n",
- "model_run_location = '../../MODEL_RUNS/example'\n",
+ "model_run_location = '../../MODEL_RUNS/homework2_solutions'\n",
"########################################################################\n",
"\n",
"# ensure that the filepath string uses forward slashes rather than backslashes\n",
@@ -90,25 +70,23 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Generating inputs now...\n",
"Setting up model directory...\n",
"Copying CBC solver to model run directory...\n",
- "Loading data from model_inputs.xlsx\n",
- "Downloading Cambium data for the following GEA Regions: ['CAMXc']\n"
+ "Loading data from model_inputs.xlsx\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "/Users/kamrantehranchi/Local_Documents/MATCH-model/match_model/generate_input_files.py:304: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
+ "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:304: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
" levelized_lrmers = pd.concat([levelized_lrmers, region_data], axis=0)\n"
]
},
@@ -123,17 +101,159 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "/Users/kamrantehranchi/Local_Documents/MATCH-model/match_model/generate_input_files.py:914: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
- " df_vcf = df_vcf.groupby(df_vcf.columns, axis=1).mean()\n"
+ "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:915: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
+ " df_vcf = df_vcf.groupby(df_vcf.columns, axis=1).mean()\n",
+ "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:89: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas. Value '20.752' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.\n",
+ " xl_gen_validated.loc[\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Writing inputs for Annual_100 scenario...\n",
+ "WARNING: Generic_DesertSolar nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $40.0 per MWh\n",
+ "Mean nodal revenue = $60.742 per MWh\n",
+ "WARNING: Generic_ValleySolar nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $42.0 per MWh\n",
+ "Mean nodal revenue = $81.911 per MWh\n",
+ "WARNING: Generic_NorthCalWind nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $80.0 per MWh\n",
+ "Mean nodal revenue = $88.987 per MWh\n",
+ "WARNING: Generic_SouthCalWind nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $75.0 per MWh\n",
+ "Mean nodal revenue = $88.2 per MWh\n",
"Writing inputs for Hourly_90 scenario...\n",
- "Writing inputs for Hourly_100 scenario...\n"
+ "Generating capacity factor timeseries for set_2\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:915: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
+ " df_vcf = df_vcf.groupby(df_vcf.columns, axis=1).mean()\n",
+ "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:89: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas. Value '20.752' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.\n",
+ " xl_gen_validated.loc[\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "WARNING: Generic_DesertSolar nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $40.0 per MWh\n",
+ "Mean nodal revenue = $60.742 per MWh\n",
+ "WARNING: Generic_ValleySolar nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $42.0 per MWh\n",
+ "Mean nodal revenue = $81.911 per MWh\n",
+ "WARNING: Generic_NorthCalWind nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $80.0 per MWh\n",
+ "Mean nodal revenue = $88.987 per MWh\n",
+ "WARNING: Generic_SouthCalWind nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $75.0 per MWh\n",
+ "Mean nodal revenue = $88.2 per MWh\n",
+ "WARNING: Generic_Geothermal_high nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $90.0 per MWh\n",
+ "Mean nodal revenue = $90.758 per MWh\n",
+ "Writing inputs for Hourly_90_Geo scenario...\n",
+ "Generating capacity factor timeseries for set_3\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:915: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
+ " df_vcf = df_vcf.groupby(df_vcf.columns, axis=1).mean()\n",
+ "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:89: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas. Value '20.752' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.\n",
+ " xl_gen_validated.loc[\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "WARNING: Generic_DesertSolar nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $40.0 per MWh\n",
+ "Mean nodal revenue = $60.742 per MWh\n",
+ "WARNING: Generic_ValleySolar nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $42.0 per MWh\n",
+ "Mean nodal revenue = $81.911 per MWh\n",
+ "WARNING: Generic_NorthCalWind nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $80.0 per MWh\n",
+ "Mean nodal revenue = $88.987 per MWh\n",
+ "WARNING: Generic_SouthCalWind nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $75.0 per MWh\n",
+ "Mean nodal revenue = $88.2 per MWh\n",
+ "WARNING: Generic_Geothermal_high nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $90.0 per MWh\n",
+ "Mean nodal revenue = $90.758 per MWh\n",
+ "WARNING: Generic_Geothermal_mid nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $80.0 per MWh\n",
+ "Mean nodal revenue = $90.758 per MWh\n",
+ "Writing inputs for Hourly_90_Geo2 scenario...\n",
+ "Generating capacity factor timeseries for set_4\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:915: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
+ " df_vcf = df_vcf.groupby(df_vcf.columns, axis=1).mean()\n",
+ "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:89: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas. Value '20.752' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.\n",
+ " xl_gen_validated.loc[\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "WARNING: Generic_DesertSolar nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $40.0 per MWh\n",
+ "Mean nodal revenue = $60.742 per MWh\n",
+ "WARNING: Generic_ValleySolar nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $42.0 per MWh\n",
+ "Mean nodal revenue = $81.911 per MWh\n",
+ "WARNING: Generic_NorthCalWind nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $80.0 per MWh\n",
+ "Mean nodal revenue = $88.987 per MWh\n",
+ "WARNING: Generic_SouthCalWind nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $75.0 per MWh\n",
+ "Mean nodal revenue = $88.2 per MWh\n",
+ "WARNING: Generic_Geothermal_high nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $90.0 per MWh\n",
+ "Mean nodal revenue = $90.758 per MWh\n",
+ "WARNING: Generic_Geothermal_mid nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $80.0 per MWh\n",
+ "Mean nodal revenue = $90.758 per MWh\n",
+ "WARNING: Generic_Geothermal_low nodal revenue greater than PPA cost\n",
+ "This may lead to over-procurement of this resource\n",
+ "Mean PPA cost = $70.0 per MWh\n",
+ "Mean nodal revenue = $90.758 per MWh\n",
+ "Writing inputs for Hourly_90_Geo3 scenario...\n"
]
}
],
@@ -141,6 +261,10 @@
"# check if the directory exists\n",
"if os.path.exists(model_workspace / \"inputs\"):\n",
" # check that an inputs version file exists\n",
+ " # list of files and folders to keep\n",
+ " keep_files = ['set_1','set_2','set_3', 'set_4', 'cbc', 'model_inputs.xlsx']\n",
+ " refresh_folder(model_workspace, keep_files=keep_files)\n",
+ "\n",
" if os.path.exists(model_workspace / \"inputs_version.txt\"):\n",
" # get the version number\n",
" with open(model_workspace / \"inputs_version.txt\", \"r\") as i:\n",
@@ -179,22 +303,6 @@
" generate_input_files.generate_inputs(model_workspace)"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### If you are Using a Mac please also run these commands:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [],
- "source": [
- "# os.system(f'mv match_model/reporting/summary_report.ipynb {model_workspace}/inputs/')"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -230,16 +338,14 @@
"output_type": "stream",
"text": [
"This machine has 8 CPU cores\n",
- "There are 3 scenarios to run\n",
- "Running 3 scenarios in parallel...\n"
+ "There are 1 scenarios to run\n",
+ "Running 1 scenarios in parallel...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "sh: start: command not found\n",
- "sh: start: command not found\n",
"sh: start: command not found\n"
]
}
@@ -311,32 +417,27 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "First Start with this cell. Your code will throw an error when generating summary reports. After this cell completes running you'll need to enter the {model_run_location} folder /inputs/{scenario_name}/summary_report.ipynb to run the python notebook to generate the report."
+ "Steps to run on mac:\n",
+ "1. open Terminal, and navigate to the folder with the homework/model_inputs.xslx.\n",
+ "2. Run `mamba activate match_model` \n",
+ "3. run `match solve-scenarios`\n",
+ "\n",
+ "Your code may throw an error when generating summary reports. If this happens- you'll need to enter the {model_run_location} folder /inputs/{scenario_name}/summary_report.ipynb to run the python notebook to generate the report.\n",
+ "\n",
+ "If not you can open the summary_reports/ ...._.html file in a browser and investigate the results of your model run.\n",
+ "\n"
]
},
{
- "cell_type": "code",
- "execution_count": 7,
+ "cell_type": "markdown",
"metadata": {},
- "outputs": [
- {
- "ename": "SyntaxError",
- "evalue": "unterminated string literal (detected at line 1) (3676248836.py, line 1)",
- "output_type": "error",
- "traceback": [
- "\u001b[0;36m Cell \u001b[0;32mIn[7], line 1\u001b[0;36m\u001b[0m\n\u001b[0;31m os.system(f'cd {model_run_location};\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unterminated string literal (detected at line 1)\n"
- ]
- }
- ],
- "source": [
- "os.system(f'cd {model_run_location}; mamba activate match_model; match solve-scenarios')"
- ]
+ "source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "# Refresh Model Inputs\n",
+ "# Helpers for Rerunning Model\n",
"After you have run one scenario if you would like to rerun the scenario you will need to delete certain files.\n",
"\n",
"To regenerate the input dataset:"
@@ -344,7 +445,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
@@ -362,7 +463,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
From 32fdfcaaf65e52712fb1041e2e6e279098238765 Mon Sep 17 00:00:00 2001
From: ktehranchi <83722342+ktehranchi@users.noreply.github.com>
Date: Mon, 23 Oct 2023 14:42:46 -0700
Subject: [PATCH 6/9] update
---
match_model/notebooks/run_scenarios.ipynb | 241 +--------------------
match_model/reporting/summary_report.ipynb | 41 +---
2 files changed, 13 insertions(+), 269 deletions(-)
diff --git a/match_model/notebooks/run_scenarios.ipynb b/match_model/notebooks/run_scenarios.ipynb
index 8190563..415d02e 100644
--- a/match_model/notebooks/run_scenarios.ipynb
+++ b/match_model/notebooks/run_scenarios.ipynb
@@ -9,7 +9,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -35,12 +35,12 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"########################################################################\n",
- "model_run_location = '../../MODEL_RUNS/homework2_solutions'\n",
+ "model_run_location = '../../MODEL_RUNS/example'\n",
"########################################################################\n",
"\n",
"# ensure that the filepath string uses forward slashes rather than backslashes\n",
@@ -70,193 +70,9 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Setting up model directory...\n",
- "Copying CBC solver to model run directory...\n",
- "Loading data from model_inputs.xlsx\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:304: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
- " levelized_lrmers = pd.concat([levelized_lrmers, region_data], axis=0)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Generating capacity factor timeseries for set_1\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:915: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
- " df_vcf = df_vcf.groupby(df_vcf.columns, axis=1).mean()\n",
- "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:89: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas. Value '20.752' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.\n",
- " xl_gen_validated.loc[\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "WARNING: Generic_DesertSolar nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $40.0 per MWh\n",
- "Mean nodal revenue = $60.742 per MWh\n",
- "WARNING: Generic_ValleySolar nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $42.0 per MWh\n",
- "Mean nodal revenue = $81.911 per MWh\n",
- "WARNING: Generic_NorthCalWind nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $80.0 per MWh\n",
- "Mean nodal revenue = $88.987 per MWh\n",
- "WARNING: Generic_SouthCalWind nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $75.0 per MWh\n",
- "Mean nodal revenue = $88.2 per MWh\n",
- "Writing inputs for Hourly_90 scenario...\n",
- "Generating capacity factor timeseries for set_2\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:915: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
- " df_vcf = df_vcf.groupby(df_vcf.columns, axis=1).mean()\n",
- "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:89: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas. Value '20.752' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.\n",
- " xl_gen_validated.loc[\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "WARNING: Generic_DesertSolar nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $40.0 per MWh\n",
- "Mean nodal revenue = $60.742 per MWh\n",
- "WARNING: Generic_ValleySolar nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $42.0 per MWh\n",
- "Mean nodal revenue = $81.911 per MWh\n",
- "WARNING: Generic_NorthCalWind nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $80.0 per MWh\n",
- "Mean nodal revenue = $88.987 per MWh\n",
- "WARNING: Generic_SouthCalWind nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $75.0 per MWh\n",
- "Mean nodal revenue = $88.2 per MWh\n",
- "WARNING: Generic_Geothermal_high nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $90.0 per MWh\n",
- "Mean nodal revenue = $90.758 per MWh\n",
- "Writing inputs for Hourly_90_Geo scenario...\n",
- "Generating capacity factor timeseries for set_3\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:915: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
- " df_vcf = df_vcf.groupby(df_vcf.columns, axis=1).mean()\n",
- "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:89: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas. Value '20.752' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.\n",
- " xl_gen_validated.loc[\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "WARNING: Generic_DesertSolar nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $40.0 per MWh\n",
- "Mean nodal revenue = $60.742 per MWh\n",
- "WARNING: Generic_ValleySolar nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $42.0 per MWh\n",
- "Mean nodal revenue = $81.911 per MWh\n",
- "WARNING: Generic_NorthCalWind nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $80.0 per MWh\n",
- "Mean nodal revenue = $88.987 per MWh\n",
- "WARNING: Generic_SouthCalWind nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $75.0 per MWh\n",
- "Mean nodal revenue = $88.2 per MWh\n",
- "WARNING: Generic_Geothermal_high nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $90.0 per MWh\n",
- "Mean nodal revenue = $90.758 per MWh\n",
- "WARNING: Generic_Geothermal_mid nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $80.0 per MWh\n",
- "Mean nodal revenue = $90.758 per MWh\n",
- "Writing inputs for Hourly_90_Geo2 scenario...\n",
- "Generating capacity factor timeseries for set_4\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:915: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.\n",
- " df_vcf = df_vcf.groupby(df_vcf.columns, axis=1).mean()\n",
- "/Users/kamrantehranchi/Local_Documents/ENERGY276/MATCH-model/match_model/generate_input_files.py:89: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas. Value '20.752' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.\n",
- " xl_gen_validated.loc[\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "WARNING: Generic_DesertSolar nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $40.0 per MWh\n",
- "Mean nodal revenue = $60.742 per MWh\n",
- "WARNING: Generic_ValleySolar nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $42.0 per MWh\n",
- "Mean nodal revenue = $81.911 per MWh\n",
- "WARNING: Generic_NorthCalWind nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $80.0 per MWh\n",
- "Mean nodal revenue = $88.987 per MWh\n",
- "WARNING: Generic_SouthCalWind nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $75.0 per MWh\n",
- "Mean nodal revenue = $88.2 per MWh\n",
- "WARNING: Generic_Geothermal_high nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $90.0 per MWh\n",
- "Mean nodal revenue = $90.758 per MWh\n",
- "WARNING: Generic_Geothermal_mid nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $80.0 per MWh\n",
- "Mean nodal revenue = $90.758 per MWh\n",
- "WARNING: Generic_Geothermal_low nodal revenue greater than PPA cost\n",
- "This may lead to over-procurement of this resource\n",
- "Mean PPA cost = $70.0 per MWh\n",
- "Mean nodal revenue = $90.758 per MWh\n",
- "Writing inputs for Hourly_90_Geo3 scenario...\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"# check if the directory exists\n",
"if os.path.exists(model_workspace / \"inputs\"):\n",
@@ -330,26 +146,9 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "This machine has 8 CPU cores\n",
- "There are 1 scenarios to run\n",
- "Running 1 scenarios in parallel...\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "sh: start: command not found\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"num_processors = mp.cpu_count()\n",
"print(f\"This machine has {num_processors} CPU cores\")\n",
@@ -379,27 +178,9 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "sh: start: command not found\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "32512"
- ]
- },
- "execution_count": 6,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"os.system(\n",
" f'start cmd /k \"cd {model_run_location} & activate match_model & match solve-scenarios\"'\n",
@@ -445,7 +226,7 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -463,7 +244,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
diff --git a/match_model/reporting/summary_report.ipynb b/match_model/reporting/summary_report.ipynb
index 288e1bd..93c29ec 100644
--- a/match_model/reporting/summary_report.ipynb
+++ b/match_model/reporting/summary_report.ipynb
@@ -9,7 +9,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-01-05T21:02:21.991676Z",
@@ -18,44 +18,7 @@
"shell.execute_reply": "2022-01-05T21:02:23.269726Z"
}
},
- "outputs": [
- {
- "data": {
- "text/html": [
- " \n",
- " "
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Scenario Name: /Users/kamrantehranchi/Local_Documents/MATCH-model/match_model/reporting\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"# Copyright (c) 2022 The MATCH Authors. All rights reserved.\n",
"# Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (or later), which is in the LICENSE file.\n",
From 7c57b1335d4a0b6602138c852ab92d79d8fe7cdc Mon Sep 17 00:00:00 2001
From: ktehranchi <83722342+ktehranchi@users.noreply.github.com>
Date: Wed, 25 Oct 2023 16:14:43 -0700
Subject: [PATCH 7/9] update env package versions
---
environment.yml | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/environment.yml b/environment.yml
index 1e7093f..68b8410 100644
--- a/environment.yml
+++ b/environment.yml
@@ -4,22 +4,22 @@ channels:
- conda-forge
- defaults
dependencies:
- - cloudpickle # BSD-3-Clause license
- - glpk # GNU GPL license
- - ipykernel # BSD-3-Clause license
- - ipython # BSD License
- - nbconvert # BSD-3-Clause license
- - nbformat # BSD-3-Clause license
+ - cloudpickle==3.0.0 # BSD-3-Clause license
+ - glpk==5.0 # GNU GPL license
+ - ipykernel==6.26.0 # BSD-3-Clause license
+ - ipython==8.16.1 # BSD License
+ - nbconvert==7.9.2 # BSD-3-Clause license
+ - nbformat==5.9.2 # BSD-3-Clause license
- nrel-pysam==3.0.2 # BSD-3-Clause license
- nrel-pysam-stubs # BSD-3-Clause license
- - numpy # BSD-3-Clause license
- - openpyxl # MIT license
- - pandas # BSD-3-Clause license
- - pint # BSD license
- - plotly # MIT license
- - pyomo>=6.0.0,<=6.4.0 # BSD license
- - python>=2.7.12 # Python Software Foundation License
+ - numpy==1.26.0 # BSD-3-Clause license
+ - openpyxl==3.1.2 # MIT license
+ - pandas==2.1.1 # BSD-3-Clause license
+ - pint==0.22 # BSD license
+ - plotly==5.17.0 # MIT license
+ - pyomo==6.4.0 # BSD license
+ - python==3.10.12 # Python Software Foundation License
- pytz # MIT license
- - pyutilib>=6.0.0 # GNU AGPLv3 license
- - requests # Apache 2.0 license
- - xlrd # BSD license
\ No newline at end of file
+ - pyutilib==6.0.0 # GNU AGPLv3 license
+ - requests==2.31.0 # Apache 2.0 license
+ - xlrd==2.0.1 # BSD license
\ No newline at end of file
From 4d8bc4f821a056e3a334262ccf78db49d5c27e98 Mon Sep 17 00:00:00 2001
From: ktehranchi <83722342+ktehranchi@users.noreply.github.com>
Date: Wed, 25 Oct 2023 16:43:25 -0700
Subject: [PATCH 8/9] simplify run_scenarios
---
match_model/notebooks/run_scenarios.ipynb | 43 -----------------------
1 file changed, 43 deletions(-)
diff --git a/match_model/notebooks/run_scenarios.ipynb b/match_model/notebooks/run_scenarios.ipynb
index 415d02e..50cf8c7 100644
--- a/match_model/notebooks/run_scenarios.ipynb
+++ b/match_model/notebooks/run_scenarios.ipynb
@@ -133,49 +133,6 @@
"## Windows Operating Systems:"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Option 1: Run as many parallel threads as possible\n",
- "\n",
- "If you would like to run as many scenarios in parallel as your machine can support, run the following cell. \n",
- "\n",
- "This will identify how many processor cores (n) exist on your machine, and automatically run (n-1) scenarios (or the total number of scnearios, whichever is less). This should leave at least one core of your machine open for other tasks, but we still recommend that you close all other windows/processes before starting this option."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "num_processors = mp.cpu_count()\n",
- "print(f\"This machine has {num_processors} CPU cores\")\n",
- "# get the number of scenarios to run\n",
- "num_scenarios = len(os.listdir(model_workspace / \"inputs\"))\n",
- "print(f\"There are {num_scenarios} scenarios to run\")\n",
- "# determine how many threads to open\n",
- "parallel_threads = min(num_processors - 1, num_scenarios)\n",
- "print(f\"Running {parallel_threads} scenarios in parallel...\")\n",
- "i = 0\n",
- "while i < parallel_threads:\n",
- " os.system(\n",
- " f'start cmd /k \"cd {model_run_location} & activate match_model & match solve-scenarios\"'\n",
- " )\n",
- " time.sleep(2)\n",
- " i += 1"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Option 2: Start scenarios one at a time\n",
- "\n",
- "If you would like to only open a single solver window, run the following cell. Each time you run the following cell will open a new parallel solver."
- ]
- },
{
"cell_type": "code",
"execution_count": null,
From 819a61c14e66785c893391ce311a1114f6d0ac75 Mon Sep 17 00:00:00 2001
From: ktehranchi <83722342+ktehranchi@users.noreply.github.com>
Date: Thu, 26 Oct 2023 15:16:11 -0700
Subject: [PATCH 9/9] update run_scenarios
---
match_model/notebooks/run_scenarios.ipynb | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/match_model/notebooks/run_scenarios.ipynb b/match_model/notebooks/run_scenarios.ipynb
index 50cf8c7..3ec13ce 100644
--- a/match_model/notebooks/run_scenarios.ipynb
+++ b/match_model/notebooks/run_scenarios.ipynb
@@ -78,7 +78,7 @@
"if os.path.exists(model_workspace / \"inputs\"):\n",
" # check that an inputs version file exists\n",
" # list of files and folders to keep\n",
- " keep_files = ['set_1','set_2','set_3', 'set_4', 'cbc', 'model_inputs.xlsx']\n",
+ " keep_files = ['set_1','set_2','set_3', 'set_4', 'cbc', 'cbc.exe', 'model_inputs.xlsx']\n",
" refresh_folder(model_workspace, keep_files=keep_files)\n",
"\n",
" if os.path.exists(model_workspace / \"inputs_version.txt\"):\n",
@@ -156,21 +156,14 @@
"metadata": {},
"source": [
"Steps to run on mac:\n",
- "1. open Terminal, and navigate to the folder with the homework/model_inputs.xslx.\n",
+ "1. Open a new Terminal, and navigate to the folder with the homework/model_inputs.xslx.\n",
"2. Run `mamba activate match_model` \n",
"3. run `match solve-scenarios`\n",
"\n",
- "Your code may throw an error when generating summary reports. If this happens- you'll need to enter the {model_run_location} folder /inputs/{scenario_name}/summary_report.ipynb to run the python notebook to generate the report.\n",
- "\n",
"If not you can open the summary_reports/ ...._.html file in a browser and investigate the results of your model run.\n",
"\n"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": []
- },
{
"cell_type": "markdown",
"metadata": {},