Tutorial 1
Tutorial 1
Programming Basics
IEDA 3010 Tutorial 01
Chen Yang
Software Installation
• Anaconda (Python)
• https://www.anaconda.com/distribution/#download-section
• Function
• abs, max, print, range,…
• Define a function, set parameters and return results.
• Sum of string
Format control (width.precision)
• Length of string
• Add and remove element
List
• Create a list
• Manipulation
Python Control Flow
• The Boolean Type Expressions
• Status: True or False
➢ Comparison operators (==, !=, >=, <=, >, <)
➢ Identity operators (is, is not)
➢ Membership operators (in, not in)
➢ Logic operators (and, or, not)
• Conditional Statements
• if-elif-else
• Coding style
• Flat is better than nested
• Readability counts
• Nested
Python Control Flow
• Iterations and loops
• The while loop
• Comparison
Define a function
Output
Summary
• Software Installation
• Variables, Simple Data Types, Functions and Modules
• Assignment Statements
• Basic types and type conversion
• Function and modules
• Python Control Flow
• Boolean type expression
• Conditional statements
• Iterations and loops
Linear Optimization Review
• Formulation
• Geometry
Formulation
max 𝑍 = 𝑐1 𝑥1 + 𝑐2 𝑥2 + ⋯ + 𝑐𝑛 𝑥𝑛
• Decision variables: 𝑥1 , 𝑥2 , ⋯
• Objective function: 𝑍 = 𝑐1 𝑥1 + 𝑐2 𝑥2 + ⋯ + 𝑐𝑛 𝑥𝑛
i.e. max or min 𝑓(𝑥)
• Constraints: 𝑎𝑖1 𝑥1 + 𝑎𝑖2 𝑥2 + ⋯ + 𝑎𝑖𝑛 𝑥𝑛 ≤ 𝑏𝑖 , 𝑥𝑖 ≥ 0
max 𝑐 𝑇 𝑥
Standard Form s.t. 𝐴𝑥 ≤ 𝑏
x≥0
Other Forms
1. Minimize to Maximize [Objective Function]
min 𝑍 = 𝑐1 𝑥1 + 𝑐2 𝑥2 + ⋯ + 𝑐𝑛 𝑥𝑛
m𝑎𝑥 −𝑍 = −𝑐1 𝑥1 − 𝑐2 𝑥2 − ⋯ − 𝑐𝑛 𝑥𝑛
• Feasible Region
▪ Intersection of all constraints
• Extreme Points
▪ Corner points inside the feasible region
Geometry of LP Review
• Objective function
▪ Isoquant
• Optimal solution
▪ Best feasible solution
▪ Unique, not unique, not finite optimal solution
• *Theorem: For any feasible LP with a finite number of optimal solution, there
exists an optimal solution that is an extreme point.
▪ From infinite number of feasible solution to finite number of extreme points
Example 1
Example 1 (Solution)
Available Investment Return of Investment
Invest\ Invest\
1 2 3 4 5 1 2 3 4 5
Year Year
1.4
A ✓ ✓ ✓ ✓ A 1.4 A1 1.4 A2
A3
B ✓ ✓ ✓
B 1.7B1 1.7B2
C ✓
C
D ✓
D
Example 2
Use the graphical method to solve this problem