|
| 1 | +# INTRODUCTION |
| 2 | + |
| 3 | +This repository contains code and example files for the Switch power system |
| 4 | +planning model. Switch is written in the Python language and several other |
| 5 | +open-source projects (notably Pyomo, Pandas and glpk). The instructions below |
| 6 | +show you how to install these components on a Linux, Mac or Windows computer. |
| 7 | + |
| 8 | +We recommend that you use the Anaconda scientific computing environment to |
| 9 | +install and run Switch. This provides an easy, cross-platform way to install |
| 10 | +most of the resources that Switch needs, and it avoids interfering with your |
| 11 | +system's built-in Python installation (if present). The instructions below |
| 12 | +assume you will use the Anaconda distribution. If you prefer to use a different |
| 13 | +distribution, you will need to adjust the instructions accordingly. In |
| 14 | +particular, it is possible to install Switch and most of its dependencies using |
| 15 | +the pip package manager if you have that installed and working well, but you |
| 16 | +will need to do additional work to install glpk or coincbc, and possibly git. |
| 17 | + |
| 18 | + |
| 19 | +# INSTALL CONDA AND PYTHON |
| 20 | + |
| 21 | +Download and install Miniconda from |
| 22 | +https://docs.conda.io/en/latest/miniconda.html or Anaconda from |
| 23 | +https://www.anaconda.com/distribution . We recommend using the 64-bit version |
| 24 | +with Python 3.7. Anaconda and Miniconda install a similar environment, but |
| 25 | +Anaconda installs more packages by default and Miniconda installs them as |
| 26 | +needed. |
| 27 | + |
| 28 | +Note that you do not need administrator privileges to install the Windows Conda |
| 29 | +environment or add packages to it if you select the option to install "just for |
| 30 | +me". |
| 31 | + |
| 32 | +If you want, this is a good point to create an Conda environment specifically |
| 33 | +for using or testing Switch. See here for more details: |
| 34 | +https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html |
| 35 | + |
| 36 | + |
| 37 | +# INSTALL SWITCH AND ITS DEPENDENCIES |
| 38 | + |
| 39 | +After installing Anaconda or Miniconda, open an Anaconda Command Prompt |
| 40 | +(Windows) or Terminal.app (Mac) and type the following command: |
| 41 | + |
| 42 | + conda install -c conda-forge switch_model |
| 43 | + |
| 44 | +This will install the `switch` command line utility, along with various software |
| 45 | +used by Switch (the Pyomo optimization framework, Pandas data manipulation |
| 46 | +framework and glpk numerical solver). |
| 47 | + |
| 48 | +If you would also like to enable automatic output graphs, run this command: |
| 49 | + |
| 50 | + conda install -c conda-forge ggplot |
| 51 | + |
| 52 | +If you would like to try the coincbc solver instead of glpk, you can run this |
| 53 | +command: |
| 54 | + |
| 55 | + conda install coincbc |
| 56 | + |
| 57 | +If you plan to use the iterative demand response model with a custom, nonlinear |
| 58 | +demand system, then you should add these packages: |
| 59 | + |
| 60 | + conda install rpy2 scipy |
| 61 | + |
| 62 | +At this point, you can solve example models or your own power system models. |
| 63 | +See README for more information. |
| 64 | + |
| 65 | + |
| 66 | +# INSTALL A PROPRIETARY SOLVER (OPTIONAL) |
| 67 | + |
| 68 | +To solve larger models, you will need to install the cplex or gurobi solvers, |
| 69 | +which are an order of magnitude faster than glpk or coincbc. Both of these have |
| 70 | +free trials available, and are free long-term for academics. You can install |
| 71 | +one of these now or after you install Switch. More information on these solvers |
| 72 | +can be found at the following links: |
| 73 | + |
| 74 | +Professional: |
| 75 | +https://www.gurobi.com/products/gurobi-optimizer/ |
| 76 | +https://www.ibm.com/products/ilog-cplex-optimization-studio/pricing |
| 77 | + |
| 78 | +Academic: |
| 79 | +https://www.gurobi.com/academia/ |
| 80 | +https://developer.ibm.com/docloud/blog/2019/07/04/cplex-optimization-studio-for-students-and-academics/ |
| 81 | + |
| 82 | +For any meaningful-sized problem, you will need the unlimited-size versions of |
| 83 | +these solvers, which will require either purchasing a license, using a |
| 84 | +time-limited trial version, or using an academic-licensed version. The |
| 85 | +small-size free or community versions (typically 1000 variables and constraints) |
| 86 | +will not be enough for any realistic model. |
| 87 | + |
| 88 | + |
| 89 | +# VIEW EXAMPLES |
| 90 | + |
| 91 | +If you want to view the Switch source code and examples, you can find them at |
| 92 | +https://github.com/switch-model/switch. You can also find the source code on |
| 93 | +your computer in $CONDA_PREFIX/lib/python3.7/site-packages/switch_model or |
| 94 | +$CONDA_PREFIX/lib/python2.7/site-packages/switch_model. |
| 95 | + |
| 96 | + |
| 97 | +# DEVELOPER INSTALLATION (optional) |
| 98 | + |
| 99 | +Many people find it useful to browse and edit a "live" installation of Switch |
| 100 | +that they also use to solve models. This supports a number of activities: |
| 101 | + |
| 102 | +- reading the documentation built into the switch_model modules |
| 103 | +- reading the source code of the modules to understand the details of how Switch |
| 104 | + works |
| 105 | +- updating Switch or fixing bugs to meet local needs or contribute to the main |
| 106 | + repository |
| 107 | +- setting breakpoints for debugging |
| 108 | +- switching between different versions of Switch |
| 109 | +- trying pre-release branches of Switch |
| 110 | + |
| 111 | +To work this way, first install Switch as described above (this will install all |
| 112 | +the Switch dependencies, even though you will later reinstall Switch itself). |
| 113 | +Then, in a terminal window or Anaconda command prompt Anaconda command prompt, |
| 114 | +use the `cd` and `mkdir` commands to create and/or enter the directory where you |
| 115 | +would like to store the Switch model code and examples. Once you are in that |
| 116 | +directory, run the following commands (don't type the comments that start with |
| 117 | +'#'): |
| 118 | + |
| 119 | + # Install git software manager. |
| 120 | + conda install git |
| 121 | + |
| 122 | + # Download Switch to a directory called `switch`. |
| 123 | + git clone https://github.com/switch-model/switch.git |
| 124 | + |
| 125 | + # Uninstall the previous copy of Switch and tell Python to use this one |
| 126 | + # instead. Note that Python will always load switch_model directly from this |
| 127 | + # directory, so you can edit it as needed and Python will see the changes. |
| 128 | + cd switch |
| 129 | + pip install --upgrade --editable . |
| 130 | + |
| 131 | + # Run tests (optional) |
| 132 | + python run_tests.py |
| 133 | + |
| 134 | + # View switch_model code (optional) |
| 135 | + cd switch_model |
| 136 | + ls |
| 137 | + cd .. |
| 138 | + |
| 139 | + # View or run examples (optional) |
| 140 | + cd examples |
| 141 | + ls |
| 142 | + cd <example dir> |
| 143 | + switch solve |
| 144 | + |
| 145 | +After this, you can pull the latest version of the Switch code and examples from |
| 146 | +the main Switch repository at any time by launching a Terminal window or |
| 147 | +Anaconda prompt, then cd'ing into the 'switch' directory and running this |
| 148 | +command: |
| 149 | + |
| 150 | + git pull |
| 151 | + |
| 152 | +This will attempt to merge your local changes with changes with changes in the main |
| 153 | +repository. If there are any conflicts, you should follow the instructions given |
| 154 | +by the git command to resolve them. |
0 commit comments