This repository contains materials for two workshops:
- Julia and Optimization days 2023, to be held Wednesday 4 October, 2023
- SESO2023, to be held Tuesday 10 October, 2023
Both workshops will be interactive. To follow along, you should download these materials and install Julia prior to the workshop.
If you have trouble following the instructions below, please
open a Github issue, or email
o.dowson@gmail.com
.
To get started, you first need to install Julia.
- Download and install the Current stable release version of Julia from https://julialang.org/downloads/.
If you cannot install locally, see the "Google Colab" instructions below.
- If you use Windows, choose the 64-bit installer
- If you have a new M1 or M2 mac, choose the
(Apple Silicon)
version
If you are comfortable using a command line, you may instead want to install juliaup, which is a small CLI for managing and updating your installations of Julia.
Next, you need to download a copy of these materials.
If you have git
installed
cd
to an appropriate directory, then run
git clone https://github.com/odow/SESO2023
If you don't have git
installed
Download this zip file. Once downloaded, unzip it to an appropriate location.
Now open Julia, either by typing julia
at a terminal, or by launching the icon
from wherever you installed it.
Once open, you should be faced with the Julia REPL that looks like this:
Now we need to install some packages.
In the Julia REPL, run the following commands, replacing the path with the location of where you downloaded the materials.
cd("/Users/Oscar/Downloads/SESO2023-main")
import Pkg
Pkg.activate(".")
Pkg.instantiate()
Pkg.build("IJulia")
julia> cd("/Users/Oscar/Downloads/SESO2023-main")
julia> import Pkg
julia> Pkg.activate(".")
Activating project at `~/Downloads/SESO2023-main`
julia> Pkg.instantiate()
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Updating `~/Downloads/SESO2023-main/Project.toml`
... lots of lines omitted ...
Precompiling project...
233 dependencies successfully precompiled in 274 seconds
julia> Pkg.build("IJulia")
Building Conda ─→ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/8c86e48c0db1564a1d49548d3515ced5d604c408/build.log`
Building IJulia → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/47ac8cc196b81001a711f4b2c12c97372338f00c/build.log`
WARNING: it takes a few minutes to download and compile all the packages! The good news is that you only have to run this command once.
- On Mac and Linux,
cd("~")
may throw an error instead ofcd
ing to your home directory:To fix, type the full path to the home directory, or typejulia> cd("~") ERROR: IOError: cd("~"): no such file or directory (ENOENT)
cd("~
, then press theTAB
key.
Okay, last step, let's launch a Jupyter notebook. Open a Julia REPL and then run:
import Pkg
cd("/Users/Oscar/Downloads/SESO2023-main")
Pkg.activate(".")
import IJulia
IJulia.notebook(dir = ".")
If all goes well, a browser window will open that looks like this:
To get started on the content portion of the tutorials, double click on the
"notebooks" folder, and then 00_getting_started_with_julia.ipynb
. Then click
"Cell > "Run All".
If things are sucessful, all of the cells should run (some will error on purpose). You're now ready to follow along with the live training.
- Don't start Jupyter via Anaconda! There are some version differences that cause problems.
- If you encounter
install Jupyter via Conda, y/n? [y]:
, press they
key
I will continue to update these materials over time. To update the materials you previous installed:
If you have git
installed
git pull
the latest changes. All of the packages will remain installed, so the
only thing that will change are the Jupyter notebooks.
- If you made changes to a notebook that was updated,
git
will throw an error sayingerror: Your local changes to the following files would be overwritten by merge:
If the changes can be discarded, dogit checkout notebook_name.ipynb
and then trygit pull
again.
If you don't have git
installed
Download a new copy of the zip file, and then copy-paste the new notebooks into the old directory. There is no need to re-run the other installation steps.
Open http://colab.research.google.com/
and import one of the colab_xxx
notebooks by providing the link to the GitHub
repository:
https://github.com/odow/SESO2023
Click "Connect" in the top-right corner.
You will get a warning that the kernel julia-1.9
is not recognized, defaulting
to python3
. This is because Julia is not officially supported by Google Colab.
To install Julia, create a new code cell at the top of the notebook, and run:
%%shell
set -e
wget -nv https://raw.githubusercontent.com/odow/SESO2023/main/install_colab.sh -O /tmp/install_colab.sh
bash /tmp/install_colab.sh # Takes ~ 2 minutes
Reload the page to load the notebook with the correct kernel.
We also need to install the various packages.
You can either create a new code cell and manually specify the packages that
need installing via Pkg.add
, for example:
import Pkg; Pkg.add(["JuMP", "HiGHS"]) # Can take ~ 5 minutes
Or you can download the Project.toml
file from the GitHub repo and install
all the packages in one go. This can take a few minutes to install and compile
everything.
import Downloads, Pkg
Downloads.download("https://raw.githubusercontent.com/odow/SESO2023/main/Project.toml", "/tmp/Project.toml")
Pkg.activate("/tmp/Project.toml")
Pkg.instantiate() # Can take ~ 7 minutes
- Because each notebook runs in a self-contained virtual machine, you need to re-install Julia and all of the packages every time you start Colab. If you use Colab frequently and have a solution to this problem, please let me know.