logging in or signing up AMPL DAN Rinald Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINTLite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 359 Category: Education License: All Rights Reserved Like it (1) Dislike it (0) Added: February 07, 2008 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript AMPL: AMPL A Mathematical Programming Language Presentation #3Outline: Outline Set operations Set indexing Advanced syntax ExampleSet Operations: Set Operations Set Operations: Set Operations Let A, B, and U be sets AMPL allows simple set operations: Union: U = A union B Intersection: U = A inter B Cross Product: U = { A , B } These operations become useful or necessary in many problemsAdvantage of Set Operations: Advantage of Set Operations Suppose we have 3 sets of products, CANDY TOYS GAMES In our model we may need to declare the following parameters for each: Price Supply DemandNaïve Setup: Naïve Setup Param Price_C {CANDY}; Param Price_T {TOYS}; Param Price_G {GAMES}; Param Supply_C {CANDY}; Param Supply_T {TOYS}; Param Supply_G {GAMES}; Param Demand_C {CANDY}; Param Demand_T {TOYS}; Param Demand_G {GAMES};Using Set Operation Union: Using Set Operation Union Param Price {CANDY union TOYS union GAMES}; Param Supply {CANDY union TOYS union GAMES}; Param Demand {CANDY union TOYS union GAMES};Even Better…: Even Better… Set PRODUCTS = CANDY union TOYS union GAMES; Param Price {PRODUCTS}; Param Supply {PRODUCTS}; Param Demand {PRODUCTS};Compound Sets: Compound Sets Suppose you have a set called PRODUCTS of products to sell at a store Consider that instead of one store you have three stores in different parts of the country Each store has a different level of each paramaterOne Solution: One Solution Instead of using the set PRODUCTS, make three different sets: PRODUCTS_1 PRODUCTS_2 PRODUCTS_3 Let each of the three numbers represent one of your store locationsOne Solution (cont…): One Solution (cont…) Next, define each parameter for each set of products: Param Price {PRODUCTS_1}; Param Supply {PRODUCTS_1}; Param Demand {PRODUCTS_1}; Param Price {PRODUCTS_2}; Param Supply {PRODUCTS_2}; … Easier Solution: Easier Solution For a better solution use compound sets: Param Price {PRODUCTS, STORES}; Param Supply {PRODUCTS, STORES}; Param Demand {PRODUCTS, STORES}; Structure of {PRODUCTS, STORES}: Structure of {PRODUCTS, STORES} Suppose PRODUCTS := oreos jenga lazertag ; STORES := 1 2 3 ; Then {PRODUCTS, STORES} is the set of all combinations of products with stores: (oreos,1) (oreos,2) (oreos,3) (jenga,1) (jenga,2) (jenga,3) (lazertag,1) (lazertag,2) (lazertag,3)Specifying Data : Specifying Data In your .dat file, your declaration of Demand could look like this: param Demand: 1 2 3 := oreos 10 20 30 jenga 30 33 42 lazertag 40 30 22 ; Set Indexing: Set Indexing Indexing of Sets: Indexing of Sets Indexing of a one dimensional set sum {i in PRODUCTS} cost[i]*make[i]; Indexing is similar in compound sets One can say sum { (i,j) in {PRODUCTS, STORES}} cost[i]*make[i,j]; or sum { i in PRODUCTS, j in STORES} cost[i]*make[i,j];When do we need indexing?: When do we need indexing? We may declare a parameter with or without giving index values: param Demand { PRODUCTS, STORES }; or param Demand { i in PRODUCTS, j in STORES }; With PRODUCTS and STORES:: With PRODUCTS and STORES: “The sales at each store will not exceed the demand for any given product at that store.” Could be expressed as the following constraint: subject to DEMAND {(i,j) in {PRODUCTS, STORES}}: Demand [i,j] >= Sell [i,j];With PRODUCTS and STORES:: With PRODUCTS and STORES: Suppose we have another parameter: Param Capacity {STORES}; Let the capacity of a store be the total number of items it can sell all together With PRODUCTS and STORES:: With PRODUCTS and STORES: “The total sales at any given store can not exceed the sales capacity of that store.” Could be expressed as follows Subject to CAPACITY {j in STORES}: Sum {i in PRODUCTS} Sell [i, j] <= Capacity [j]; Advanced Syntax: Advanced Syntax Tips and ShortcutsTransposition: Transposition How to Transpose: How to Transpose Recall an earlier example: Param Demand: 1 2 3 := oreos 10 20 30 jenga 30 33 42 lazertag 40 30 22 ;How to Transpose: How to Transpose Data in Transposed form Param Demand (tr): oreos jenga lazertag := 1 10 30 40 2 20 33 30 3 30 42 22 ; Why Transpose: Why Transpose Not Necessary, but can help with data management What if we had 30 stores? Param Demand (tr): oreos jenga lazertag := 1 10 30 40 2 20 33 30 3 30 42 22 ; Omitted Data: Omitted Data Omitted Data Entry: Omitted Data Entry Example: Consider the following data Param: Cost Supply Demand := oreos 10 20 30 jenga 30 33 42 lazertag 40 30 22 ; Omitted Data Entry: Omitted Data Entry Suppose in addition to the data specified in the previous table, you have an additional parameter such as: Param Calories {FOOD}; This parameter would apply to oreos, but not to jenga or lazertag.Example: Example Param: Cost Supply Demand := oreos 10 20 30 jenga 30 33 42 lazertag 40 30 22 ; Param: Calories := oreos 100 ;Example: Example Param: Cost Supply Demand Calories:= oreos 10 20 30 100 jenga 30 33 42 . lazertag 40 30 22 . ; We can use “.” to represent omitted data Example Problem: Example Problem Auto ProductionAuto Production: Auto Production You own an auto company and are setting up operation in a new country You want to decide which facilities to build and which cars to produce You want to maximize your profit after one yearCars and Buildings: Cars and Buildings You can make three types of cars: Sedan Hybrid Sport There are two different types of car production plants: Standard Car Plant High Tech Sport PlantCars and Buildings: Cars and Buildings There are two types of engine plants: Standard Engine Plant Hybrid Engine Plant An advanced tech center is required for some technologiesCost, Selling Price, Market: Cost, Selling Price, MarketBuilding Cost: Building CostFinal Details: Final Details Due to labor limitations you can produce no more than 5000 cars in the first year Your goal is to maximize profit You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
AMPL DAN Rinald Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINTLite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 359 Category: Education License: All Rights Reserved Like it (1) Dislike it (0) Added: February 07, 2008 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript AMPL: AMPL A Mathematical Programming Language Presentation #3Outline: Outline Set operations Set indexing Advanced syntax ExampleSet Operations: Set Operations Set Operations: Set Operations Let A, B, and U be sets AMPL allows simple set operations: Union: U = A union B Intersection: U = A inter B Cross Product: U = { A , B } These operations become useful or necessary in many problemsAdvantage of Set Operations: Advantage of Set Operations Suppose we have 3 sets of products, CANDY TOYS GAMES In our model we may need to declare the following parameters for each: Price Supply DemandNaïve Setup: Naïve Setup Param Price_C {CANDY}; Param Price_T {TOYS}; Param Price_G {GAMES}; Param Supply_C {CANDY}; Param Supply_T {TOYS}; Param Supply_G {GAMES}; Param Demand_C {CANDY}; Param Demand_T {TOYS}; Param Demand_G {GAMES};Using Set Operation Union: Using Set Operation Union Param Price {CANDY union TOYS union GAMES}; Param Supply {CANDY union TOYS union GAMES}; Param Demand {CANDY union TOYS union GAMES};Even Better…: Even Better… Set PRODUCTS = CANDY union TOYS union GAMES; Param Price {PRODUCTS}; Param Supply {PRODUCTS}; Param Demand {PRODUCTS};Compound Sets: Compound Sets Suppose you have a set called PRODUCTS of products to sell at a store Consider that instead of one store you have three stores in different parts of the country Each store has a different level of each paramaterOne Solution: One Solution Instead of using the set PRODUCTS, make three different sets: PRODUCTS_1 PRODUCTS_2 PRODUCTS_3 Let each of the three numbers represent one of your store locationsOne Solution (cont…): One Solution (cont…) Next, define each parameter for each set of products: Param Price {PRODUCTS_1}; Param Supply {PRODUCTS_1}; Param Demand {PRODUCTS_1}; Param Price {PRODUCTS_2}; Param Supply {PRODUCTS_2}; … Easier Solution: Easier Solution For a better solution use compound sets: Param Price {PRODUCTS, STORES}; Param Supply {PRODUCTS, STORES}; Param Demand {PRODUCTS, STORES}; Structure of {PRODUCTS, STORES}: Structure of {PRODUCTS, STORES} Suppose PRODUCTS := oreos jenga lazertag ; STORES := 1 2 3 ; Then {PRODUCTS, STORES} is the set of all combinations of products with stores: (oreos,1) (oreos,2) (oreos,3) (jenga,1) (jenga,2) (jenga,3) (lazertag,1) (lazertag,2) (lazertag,3)Specifying Data : Specifying Data In your .dat file, your declaration of Demand could look like this: param Demand: 1 2 3 := oreos 10 20 30 jenga 30 33 42 lazertag 40 30 22 ; Set Indexing: Set Indexing Indexing of Sets: Indexing of Sets Indexing of a one dimensional set sum {i in PRODUCTS} cost[i]*make[i]; Indexing is similar in compound sets One can say sum { (i,j) in {PRODUCTS, STORES}} cost[i]*make[i,j]; or sum { i in PRODUCTS, j in STORES} cost[i]*make[i,j];When do we need indexing?: When do we need indexing? We may declare a parameter with or without giving index values: param Demand { PRODUCTS, STORES }; or param Demand { i in PRODUCTS, j in STORES }; With PRODUCTS and STORES:: With PRODUCTS and STORES: “The sales at each store will not exceed the demand for any given product at that store.” Could be expressed as the following constraint: subject to DEMAND {(i,j) in {PRODUCTS, STORES}}: Demand [i,j] >= Sell [i,j];With PRODUCTS and STORES:: With PRODUCTS and STORES: Suppose we have another parameter: Param Capacity {STORES}; Let the capacity of a store be the total number of items it can sell all together With PRODUCTS and STORES:: With PRODUCTS and STORES: “The total sales at any given store can not exceed the sales capacity of that store.” Could be expressed as follows Subject to CAPACITY {j in STORES}: Sum {i in PRODUCTS} Sell [i, j] <= Capacity [j]; Advanced Syntax: Advanced Syntax Tips and ShortcutsTransposition: Transposition How to Transpose: How to Transpose Recall an earlier example: Param Demand: 1 2 3 := oreos 10 20 30 jenga 30 33 42 lazertag 40 30 22 ;How to Transpose: How to Transpose Data in Transposed form Param Demand (tr): oreos jenga lazertag := 1 10 30 40 2 20 33 30 3 30 42 22 ; Why Transpose: Why Transpose Not Necessary, but can help with data management What if we had 30 stores? Param Demand (tr): oreos jenga lazertag := 1 10 30 40 2 20 33 30 3 30 42 22 ; Omitted Data: Omitted Data Omitted Data Entry: Omitted Data Entry Example: Consider the following data Param: Cost Supply Demand := oreos 10 20 30 jenga 30 33 42 lazertag 40 30 22 ; Omitted Data Entry: Omitted Data Entry Suppose in addition to the data specified in the previous table, you have an additional parameter such as: Param Calories {FOOD}; This parameter would apply to oreos, but not to jenga or lazertag.Example: Example Param: Cost Supply Demand := oreos 10 20 30 jenga 30 33 42 lazertag 40 30 22 ; Param: Calories := oreos 100 ;Example: Example Param: Cost Supply Demand Calories:= oreos 10 20 30 100 jenga 30 33 42 . lazertag 40 30 22 . ; We can use “.” to represent omitted data Example Problem: Example Problem Auto ProductionAuto Production: Auto Production You own an auto company and are setting up operation in a new country You want to decide which facilities to build and which cars to produce You want to maximize your profit after one yearCars and Buildings: Cars and Buildings You can make three types of cars: Sedan Hybrid Sport There are two different types of car production plants: Standard Car Plant High Tech Sport PlantCars and Buildings: Cars and Buildings There are two types of engine plants: Standard Engine Plant Hybrid Engine Plant An advanced tech center is required for some technologiesCost, Selling Price, Market: Cost, Selling Price, MarketBuilding Cost: Building CostFinal Details: Final Details Due to labor limitations you can produce no more than 5000 cars in the first year Your goal is to maximize profit