Using Robust Optimization Techniques to Inform US Climate Policy

69 views
Skip to first unread message

Aaron Belman Martínez

unread,
Feb 23, 2022, 3:32:48 PM2/23/22
to Temoa Project
Hi community,

I have encountered a problem when trying to run the TemoaProject: Using Robust Optimization Techniques to Inform US Climate Policy

I have properly installed the temoa_robust.zip and I am using the specific environment.yml (the specific environment is in the packages.txt file attached). However, when I am trying to run the model, by following the specified instructions from the Zenodo file:

## Steps to run the Robust Optimization model:

1. Install Python 3.7.3
2. Install pyomo 5.6.6
3. Open terminal
4. Navigate to the temoa_model folder
5. Execute the following command
  ```python
  python Robust_optimization.py
  ```
6. Results for a budget of uncertainty = 150 will be stored in "data_files/US_database/US_National_RO_res.db". Install SQLite Browser to view the results in the US_National_RO_res.db file
7. Cost of the robust solution at nominal values of uncertain parameter will be stored at "data_files/US_database/Robust_cost.csv"


The model throws the following error after ~30 minutes of solving the model (I attach it in the error.txt file). It is important to mention that the model throws the error while solving the robust model, not while creating instance of robust model, as this step is successfully completed (see running model.txt).

I am running the model in Windows.

Any advice? 
error.txt
running model.txt
packages.txt

nspatank

unread,
Feb 24, 2022, 8:43:57 AM2/24/22
to Temoa Project
Hi Aaron,

I just tried running the Robust optimization script on my local machine with Python 3.7.3 and Pyomo 5.7.
The script worked without any errors. 

Can you try Pyomo 5.7 instead of 5.6.6? If you still face any errors, I can send you my local copy of the RO code.

I hope it helps.

-Neha

nspatank

unread,
Feb 24, 2022, 8:54:20 AM2/24/22
to Temoa Project
Hi Aaron,

I am attaching a version list of all other relevant packages on my local machine. Differences in the version of some other packages may also cause an error.

matplotlib 3.0.3
numpy 1.16.2
SQLAlchemy 1.3.1 I am also attaching a version list of all other packages installed on my machine for the sake of completeness.
Package Version
---------------------------------- --------
alabaster 0.7.12
anaconda-client 1.7.2
anaconda-navigator 1.9.7
anaconda-project 0.8.2
appdirs 1.4.4
asn1crypto 0.24.0
astroid 2.2.5
astropy 3.1.2
atomicwrites 1.3.0
attrs 19.1.0
Babel 2.6.0
backcall 0.1.0
backports.os 0.1.1
backports.shutil-get-terminal-size 1.0.0
beautifulsoup4 4.7.1
bitarray 0.8.3
bkcharts 0.2
toolz 0.9.0
bleach 3.1.0 bokeh 1.0.4 boto 2.49.0 Bottleneck 1.2.1 certifi 2019.3.9 cffi 1.12.2 chardet 3.0.4 Click 7.0 cloudpickle 0.8.0 clyent 1.2.2 colorama 0.4.1 conda 4.6.11 conda-build 3.17.8 conda-verify 3.1.1 contextlib2 0.5.5 cryptography 2.6.1 cycler 0.10.0 Cython 0.29.6 cytoolz 0.9.0.1 dask 1.1.4 decorator 4.4.0 defusedxml 0.5.0 distributed 1.26.0 docutils 0.14 entrypoints 0.3 et-xmlfile 1.0.1 fastcache 1.0.2 filelock 3.0.10 Flask 1.0.2 future 0.17.1 gevent 1.4.0 glob2 0.6 gmpy2 2.0.8 greenlet 0.4.15 h5py 2.9.0 heapdict 1.0.0 html5lib 1.0.1 idna 2.8 imageio 2.5.0 imagesize 1.1.0 importlib-metadata 0.0.0 ipykernel 5.1.0 ipython 7.4.0 ipython-genutils 0.2.0 ipywidgets 7.4.2 isort 4.3.16 itsdangerous 1.1.0 jdcal 1.4 jedi 0.13.3 jeepney 0.4 Jinja2 2.10 jsonschema 3.0.1 jupyter 1.0.0 jupyter-client 5.2.4 jupyter-console 6.0.0 jupyter-core 4.4.0 jupyterlab 0.35.4 jupyterlab-server 0.2.0 keyring 18.0.0 kiwisolver 1.0.1 lazy-object-proxy 1.3.1 libarchive-c 2.8 lief 0.9.0 llvmlite 0.28.0 locket 0.2.0 lxml 4.3.2 MarkupSafe 1.1.1 matplotlib 3.0.3 mccabe 0.6.1 mistune 0.8.4 mkl-fft 1.0.10 mkl-random 1.0.2 more-itertools 6.0.0 mpmath 1.1.0 msgpack 0.6.1 multipledispatch 0.6.0 navigator-updater 0.2.1 nbconvert 5.4.1 nbformat 4.4.0 networkx 2.2 nltk 3.4 nose 1.3.7 notebook 5.7.8 numba 0.43.1 numexpr 2.6.9 numpy 1.16.2 numpydoc 0.8.0 olefile 0.46 openpyxl 2.6.1 packaging 19.0 pandas 0.24.2 pandocfilters 1.4.2 parso 0.3.4 partd 0.3.10 path.py 11.5.0 pathlib2 2.3.3 patsy 0.5.1 pep8 1.7.1 pexpect 4.6.0 pickleshare 0.7.5 Pillow 5.4.1 pip 19.0.3 pkginfo 1.5.0.1 pluggy 0.9.0 ply 3.11 prometheus-client 0.6.0 prompt-toolkit 2.0.9 psutil 5.6.1 ptyprocess 0.6.0 py 1.8.0 pycodestyle 2.5.0 pycosat 0.6.3 pycparser 2.19 pycrypto 2.6.1 pycurl 7.43.0.2 pyDOE 0.3.8 pyflakes 2.1.1 Pygments 2.3.1 pylint 2.3.1 pyodbc 4.0.26 Pyomo 5.7 pyOpenSSL 19.0.0 pyparsing 2.3.1 pyrsistent 0.14.11 PySocks 1.6.8 pytest 4.3.1 pytest-arraydiff 0.3 pytest-astropy 0.5.0 pytest-doctestplus 0.3.0 pytest-openfiles 0.3.2 pytest-remotedata 0.3.1 python-dateutil 2.8.0 pytz 2018.9 PyUtilib 6.0.0 PyWavelets 1.0.2 PyYAML 5.1 pyzmq 18.0.0 QtAwesome 0.5.7 qtconsole 4.4.3 QtPy 1.7.0 requests 2.21.0 rope 0.12.0 ruamel-yaml 0.15.46 SALib 1.3.11 scikit-image 0.14.2 scikit-learn 0.20.3 scipy 1.2.1 seaborn 0.9.0 SecretStorage 3.1.1 Send2Trash 1.5.0 setuptools 40.8.0 simplegeneric 0.8.1 singledispatch 3.4.0.3 six 1.12.0 snowballstemmer 1.2.1 sortedcollections 1.1.2 sortedcontainers 2.1.0 soupsieve 1.8 Sphinx 1.8.5 sphinxcontrib-websupport 1.1.0 spyder 3.3.3 spyder-kernels 0.4.2 SQLAlchemy 1.3.1 statsmodels 0.9.0 sympy 1.3 tables 3.5.1 tblib 1.3.2 terminado 0.8.1 testpath 0.4.2 toolz 0.9.0 tornado 6.0.2 tqdm 4.31.1 traitlets 4.3.2 unicodecsv 0.14.1 urllib3 1.24.1 wcwidth 0.1.7 webencodings 0.5.1 Werkzeug 0.14.1 wheel 0.33.1 widgetsnbextension 3.4.2 wrapt 1.11.1 wurlitzer 1.0.2 xlrd 1.2.0 XlsxWriter 1.1.5 xlwt 1.3.0 zict 0.1.4 zipp 0.3.3

-Neha

Aaron Belman Martínez

unread,
Feb 28, 2022, 7:30:57 AM2/28/22
to Temoa Project
Hi Neha, 

Thanks a lot for your help, I followed your advice and I managed to run a full simulation. However, I have some questions that I would like to ask you.

I ran a full simulation using the following relevant packages (I attach a complete list in this mail):
  • python 3.7.3
  • pyomo 5.7.3 (I tried to use pyomo 5.7 as you recommended but it lead to some inconsistencies with the cplex 20.1.0.3 package that I am currently using, may I ask which cplex package are you using?)
  • matplotlib 3.0.3
  • numpy 1.16.2
  • SQLAlchemy 1.3.1
    Although the simulation was completed successfully, there are some aspects that caught my attention:
    • After running the command "python Robust_optimization.py" the model stated multiple warnings, which ultimately lead to the risk of: This WILL potentially lead to nondeterministic behavior in Pyomo. I attach a file with the full list of warnings stated before solving the model. Do you also get the same warnings when running the model?
    • The model reached a solution in a suspicious amount of time (around 5 minutes). Which, in my opinion, might be extremely fast especially for a model using the US_National database. (My PC specs are 4GB of RAM and 2.6 GHz). How much time does this simulation take on your PC?
    Regardless of the aspects that I just mentioned, I would really appreciate if you can share with me the solutions files you obtained after running the simulation (US_National_RO_res and Robust_cost) so I can compare them with my own results and be certain the model is working fine in my own environment. 

    Thanks again for your help Neha!

    Kind regards,
    Aaron
    Warnings.txt
    PackagesSecondTry.txt

    nspatank

    unread,
    Feb 28, 2022, 8:31:30 AM2/28/22
    to Temoa Project
    Hi Aaron,

    I am glad to learn that you were able to solve the RO model successfully. Here are a few comments for your questions:

    1. CPLEX version - CPLEX/12.9.0
    2. Don't worry about Pyomo related warnings. I received the same ones.
    3. Least-cost run takes 2-3 minutes to solve for a single region US database with 12 representative time slices.
    RO formulation scales linearly with the number of uncertain variables. Since we build on the existing model instance from the least cost solution, RO takes 5-6 minutes to solve. So, your computational time seems right.
    Note: The RO script only solves for the budget of uncertainty = 150. You can solve for multiple values of the budget of uncertainty by setting BOU = list(range(0,600,50)).
    4. I am not able to upload the results file from my runs as it is too large.

    Hope it helps.

    Best,
    Neha

    Aaron Belman Martínez

    unread,
    Mar 16, 2022, 9:51:59 PM3/16/22
    to Temoa Project
    Hi Neha, 

    Sorry to bother you again with questions about running the model. Till now, I have been able to run multiple simulations for different BOU values (BOU = list(range(0,600,50))+[2400]), and up to this time I have been handling and understanding the output results. Now, I reached a point on which I will be modifying some of the US_National database parameters. As far as I understand, when running the Robust optimization script, the model utilizes two input files:

                    1. data_files/US_database/US_National_RO.dat
                    2. temoa_model/Robust_bounds.txt

    I made a minor change in the US_National.sql file and then converted it to the new US_National_RO.dat file by using the following command in the anaconda prompt:

                 > sqlite3 US_National_RO.dat < US_National.sql

    However, this time while I run the model, an unexpected error occurs (I attach it in this mail). Am I creating the US_National_RO.dat file the wrong way? Is there an alternative way to create the .dat file from a .sql file?

    It is important to mention that I am utilizing the same environment that worked to run the original US_National_RO.dat. The only difference in the file that I am trying to run is just a minor change in the emissions limit constraint for the year 2050. Therefore, I am sure the error is not coming from an irregularity in the database, instead, it should be related to the way I created the US_National_RO.dat file from the US_National.sql

    Any advice?

    Kind regards,

    Aaron

    error.txt

    Neha Patankar

    unread,
    Mar 17, 2022, 11:34:09 AM3/17/22
    to Temoa Project
    Hi Aaron,

    No worries! I am happy to help.

    Several sets/parameters in the US_National_RO.dat file are not present in the US_National.sql file. So, those sets/parameters are omitted when you converted the updated US_National.sql  file.
    Please make the emission constraint related changes in the US_National_RO.dat file directly. You can do so by editing the .dat file with SublimeText / Notepad++ / VSCode or any other text editor. 

    -Neha

    --
    You received this message because you are subscribed to a topic in the Google Groups "Temoa Project" group.
    To unsubscribe from this topic, visit https://groups.google.com/d/topic/temoa-project/VLTeCk_7V6g/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to temoa-projec...@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/temoa-project/a555ae80-9b8a-49f0-9452-583163aa89f9n%40googlegroups.com.

    Aaron Belman Martínez

    unread,
    Mar 17, 2022, 6:40:34 PM3/17/22
    to Temoa Project
    Hi Neha,

    I changed the parameter directly in the US_National_RO.dat as you recommended. I specifically modified the 2050 emission limit from 288000 to 200000 as you can see in the following image:

    1-1.PNG

    However, when I ran the RO script and obtained the US_National_RO_res.db output file. I checked and it seems the parameter that I changed was still as the original US_National_RO.dat file. Showing a limit of 288000 instead of the new one of 200000. 

    1- 2.PNG

    Am I missing something?

    Neha Patankar

    unread,
    Mar 17, 2022, 8:07:08 PM3/17/22
    to Temoa Project
    Hello Aaron,

    The input dataset is read from the US_National_RO.dat file, and the results are written in the US_National_RO_res.db file. Input parameters in the US_National_RO_res.db are not used in the RO script. 
    Ideally, we would want the inputs in the US_National_RO.dat file to be synced with the inputs in the US_National_RO_res.db file; however, it is currently not the case.

    -Neha

    You received this message because you are subscribed to the Google Groups "Temoa Project" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to temoa-projec...@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/temoa-project/4183307f-c9db-45d5-b249-c3564cadcae5n%40googlegroups.com.
    Reply all
    Reply to author
    Forward
    0 new messages