Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Installing Anaconda/Gurobi: Python - M Pip Install Gurobipy Conda Install - C Gurobi Gurobi 9.5.0

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Installing Anaconda/Gurobi

1. Install Anaconda:
Download/Install Anaconda: https://docs.anaconda.com/anaconda/install/
Open Anaconda Navigator
Launch Jupiter Notebook

2. Download/Install Gurobi
https://www.gurobi.com/

3. Download the Gurobi license.


Go to:
https://www.gurobi.com/academia/academic-program-and-licenses/

Register for an academic account in order to get the license.

4. Setup Gurobi license

5. “Install Gurobi into Anaconda


https://www.gurobi.com/gurobi-and-anaconda-for-windows/

6. Install gurobipy libarary


python -m pip install gurobipy
conda install -c gurobi gurobi=9.5.0

Working With Jupiter Notbook

7. Download the Repository” of problems from Introduction to Mathematical Optimization


Modeling Page:
https://colab.research.google.com/github/Gurobi/modeling-examples/blob/master/
intro_to_modeling/introduction_to_modeling_gcl.ipynb

8. I will demonstrate the “Agricultural Pricing” problem.


a. Solve the problem via Jupiter Notbook
b. Solve the problem via Spyder

Gurobi & Python Resources


1. Gurobi Optimizer Beginner’s Guide
Let us work together the example on page 75.
Let us work together the example on page 80.
Let us work together the example on page 84.

2. Python Beginner’s guide: https://wiki.python.org/moin/BeginnersGuide


3. Documents related to python: https://docs.python.org/3/tutorial/
a. Data structures: Section 3.1.3 & Section 5
Data Structures:
Lists: can be written as a list of comma-separated values (items) between square brackets. Lists
might contain items of different types, but usually the items all have the same type.

Tuples are crucial to providing efficient and convenient access to Gurobi decision variables in
Gurobi Python programs. Lists and tuples are both just ordered collections of Python objects. A
list is created and displayed as a comma-separated list of member objects, enclosed in square
brackets. A tuple is similar, except that the member objects are enclosed in parenthesis. For
example, [1, 2, 3] is a list, while (1, 2, 3) is a tuple.

A tuple is immutable, meaning that you can’t modify it once it has been created. By contrast, you
can add new members to a list, remove members, change existing members, etc. This immutable
property allows you to use tuples as indices for dictionaries.

Sets: A set is an unordered collection with no duplicate elements. Set objects also support
mathematical operations like union, intersection, difference, and symmetric difference.

Dictionaries are sometimes found in other languages as “associative memories” or “associative


arrays”. Unlike sequences, which are indexed by a range of numbers, dictionaries are indexed
by keys, which can be any immutable type; strings and numbers can always be keys.

A Python dictionary allows you to map arbitrary key values to pieces of data. It is best to think of
a dictionary as a set of key: value pairs, with the requirement that the keys are unique (within one
dictionary). A pair of braces creates an empty dictionary: {}. Placing a comma-separated list of
key: value pairs within the braces adds initial key: value pairs to the dictionary; this is also the
way dictionaries are written on output.

Gurobi included a utility routine in the Gurobi Python interface that simplifies dictionary
initialization for a case that arises frequently in mathematical modeling. The multidict function
allows you to initialize one or more dictionaries in a single statement. The function takes a
dictionary as its argument, where the value associated with each key is a list of length n. The
function splits these lists into individual entries, creating n separate dictionaries. The function
returns a list. The first result is the list of shared key values, followed by the n individual
dictionaries:

You might also like