AMPL DAN

Uploaded from authorPOINTLite
Views:
 
Category: Education
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

AMPL: 

AMPL A Mathematical Programming Language Presentation #3

Outline: 

Outline Set operations Set indexing Advanced syntax Example

Set 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 problems

Advantage 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 Demand

Naï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 paramater

One 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 locations

One 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 Shortcuts

Transposition: 

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 Production

Auto 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 year

Cars 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 Plant

Cars 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 technologies

Cost, Selling Price, Market: 

Cost, Selling Price, Market

Building Cost: 

Building Cost

Final 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