Practical Python AI Projects

Chapter 1: ␇Introduction␈1

1.1 ␇␇What Is This Book About?␈1 1.2 ␇␇Features of the Text␈3 1.2.1 ␇␇Running the Models␈5 1.2.2 ␇␇A Note on Notation␈6 1.3 ␇␇Getting Our Feet Wet: Amphibian Coexistence␈6

Chapter 2: ␇Linear Continuous Models␈19

2.1 ␇␇Mixing␈20 2.1.1 ␇␇Constructing a Model␈22 2.1.2 ␇␇Variations␈26 2.1.3 ␇␇Structure of the Problems Under Consideration␈28 2.2 ␇␇Blending␈30 2.2.1 ␇␇Constructing a Model␈32 2.2.2 ␇␇Variations␈36 2.3 ␇␇Project Management␈38 2.3.1 ␇␇Constructing a Model␈40 2.3.2 ␇␇Variations␈43 2.4 ␇␇Multi-Stage Models␈45 2.4.1 ␇␇Problem Instance␈46 2.4.2 ␇␇Constructing a Model␈48 2.4.3 ␇␇Variations␈54 2.5 ␇␇Pattern Classification␈57 2.5.1 ␇␇Constructing a Model␈58 2.5.2 ␇␇Executable Model␈60

Chapter 3: ␇Hidden Linear Continuous Models␈63 ———————————————–¿

3.1 ␇␇Piecewise Linear␈65 3.1.1 ␇␇Constructing a Model␈66 3.1.2 ␇␇Variations␈70 3.2 ␇␇Curve Fitting␈76 3.2.1 ␇␇Constructing a Model␈78 3.2.2 ␇␇Variations␈84 3.3 ␇␇Pattern Classification Revisited␈85 3.3.1 ␇␇Executable Model␈87

Chapter 4: ␇Linear Network Models␈89

4.1 ␇␇Maximum Flow␈90 4.1.1 ␇␇Constructing a Model␈91 4.1.2 ␇␇Decision Variables␈92 4.1.3 ␇␇Variations␈98 4.2 ␇␇Minimum Cost Flow␈99 4.2.1 ␇␇Constructing a Model␈100 4.2.2 ␇␇Variations␈105 4.3 ␇␇Transshipment␈106 4.3.1 ␇␇Constructing a Model␈107 4.3.2 ␇␇Variations␈112 4.4 ␇␇Shortest Paths␈113 4.4.1 ␇␇Constructing a Model␈114 4.4.2 ␇␇Alternate Algorithms␈118 4.4.3 ␇␇Variations␈118

Chapter 5: ␇Classic Discrete Models␈125

5.1 ␇␇Minimum Set Cover␈126 5.1.1 ␇␇Constructing a Model␈128 5.1.2 ␇␇Variations␈133 5.2 ␇␇Set Packing␈134 5.2.1 ␇␇Constructing a Model␈135 5.2.2 ␇␇Variations␈137 5.3 ␇␇Bin Packing␈137 5.3.1 ␇␇Constructing a Model␈139 5.4 ␇␇TSP␈150 5.4.1 ␇␇Constructing a Model␈151 5.4.2 ␇␇Variations␈157

Chapter 6: ␇Classic Mixed Models␈161

6.1 ␇␇Facility Location␈161 6.1.1 ␇␇Constructing a Model␈163 6.1.2 ␇␇Variations␈167 6.2 ␇␇Multi-Commodity Flow␈168 6.2.1 ␇␇Constructing a Model␈169 6.2.2 ␇␇Variations␈173 6.2.3 ␇␇Instances␈176 6.3 ␇␇Staffing Level␈176 6.3.1 ␇␇Constructing a Model␈179 6.3.2 ␇␇Variations␈184 6.4 ␇␇Job Shop Scheduling␈184 6.4.1 ␇␇Constructing a Model␈185

Chapter 7: ␇Advanced Techniques␈191

7.1 ␇␇Cutting Stock␈191 7.1.1 ␇␇Constructing a Model␈193 7.1.2 ␇␇Pre-Allocate Cutting Patterns␈200 7.2 ␇␇Non-Convex Trickery␈205 7.2.1 ␇␇Selecting k Variables Out of n to Be Non-Zero␈208 7.2.2 ␇␇Selecting k Adjacent Variables Out of n to Be Non-Zero␈210 7.2.3 ␇␇Selecting k Constraints Out of n␈215 7.2.4 ␇␇Maximax and Minimin␈221 7.3 ␇␇Staff Scheduling␈224 7.3.1 ␇␇Constructing a Model␈227 7.3.2 ␇␇Variations␈233 7.4 ␇␇Sports Timetabling␈234 7.4.1 ␇␇Constructing a Model␈234 7.4.2 ␇␇Variations␈245 7.5 ␇␇Puzzles␈245 7.5.1 ␇␇Pseudo-Chess Problems␈246 7.5.2 ␇␇Sudoku␈251 7.5.3 ␇␇Send More Money!␈254 7.5.4 ␇␇Ladies and Tigers␈257 7.6 ␇␇Quick Reference for OR-Tools MPSolver in Python␈263