Amsterdam Optimization Modeling Group LLC
Modeling with Excel+OML, a practical guide This document describes the use of Microsofts OML language to specify Mathematical Programming Models. The emphasis is on modeling rather than programming. A number of actual annotated models is presented to illustrate how this new modeling system can be used to implement and solve practical problems. The models in this paper are based on MS Solver Foundation 1.x.
Erwin 10/16/2009
http://www.amsterdamoptimization.com/damsquare.html
1 CONTENTS
2 Introduction ........................................................................................................................................................... 4
2.1 Modeling Language vs. API .......................................................................................................................... 5
2.2 A transportation Model ............................................................................................................................... 5
2.2.1 A GAMS Representation .......................................................................................................................... 6
2.2.2 An Excel Solver Approach ........................................................................................................................ 8
2.2.3 The OML Implementation ...................................................................................................................... 12
2.2.4 Microsoft Solver Foundation ................................................................................................................. 14
3 OML the language................................................................................................................................................ 14
3.1 Parameters ................................................................................................................................................. 15
3.1.1 Sets ........................................................................................................................................................ 15
3.1.2 Scalars .................................................................................................................................................... 15
3.1.3 Indexed Parameters ............................................................................................................................... 16
3.2 Decisions .................................................................................................................................................... 16
3.2.1 Domains ................................................................................................................................................. 17
3.2.2 Foreach .................................................................................................................................................. 17
3.2.3 FilteredForeach ...................................................................................................................................... 17
3.3 Constraints ................................................................................................................................................. 18
3.3.1 Summations ........................................................................................................................................... 18
3.3.2 All-Different Constraints ........................................................................................................................ 19
3.3.3 Implies.................................................................................................................................................... 19
3.3.4 And, Or ................................................................................................................................................... 19
3.4 Data Binding ............................................................................................................................................... 19
3.4.1 Scalars .................................................................................................................................................... 20
3.4.2 Vectors ................................................................................................................................................... 21
3.4.3 Empty cells ............................................................................................................................................. 22
3.4.4 Matrices ................................................................................................................................................. 24
3.4.5 Data Tables ............................................................................................................................................ 24
3.4.6 Sparse Tables ......................................................................................................................................... 26
3.4.7 Data Layout ............................................................................................................................................ 26
3.4.8 Range Names ......................................................................................................................................... 27
3.4.9 Debugging .............................................................................................................................................. 29
3.4.10 Performance ...................................................................................................................................... 29
4 Some API Notes ................................................................................................................................................... 30
4.1 Running OML from C# ................................................................................................................................ 30
4.2 Calling C# from Excel .................................................................................................................................. 34
5 Examples .............................................................................................................................................................. 35
5.1 A Diet Problem ........................................................................................................................................... 35
5.2 Max Flow, a network Model ...................................................................................................................... 37
5.3 The Social Golfer Problem .......................................................................................................................... 41
5.4 Job shop scheduling ................................................................................................................................... 45
5.5 Magic Squares ............................................................................................................................................ 49
5.6 Sudoku........................................................................................................................................................ 53
5.7 Langford Sequences ................................................................................................................................... 54
5.8 Traveling Salesman Problem ...................................................................................................................... 56
5.9 Tiling Squares ............................................................................................................................................. 59
5.10 Alphametics ................................................................................................................................................ 66
5.11 Data Envelopment Analysis ........................................................................................................................ 69
5.12 Quadratic Programming and Portfolio Models .......................................................................................... 72
5.12.1 Mean-variance Portfolio Selection and Efficient Frontiers ............................................................... 72
5.12.2 LP Approximations and .NET DLLs .................................................................................................... 75
5.13 Column Generation for Cutting Stock problems ........................................................................................ 84
5.13.1 Delayed Column Generation ............................................................................................................. 84
5.13.2 Bin Backing Formulation .................................................................................................................... 95
5.13.3 Heuristics ........................................................................................................................................... 97
6 Bibliography ......................................................................................................................................................... 99
2 INTRODUCTION
Microsoft has a long history with offering optimization tools. Inside Excel is Solver which can solve linear
programming problems, mixed-integer programming problems and non-linear problems (Fylstra,