Python-basic syntax

Python is a modern, easy-to-learn, object-oriented programming language. It has a powerful set of built-in data types and easy-to-use control constructs. Please note that all contents in this series of notes are using Python 3. In Python interpreter, try the following command to check the version you installed: Variables play the key roles in any…

Some features in Gurobi Python interface

In order to provide a better modeling experience, Gurobi provides a few tailored objects and functions for building up optimization models. This post is a quick review of them. Gurobi tuplelist This is a subclass of list to store lists of tuples, for example: select is a very efficient way to select elements in a tuplelist….

Python String Format

About number formatting The following table collects the most essential use of str.format() Try print(“FORMAT”.format(NUMBER)) if you would like to run any of these cases. Number Format Output Description 3.1415926 {:.2f} 3.14 2 decimal places 3.1415926 {:+.2f} +3.14 2 decimal places with sign -1 {:+.2f} -1.00 2 decimal places with sign 2.71828 {:.0f} 3 No…

Gurobi Python Interface

Gurobi released the latest 7.0 version optimizer in Oct. 2016, and Python modeling enhancements is one of the new features.