1 / 19

Conditions and Indexes in the Sum and For Every methods

Conditions and Indexes in the Sum and For Every methods. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered set Define Variables X = { CARS } , 0<=X.i<=inf. Using Conditions in Sum and For Every statements. Summation Statement without conditions Autos = sum i ( X.i )

lexi
Télécharger la présentation

Conditions and Indexes in the Sum and For Every methods

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Conditions and Indexes in the Sum and For Every methods

  2. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered set Define Variables X = { CARS } , 0<=X.i<=inf Using Conditions in Sum and For Every statements Summation Statement without conditions Autos = sum i ( X.i ) AUTOS = X.bmw + X.chevy + X.chrysler + X.ford + X.toyota

  3. Other examples of Summation Statement Yogurt + sum i ( X.i ) = Cheese sum i ( X.i ) + sum j (Y.j) >=1234 Yogurt - sum i,j (Z.i,j) + X.bmw <= Sum i (X.i) 2 Yogurt + 2 Cheese <= 120 A model that uses set notation may also contain any linear constraint.

  4. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered set Define Variables X = { CARS } , 0<=X.i<=inf Example 1: Condition limiting an index Autos = sum i,i<=3 ( X.i ) AUTOS = X.bmw + X.chevy + X.chrysler

  5. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered set Define Variables X = { CARS } , 0<=X.i<=inf Example 2: Condition upper and lower limits on an index Domestic = sum i,i>=2,i<=4 ( X.i ) DOMESTIC = X.chevy + X.chrysler + X.ford

  6. Using indexes and comparisons • You may use any of the following logical operators in a condition: • > greater than • < less than • >= greater than or equal to • <= less than or equal to • = equal to • <> not equal to • The SUM and FOR EVERY statement may contain up to ten conditions containing simple math expressions. The use of parenthesis in an condition is prohibited. • Examples: • Sum i,i+1<6 (X.i) • For Every a,b,d,a+b-d>=4 : GOODS.a.b.d >=20 • Sum a,b,k,2a-3b>4k,a>=2,k>=3 (DATA.a.b * Y.b.k) • For Everyi,i>1: MAKE.i + INVENTORY.(i-1) = DEMAND.i + INVENTORY.i

  7. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered set Define Variables X = { CARS } , 0<=X.i<=inf For Every Statement without conditions AllAutos for every i : X.i <= 123 AllAutos.bmw: X.bmw <= 123 AllAutos.chevy: X.chevy <= 123 AllAutos.chrysler: X.chrysler <= 123 AllAutos.ford: X.ford <= 123 AllAutos.toyota: X.toyota <= 123

  8. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered set Define Variables X = { CARS } , 0<=X.i<=inf Example 3: Condition limiting an index ThreeCars for every i,i<=3 : X.i <= 123 ThreeCars.bmw: X.bmw <= 123 ThreeCars.chevy: X.chevy <= 123 ThreeCars.chrysler: X.chrysler <= 123

  9. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered set Define Variables X = { CARS } , 0<=X.i<=inf Example 4:Condition upper and lower limits on an index Domestic for every i,i>=2,i<=4 : X.i <= 123 Domestic.chevy: X.chevy <= 123 Domestic.chrysler: X.chrysler <= 123 Domestic.ford: X.ford <= 123

  10. Define Names CARS.i = { bmw chevy chrysler ford toyota}, ordered set Define Names VINTAGE.v = { yr2002 yr2003 yr2004 }, ordered set Define Variables X = { CARS by VINTAGE } , 0<=X.i.v<=inf Example 5: Compound Condition SelectAutos = sum i,v,i>=v ( X.i.v ) SELECTAUTOS = X.bmw.yr2002 + X.chevy.yr2002 + X.chevy.yr2003 + X.chrysler.yr2002 + X.chrysler.yr2003 + X.chrysler.yr2004 + X.ford.yr2002 + X.ford.yr2003 + X.ford.yr2004 + X.toyota.yr2002 + X.toyota.yr2003 + X.toyota.yr2004

  11. Constant Table Price

  12. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered set Define Names VINTAGE.v = { yr2002 yr2003 yr2004 }, ordered set Define Variables X = { CARS by VINTAGE } , 0<=X.i.v<=inf Example 6: Using a Constant table Value = sum i,v,price.i.v>29000 ( X.i.v ) VALUE = X.bmw.yr2002 + X.bmw.yr2003 + X.bmw.yr2004 + X.chrysler.yr2004 + X.toyota.yr2004

  13. Constant Table Quality

  14. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered set Define Names VINTAGE.v = { yr2002 yr2003 yr2004 }, ordered set Define Variables X = { CARS by VINTAGE } , 0<=X.i.v<=inf Example 7: Using a Constant table with Letters Value = sum i,v,quality.i.v=‘great’ ( X.i.v ) VALUE = X.bmw.yr2002 + X.bmw.yr2003 + X.bmw.yr2004 + X.chevy.yr2004 + X.chrysler.yr2004 + X.ford.yr2004 + X.toyota.yr2003 + X.toyota.yr2004

  15. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered set Define Names VINTAGE.v = { yr2002 yr2003 yr2004 }, ordered set Define Variables X = { CARS by VINTAGE } , 0<=X.i.v<=inf Example 8: Using a Constant table with Letters Value = sum i,v,quality.i.v=‘great’ ( price.i.v * X.i.v ) VALUE = 35000 X.bmw.yr2002 + 40000 X.bmw.yr2003 + 45000 X.bmw.yr2004 + 28000 X.chevy.yr2004 + 32000 X.chrysler.yr2004 + 26000 X.ford.yr2004 + 28000 X.toyota.yr2003 + 30000 X.toyota.yr2004

  16. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered set Define Names VINTAGE.v = { yr2002 yr2003 yr2004 }, ordered set Define Variables X = { CARS by VINTAGE } , 0<=X.i.v<=inf Example 9: Condtions within both the For Every and Sum methods Joint for every i : sum v,quality.i.v=‘great’ (X.i.v) >= 12 Joint.bmw: X.bmw.yr2002 + X.bmw.yr2003 + X.bmw.yr2004 >= 12 Joint.chevy: X.chevy.yr2004 >= 12 Joint.chrysler: X.chrysler.yr2004 >= 12 Joint.ford: X.ford.yr2004 >= 12 Joint.toyota: X.toyota.yr2003 + X.toyota.yr2004 >= 12

  17. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered setDefine Names VINTAGE.v = { yr2002 yr2003 yr2004 }, ordered set Define Subset IMPORTS.m = { bmw chrysler toyota }, subset of CARS.i Define Variables X = { CARS by VINTAGE } , 0<=X.i.v<=inf Example 10: Using SUBSETS to selectively choose members. You may also use conditions with subsets. Subset IMPORTS includes BMW, Daimler-Chrysler, and Toyota. Writing a condition to choose only these makes of vehicles would be difficult. The subset members must be completely contained in another set. Such as, all the members in IMPORTS are contained in the set CARS. You may not included Volvo in the subset IMPORTS because it is not listed in the set CARS. In the following example the constraints are limited only to import makes of vehicles. Some for every m : sum v ( X.m.v ) >= 3.2 Some.bmw: X.bmw.yr2002 + X.bmw.yr2003 + X.bmw.yr2004 >= 3.2 Some.chrysler: X.chrysler.yr2002 + X.chrysler.yr2003 + X.chrysler.yr2004 >= 3.2 Some.toyota: X.toyota.yr2002 + X.toyota.yr2003 + X.toyota.yr2004 >= 3.2

  18. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered setDefine Names VINTAGE.v = { yr2002 yr2003 yr2004 }, ordered set Define Subset IMPORTS.m = { bmw chrysler toyota }, subset of CARS.i Define Variables X = { CARS by VINTAGE } , 0<=X.i.v<=inf Example 11: Using SUBSETS to create constant tables Price2

  19. Define Names CARS.i = { bmw chevy chrysler ford toyota }, ordered setDefine Names VINTAGE.v = { yr2002 yr2003 yr2004 }, ordered set Define Subset IMPORTS.m = { bmw chrysler toyota }, subset of CARS.i Define Variables X = { CARS by VINTAGE } , 0<=X.i.v<=inf Example 11: These SUBSETS can be used in conditions and equations. Some2for every m : sum v,price2.m.v>=30000 ( PRICE2.m.v * X.m.v ) >= 3.2 Some2.bmw: 35000 X.bmw.yr2002 + 40000 X.bmw.yr2003 + 45000 X.bmw.yr2004 >= 3.2 Some2.chrysler: 32000 X.chrysler.yr2004 >= 3.2 Some2.toyota: 30000 X.toyota.yr2004 >= 3.2

More Related