1. Home
  2. Docs
  3. Tutorials
  4. JuMP tutorial
  5. JuMP on Windows

JuMP on Windows

Before reaching this guide, you’ll have:

  • downloaded the Engine.
  • installed the Engine.

Step 1: Install Julia

Go to https://julialang.org/downloads/ and obtain the Windows -in 64-bit(installer) flavour- downloadable.

Double-click the installer and follow the instructions on-screen to install.

Make sure that Add Julia to PATH is selected in the Select Additional Tasks section of the installer wizard. Otherwise you will not be able to start Julia from the command line.

Step 2: Launch Julia in the Command Prompt

Click on the Windows icon at the bottom left of your screen and enter Command Prompt. You should now see the Command Prompt icon and be able to launch it.

Note that this guide will not work with Powershell. It is possible to use Powershell for running the Engine through Julia/JuMP, but extra steps may be required depending on your system.

Start a Julia interactive shell by entering this command in the command prompt:

julia

You should see a printout of the Julia logo, and a

julia> prompt, that looks like this:

_
_       _ _(_)_     |  Documentation: https://docs.julialang.org
(_)     | (_) (_)    |
_ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` |  |
| | |_| | | | (_| |  |  Version 1.6.1 (2021-04-23)
_/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia>

Step 3: Install JuMP

To install JuMP we are going to use the built-in package manager of the Julia language. We are also going to install some auxiliary packages that are necessary in order to use Octeract Engine later.

Type the following lines in the Julia prompt:

import Pkg
Pkg.add("JuMP")
Pkg.add("AmplNLWriter")

This may take a minute or two depending on the speed of your internet connection and your computer hardware.

Step 4: Run a Model with JuMP and Octeract Engine

Paste the following model in your interactive Julia prompt:

using Pkg
using JuMP
using AmplNLWriter

m = Model(() -> AmplNLWriter.Optimizer("octeract-engine"))

@variable(m, 0 <= x1 <= 1)
@variable(m, 0 <= x2 <= 1)
@variable(m, 0 <= x3 <= 1)
@variable(m, 0 <= x4 <= 1)
@variable(m, 0 <= x5 <= 1)

@objective(m, Min, 42*x1 - 0.5*(100*x1*x1 + 100*x2*x2 +
100*x3*x3 + 100*x4*x4 + 100*x5*x5) + 44*x2 + 45*x3 +
47*x4 + 47.5*x5)

ENV["octeract_options"] = "num_cores=4"

optimize!(m)

println("Objective value: ", objective_value(m))
println("Solved!")

The interactive Julia prompt relies on a new line being entered to execute a command*. If the script hangs after being pasted from the web on the last line, press Enter to resume it.

*The model can also be entered line by line, if for some reason your prompt is not accepting the formatting of the whole text block.

Note this line in the above script:

ENV["octeract_options"] = "num_cores=4"

It sets the number of cores that Octeract Engine will solve with. You can adjust that number up to the number of cores allowed by your authentication token, or remove it completely to solve in serial.

To exit the Julia prompt, enter:

exit()

And that’s it – you’re done!
You’ve just solved your first model with JuMP and Octeract Engine!