1 ILOG Modeling Examples



Comments



Description

IBM Advanced Analytics Summit – April 2011Modeling Optimization Problems with IBM ILOG Cplex Optimization Studio © 2011 IBM Corporation Agenda  Optimization Development  Sample Application  CPLEX Studio – Projects – Run Configurations  OPL Language – Primitive Types – Tuples – Sets – Arrays  Application to Mathematical Programming  Application to Detailed Scheduling Using Constraint Programming © 2011 IBM Corporation Optimization Development Optimization Expert Mathematical Model Development Software Developer Traditional Application Development IBM ILOG CPLEX Studio reduces the time to market for optimization applications © 2011 IBM Corporation Simple Application User Interface GUI Database Forms Spreadsheet Mathematical Model Reporting Database Spreadsheet GUI IBM ILOG OPL Raw Data Input Data Database Spreadsheet Engine IBM ILOG CPLEX IBM ILOG CP Optimizer Output Data Database Spreadsheet Repository © 2011 IBM Corporation Solve . Key Features  OPL: Optimization Programming Language – A compact language to represent optimization problems – Advanced types for data organization – Supports solving mathematical programming models with CPLEX and applying constraint programming including scheduling with CP Optimizer – Connects to relational databases and Excel spreadsheets – ILOG Script for data processing and iterative solving © 2011 IBM Corporation . Key Features  Integrated Development Environment – Graphical editor for OPL models and data files – File and project organization – Review data and solutions as tables – Menus/buttons to debug optimization – Online help for OPL syntax – Access to engine features • Infeasibility Analysis • Solution Pools • Engine Parameters © 2011 IBM Corporation . Anatomy of an OPL Project OPL Project Run Configuration Run Configuration Run Configuration Model File (.mod) Data File (.ops) Data Structure Definitions Excel Connections Pre-Processing Database Connections Decision Variables CPLEX Settings Data Structure Objective FunctionCPO Settings Initializations Constraints Language Settings Post-Processing © 2011 IBM Corporation .dat) Settings File(. Anatomy of an OPL Project  Model Files – You can share multiple model files between different run configurations: Good for running the same model on many different data instances – You can have multiple model files in the same run configuration: Good for separating data structure definitions from model definitions  Data Files – You can share multiple data files between different run configurations: Good for testing different models on the same data instance – You can have multiple data files in the same run configuration: Good for separating different data initializations © 2011 IBM Corporation . The Optimization Programming Language (OPL) © 2011 IBM Corporation . . – {int} ProductIDs = ...OPL Language: Fundamental Types and Sets  The fundamental types in OPL are – float – int – string  You can also declare ranges – range r = 1.. © 2011 IBM Corporation ...100.  You can declare data consisting of sets of any of the fundamental types using one of two syntaxes – setof(string) Products = .. string s. "C"> }. © 2011 IBM Corporation .OPL Language: Tuples  OPL allows you to create structured data types. }. "B">. <5. <6.  You can define sets of tuples setof(pair) S = { <5. called tuples tuple pair { int v. "A">. 5>}.  … and arrays indexed on sets of tuples tuple Edges { int orig. int a[Edges] = [10. <1. 20. 30. <1. int dest. } {Edge} Edges = {<1.30]. © 2011 IBM Corporation .4>.20. 40]..2>.OPL Language: Arrays  OPL allows you to define arrays of fundamental types – int a[1.4] = [10. “dexpr” – For readability and to separate parts of the objective function dexpr float tasksWorked = sum(w in workers. dvar float+ production[p in products][timePeriods].  Decision expression .nShifts]. minimize tasksWorked. dvar boolean assign[workers][tasks].OPL Language: Decision variables and expressions  Decision variable .. © 2011 IBM Corporation . t in tasks) assign[w][t].“dvar” – Can be defined as: int. boolean – Indexed on ranges or sets dvar int nWorkers[1. float. forall (i in loopdata) { © 2011 IBM Corporation .10 : mydata[i] <= 10 }...10 : mydata[i] <= 10) {  Using Sets – When same filter needed more than once setof(int) loopdata = { i | i in 1..10) {  Conditional (filtered) Loop forall (i in 1.Conditional loops  Standard Loop forall (i in 1. Data driven relaxations  Use data to conditionally state a collection of constraints – Data declarations int includeBundleConstraint = . – Conditional constraints if (includeBundleConstraint == 1) { forall (i in S1) { sum (j in S2) x[j] <= b[i]. }.. } else { … } © 2011 IBM Corporation ...  Logical indicators (x == 0) => (y == 0).Examples of logical and nonlinear expressions  Semi-continuous order quantity: (x == 0) || (x >= 100).  Maximum deviation from a target value deviation == max (i in Index) abs(x[i]-target).  Benefits – Model is easier to develop and maintain – Can eliminate some big-M bounds © 2011 IBM Corporation . Zeros == sum (i in Index) (x[i] == 0). Examples and Demo © 2011 IBM Corporation . A Production Planning Example  A manufacturer wants to sell a product  The product can be made either – Inside the factory • Scarce resources are required to build the product • There is a cost per unit to manufacture the product – Outside the factory • There is a cost per unit to purchase the product  All demand must be satisfied  The objective is to minimize cost © 2011 IBM Corporation . . © 2011 IBM Corporation ....  Total number of available resources float capacity[Resources] = .... setof(string) Resources = ..  Number of units of each resource needed to produce one unit of each product float consumption[Products][Resources] = ..A Production Planning Example: Data Declarations  Sets of products and resources setof(string) Products = .  Number of units in demand for each product float demand[Products] = ..........  Cost per unit of inside and outside production float insideCost[Products] = .. float outsideCost[Products] = ... dvar float+ outside[Products].A Production Planning Example: Decision Variables  Inside and outside production dvar float+ inside[Products]. © 2011 IBM Corporation . A Production Planning Example: Objective Function  Inside and outside production cost dexpr float InsideCost = sum(p in Products) insideCost[p] * inside[p]. dexpr float OutsideCost = sum(p in Products) outsideCost[p]* outside[p]. © 2011 IBM Corporation . minimize InsideCost + OutsideCost. A Production Planning Example: Constraints  Capacity and demand constraints subject to { forall (r in Resources) ctCapacity: sum (p in Products) consumption[p][r]*inside[p] <= capacity[r]. }. © 2011 IBM Corporation . forall (p in Products) ctDemand: inside[p] + outside[p] >= demand[p].  Consumption Consumption = [ [3. OutsideCost = [ 260. [2. 270 ]. Resources = { gold diamonds }. 2] ]. 200 ]. 1].  Costs (per unit for rings and earrings) InsideCost = [ 250. 150 ].Products Could be Jewelry  Products and Resources Products = { rings earrings }.  Capacity (Available units of gold and diamonds) Capacity = [ 130. 180 ].  Demand (Number of rings and earrings) Demand = [ 100. © 2011 IBM Corporation .  Demand (Quantities of kluski.  Capacity (Available units of flour and eggs) Capacity = [20. 0. 40]. © 2011 IBM Corporation .2]. 0.6. and fettucine ) Demand = [100. 200.  Costs (per unit for of kluski. Resources = { flour eggs }.6] ].4. OutsideCost = [0. capellini. 0.3. 300]. and fettucine ) InsideCost = [0. [0.9. capellini. [0. 0. 0.Products Could be Pasta  Products and Resources Products = { kluski capellini fettucine }.3].  Consumption Consumption = [ [0.8.5. 0.4].4].8. 0. Statistics and Profiler tabs  Show Online help © 2011 IBM Corporation .Demo of Production Planning Example  Open OPL  Import Project  Show configuration  Show model. Engine log. data and settings files  Show input data tables  Solve  Show output data tables  Show Solutions. 000 is available at the beginning of the project and 30. – Some tasks must necessarily take place before others. – The building of a house must start after its release date – Each task requires one worker. – Each task costs a given amount of cash per day which must be available at the start of the task.000 is added every 60 days. – 30. roofing. painting … . – The objective is to minimize the overall completion date. © 2011 IBM Corporation .Scheduling using CP Optimizer . – Tasks are masonry.Demo  Building 5 houses with 3 workers and a cash budget. Demo of sched_cumul  Import the sched_cumul project  See model and data file  Solve problem  Display the results in the Console tab and the Solutions tab © 2011 IBM Corporation . – Its position in time is an unknown of the scheduling problem. an end value and a size. – An activity usually increases the cumulFunction at the start of the usage of the cumulative resources. – It is characterized by a start value. © 2011 IBM Corporation . and decreases the function when the resource is released at its end time (pulse function). – Its value depends on other decision variables of the problem. cumulFunction:  A cumulative function is used to model a quantity that varies over time.Brief intro to the Scheduling API in OPL interval variable:  An interval variable represents an interval of time during which an activity is carried out. etc. © 2011 IBM Corporation . – Examples: startAtEnd. endAtStart.Brief intro to the Scheduling API in OPL .cont pulse:  Pulse is a cumulative function expression that is used when an activity – increases the resource usage function at its start – decreases usage when it releases the resource at its end time. precedence constraint:  Precedence constraints are common scheduling constraints used to restrict the relative position of interval variables in a solution. startAfterEnd. .... }.....NbHouses. int ReleaseDate[Houses] = . tuple Precedence { string before. int NbWorkers = . = .CP Example – Scheduling using CP.... © 2011 IBM Corporation . {Precedence} Precedences = ... = 1.. string after.. {string} TaskNames int Duration [t in TaskNames] = ... int NbHouses range Houses = ... t in TaskNames) stepAtStart(itvs[h][t].sum(h in Houses.5) step(60*p..CP Example .maxint size Duration[t]. © 2011 IBM Corporation .. 30000) .Scheduling dvar interval itvs[h in Houses][t in TaskNames] in ReleaseDate[h]. 200*Duration[t]). cumulFunction cash = sum (p in 0.1). cumulFunction workersUsage = sum(h in Houses. t in TaskNames) pulse(itvs[h][t]. after]).CP-Example Scheduling minimize max(h in Houses) endOf(itvs[h]["moving"]).before]. cash >= 0. } © 2011 IBM Corporation . itvs[h][p. workersUsage <= NbWorkers. subject to { forall(h in Houses) forall(p in Precedences) endBeforeStart(itvs[h][p.
Copyright © 2024 DOKUMEN.SITE Inc.