Code Monkey home page Code Monkey logo

ssac2020's Introduction

SSAC2020: An Optimization Approach to Roster Creation

Materials for Sloan Sports Analytics Conference 2020 workshop on optimization using Julia/JuMP. In this session, we implement optimization models using the programming language Julia and the JuMP library. A video recording of the conference session is available here.

Before this session, follow the preassignment below to setup Julia and JuMP if you would like to run the code on your own computer. The data files and notebook that we will use in the session can be downloaded above (NBA_data_2018_2019.csv, NBA_data_2018_2019_playoffs.csv, and SSAC20 Julia and JuMP Tutorial.ipynb).

Preassignment Part 1: Install Julia

The first step is to install a recent version of Julia. Julia is a "high-level, high-performance dynamic programming language for technical computing", and JuMP is a library that allows us to easily formulate and solve optimization problems.

The current version is 1.3.1. Versions of Julia for all platforms are available here.

Install JuMP and Cbc in Julia

Installing packages in Julia is easy with the Julia package manager. To install a package, open Julia (click on the application icon to launch) and type ] to enter the package manager.

Install the JuMP package (press enter to run the command):

(v1.3) pkg> add JuMP

Also install the Cbc package, which will be the backend mixed-integer optimization solver for our optimization problems.

(v1.3) pkg> add Cbc

Finally, you should add Julia's package manager (Pkg) to make it easy to add new packages.

(v1.3) pkg> add Pkg

Preassignment Part 2: Install IJulia

IJulia is the Julia version of IPython/Jupyter, that provides a nice notebook interface to run julia code, together with text and visualization. Please follow the following steps.

First, install IJulia (note that this is case-sensitive).

(v1.3) pkg> add IJulia

Once the package is installed, you can launch an IJulia session by running:

julia> using IJulia
julia> notebook()

This will open a window in your browser. You can create a new notebook by clicking "New > Julia 1.3.1" in the upper right corner.

Note: you may be prompted to install Jupyter when you first use IJulia. If so, go ahead and install it through the command line. Once it is installed, the notebook should launch normally.

Reference: these instructions were adapted from this tutorial.

Preassignment Part 3: Solving a simple optimization problem

Let's try a simple optimization problem! Copy and paste the following JuMP code into the new IJulia notebook that you created. You can run the code by pressing the "Run" button in the top menu. It may take 1-2 minutes for your code to return an output since you are loading these packages for the first time.

A solution should be returned with an objective value of 10.6.

using JuMP, Cbc

m = Model(Cbc.Optimizer) 
@variable(m, 0 <= x <= 2 )
@variable(m, 0 <= y <= 30 )

@objective(m, Max, 5x + 3*y )
@constraint(m, 1x + 5y <= 3.0 )

print(m)

optimize!(m)

println("Objective value: ", objective_value(m))
println("x = ", value(x))
println("y = ", value(y))

Questions?

Email [email protected]

ssac2020's People

Contributors

hwiberg avatar

Stargazers

 avatar  avatar Noah Landesberg avatar  avatar Jimmy Shah avatar Benjamin Xiao avatar Bradley Fay avatar  avatar

Watchers

 avatar  avatar

Forkers

morganabbitt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.