$Title Blending Example $Ontext This is a Blending Example taken from section 1.2 of Model Building in Mathematical Programming by H. Paul Williams. $Offtext * * First describe the sets over which we index over. There * are two types of Vegitable oil and three types of non-vegitable oils. * Sets VegType type of vegitable oil /1, 2/ NonVegType type of NonVegitable oil /1, 2, 3/; * * This section begins the DATA part of the GAMS code. All data * should be collected together, and there should no be any data * specific instances in the equations section below. It is important * to keep data seperate from the model. * Parameters VegHard(VegType) / 1 8.8 2 6.1/ NonVegHard(NonVegType) / 1 2.0 2 4.2 3 5.0/ VegCost(VegType) / 1 110 2 120/ NonVegCost(NonVegType) / 1 130 2 110 3 115/; Scalar VegLim upper bound on vegatible oil /200/; Scalar NonVegLim upper bound on nonvegitable oil /250/; Scalar HardUpBound upper bound on final prod. hardness /6/; Scalar HardLoBound lower bound on final prod. hardness /3/; Scalar SellPrice selling price for the final product /150/; * * This Ends the DATA section of the GAMS code. * * * Describe the decision variables. * Variables VegUse(VegType) amount of vegitable oil used NonVegUse(NonVegType) amount of nonvegitable oil used TotProd total product z total profit; * Make sure the variables are nonnegative, except the objective function * variable which MUST be free. Positive variables VegUse, NonVegUse; free variable z; * * The Equations Section is split into two parts. First the equations must * be defined and then assigned. * Equations VegUseBound Bound the Use of Vegitable Oil NonVegUseBound Bound the Use of NonVegtibable Oil ProdHardUpBound Don't exceed the hardness up bound ProdHardLoBound Guarantee the hardness lower bound BalInOut Wieght of final proj is wieght of raw materials Cost Cost row; * The equation assignments are below. VegUseBound.. sum(VegType,VegUse(VegType)) =l= VegLim; NonVegUseBound.. sum(NonVegType, NonVegUse(NonVegType)) =l= NonVegLim; ProdHardUpBound.. sum(VegType,VegHard(VegType)*VegUse(VegType)) + sum(NonVegType, NonVegHard(NonVegType)*NonVegUse(NonVegType)) =l= HardUpBound*TotProd; ProdHardLoBound.. sum(VegType,VegHard(VegType)*VegUse(VegType)) + sum(NonVegType, NonVegHard(NonVegType)*NonVegUse(NonVegType)) =g= HardLoBound*TotProd; BalInOut.. sum(VegType,VegHard(VegType)*VegUse(VegType)) + sum(NonVegType, NonVegHard(NonVegType)*NonVegUse(NonVegType)) =g= TotProd; Cost.. SellPrice*TotProd - sum(VegType,VegCost(VegType)*VegUse(VegType)) - sum(NonVegType, NonVegCost(NonVegType)*NonVegUse(NonVegType)) =e= z; * * The model statement assings constraints to a model name. In this * case we use all the constraints in a model called Blend. There may * be several model statements within the GAMS code, which allows you * add and remove constraints as you wish. * Model Blend /all/; * * The solve statement indicates which model to solve, what type of model * it is, and which variable to optimize. In this case we are solving the * Blend, it is a linear program, and we are maximizing the variable z. * Solve Blend using lp maximizing z; * * The Display statment indicates the information you want GAMS to record * in the lst file. In this case we are getting GAMS to record the "levels" * of the Use variables for vegitable and nonvegitable oil. * Display VegUse.l, NonVegUse.l;