- installed the Engine.
- installed your authentication token.

` ````
python --version
```

If Python is not installed or if you have a different version installed, go to https://www.python.org/downloads and download the Python 3.7.x installer.

You can check your installation by closing and reopening Command Prompt then repeating the beginning of this step.

Run the Python installer and go through the installation process.

Python should be correctly installed at this point. You can check your installation by repeating the beginning of this step.

` ````
python
```

Alternatively, you can use a Python editor of your choice. Save the file as

` ````
python "C:\path\to\your_file.py"
```

Enter:

` ````
from octeract import *
m = Model()
```

` ````
#Define variables and variable bounds
m.add_variable("x1", 0, 1)
m.add_variable("x2", 0, 1)
m.add_variable("x3", 0, 1)
m.add_variable("x4", 0, 1)
m.add_variable("x5", 0, 1)
#Define and objective function
m.set_objective("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")
#Define a constraint
m.add_constraint("20*x1 + 12*x2 + 11*x3 + 7*x4 + 4*x5 <= 40")
```

` ````
m.global_solve()
```

` ````
n = 4
m.global_solve(n)
```

If successful, it will print out the optimal solution for your model.

You've just solved an optimisation problem using Python.

- installed the Engine.
- installed your authentication token.

` ````
python3 --version
```

Ensure that the default Python 3 version for your Linux distribution is the version of Python on your PC. Here is a list of default Python 3 versions per distribution:

Ubuntu 20: | Python 3.8 |

Ubuntu 18: | Python 3.6 |

CentOS 7: | Python 3.6 |

CentOS 8: | Python 3.6 |

Enter:

` ````
sudo apt update
sudo apt install python3
```

Enter:

` ````
sudo yum update
sudo yum install python3
```

` ````
python3
```

Alternatively, you can use a Python editor of your choice. Save the file as

` ````
python3 "/path/to/your_file.py"
```

Enter:

` ````
from octeract import *
m = Model()
```

` ````
#Define variables and variable bounds
m.add_variable("x1", 0, 1)
m.add_variable("x2", 0, 1)
m.add_variable("x3", 0, 1)
m.add_variable("x4", 0, 1)
m.add_variable("x5", 0, 1)
#Define and objective function
m.set_objective("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")
#Define a constraint
m.add_constraint("20*x1 + 12*x2 + 11*x3 + 7*x4 + 4*x5 <= 40")
```

` ````
m.global_solve()
```

` ````
n = 4
m.global_solve(n)
```

If successful, it will print out the optimal solution for your model.

You've just solved an optimisation problem using Python.

htg/htg1006