Download Mosel User Guide
Transcript
Contents I Using the Mosel language 1 Introduction Why you need Mosel . . . . . . . . . . . . . . What you need to know before using Mosel Symbols and conventions . . . . . . . . . . . . The structure of this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 2 3 4 1 Getting started with Mosel 1.1 Entering a model . . . . . . . . . . . . . . . . 1.2 The chess set problem: description . . . . . . 1.2.1 A first formulation . . . . . . . . . . . 1.3 Solving the chess set problem . . . . . . . . . 1.3.1 Building the model . . . . . . . . . . . 1.3.2 Obtaining a solution using Mosel . . . 1.3.3 Running Mosel from a command line 1.3.4 Using Xpress-IVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 5 5 5 6 6 7 8 9 2 Some illustrative examples 2.1 The burglar problem . . . . . . . . . . . . . . . . . . . . 2.1.1 Model formulation . . . . . . . . . . . . . . . . . 2.1.2 Implementation . . . . . . . . . . . . . . . . . . . 2.1.3 The burglar problem revisited . . . . . . . . . . . 2.2 A blending example . . . . . . . . . . . . . . . . . . . . . 2.2.1 The model background . . . . . . . . . . . . . . . 2.2.2 Model formulation . . . . . . . . . . . . . . . . . 2.2.3 Implementation . . . . . . . . . . . . . . . . . . . 2.2.4 Re-running the model with new data . . . . . . 2.2.5 Reading data from spreadsheets and databases 2.2.5.1 Spreadsheet example . . . . . . . . . . 2.2.5.2 Database example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 10 10 10 13 14 14 14 15 16 17 17 18 3 More advanced modeling features 3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . 3.2 A transport example . . . . . . . . . . . . . . . . . 3.2.1 Model formulation . . . . . . . . . . . . . . 3.2.2 Implementation . . . . . . . . . . . . . . . . 3.3 Conditional generation — the | operator . . . . . 3.3.1 Conditional variable creation and create 3.4 Reading sparse data . . . . . . . . . . . . . . . . . . 3.4.1 Data input with initializations from 3.4.2 Data input with readln . . . . . . . . . . . 3.4.3 Data input with diskdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 19 19 19 20 21 22 23 23 24 24 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Integer Programming 26 4.1 Integer Programming entities in Mosel . . . . . . . . . . . . . . . . . . . . . . . . . 26 4.2 A project planning model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 i Mosel User Guide