Skip to content

juliayyan/OptTeaching

Repository files navigation

OptTeaching

Notebooks and code in Julia for COMM 612.

Setup

  1. Download Gurobi. It's best to stick with the default settings and do a "standard installation".
  2. To use Gurobi, you will need a free academic license. For this step, you will need to be on an academic network; it's easiest if you are physically at your school and on the university WiFi. Register for a Gurobi account, log in to the User Portal, and generate a Named-User Academic license. When you run the grbgetkey command, you will be asked "In which directory would you like to store the Gurobi license file?" I use the default, which is /Users/my-username.
  3. Download Julia.
  4. Open Julia. In Julia, you will first need to set the GUROBI_HOME environment variable to wherever Gurobi was installed, as described in this README:
# On Windows, this might be
ENV["GUROBI_HOME"] = "C:\\Program Files\\gurobi1100\\win64"
# ... or perhaps ...
ENV["GUROBI_HOME"] = "C:\\gurobi1100\\win64"
# On Mac, this might be
ENV["GUROBI_HOME"] = "/Library/gurobi1100/mac64"
# ... or perhaps ...
ENV["GUROBI_HOME"] = "/Library/gurobi1100/macos_universal2"
  1. Then, install the Gurobi package in Julia by running the following:
import Pkg
Pkg.add("Gurobi")
  1. Install the JuMP package in Julia by running Pkg.add("JuMP").
  2. Run the following code in Julia to test whether Gurobi is working properly.
using JuMP, Gurobi
model = JuMP.Model(Gurobi.Optimizer)
@variable(model, x >= 0)
@objective(model, Min, x)
optimize!(model)
  1. You will need IJulia to open and run my notebooks. To install the IJulia package, run Pkg.add("IJulia"). (Each notebook also includes package dependences in the header, which need to be installed before running the notebook.)
  2. Either download or clone this repository and navigate to the directory containing the notebook that you want to run. Run the following in Julia:
using IJulia
notebook(dir = ".")

Resources

Troubleshooting

Please report any issues so that I can expand this list.

  • If you switched the order of the Gurobi instructions and tried to run Pkg.add("Gurobi") before setting ENV["GUROBI_HOME"] or before downloading the Gurobi Optimizer...
    • First, remove the Gurobi.jl package by running Pkg.rm("Gurobi"). Then, close Julia and start over, using the order of instructions as written in this README.
    • Alternatively, you could try to run Pkg.build("Gurobi").
    • See this thread for discussion.
  • If you can use Gurobi in the Julia REPL but not in IJulia, try restarting Julia and IJulia.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors