hnquadminvarience

hnquadminvarience - GAMS 2.50A Windows NT/95/98 10/28/02...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: GAMS 2.50A Windows NT/95/98 10/28/02 14:48:44 PAGE 1 G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m C o m p i l a t i o n 1 ************************************************************************** 2 * * 3 * HAZEL AND NORTON (1986, P. 83) QUADRATIC PROGRAMMING EXAMPLE * 4 * * 5 * NOTE THAT I HAVE INCLUDED SOME MORE, AND SOME SLIGHTLY DIFFERENT * 6 * INCOME LEVELS THAN HAZEL AND NORTON DID AND THAT THESE RESULTS DIFFER * 7 * FROM THEIR RESULTS AT THE SAME INCOME LEVELS BECAUSE OF * 8 * ROUNDING DIFFERENCES. IN FACT IF YOU TRY TO COMPUTE THEIR VARIANCE * 9 * IN THIS EXAMPLE, UNLESS YOU KEEP ALL THE INTERMEDIATE NUMBERS THE SAME * 10 * AS WHAT THEY PRESENT, YOU WILL GET A DRASTICALLY DIFFERENT ANSWER THAN * 11 * THEY DID BECAUSE OF ROUNDING DIFFERENCES. * 12 * * 13 ************************************************************************** 14 * 15 * DEFINING THE VARIABLES AND THE CONSTRAINTS EXCEPT FOR THE INCOME AND 16 * ROTATION CONSTRAINTS 17 * 18 SET T YEARS /Y-1*Y-6/ 19 J CROPS /X1*X4/ 20 M RHS /LAND, LABOR/ 21 * The ALIAS command Command simply says that K has the same number of elements as J. 22 * GAMS REQUIRES THAT 23 * an Alias be used when squaring a matrix. See the variance calculation below; 24 * 25 ALIAS (J,K) 26 * ENTERING THE RAW GROSS MARGINS DATA 27 * 28 TABLE GM(T,J) GROSS MARGINS - PESOS PER HA 29 30 X1 X2 X3 X4 31 Y-1 292 -128 420 579 32 Y-2 179 560 187 639 33 Y-3 114 648 366 379 34 Y-4 247 544 249 924 35 Y-5 426 182 322 5 36 Y-6 259 850 159 569 37 * 38 * THE AIJ'S OF THE LAND AND LABOR CONSTRAINTS 39 * 40 TABLE A(M,J) COEFFICIENTS OF LAND LABOR AIJ'S 41 42 X1 X2 X3 X4 43 LAND 1 1 1 1 44 LABOR 25 36 27 87 45 * 46 * DEFINING COEFFICIENTS WHICH ARE EITHER CALCULATED BY 47 * GAMS OR ENTERED AS VECTORS RATHER THAN MATRICES 48 * 49 PARAMETERS AGM(J) AVERAGE GROSS MARGINS OF EACH ROTATION - PESOS 50 DEV(T,J) ANNUAL INCOME DEVIATIONS FROM MEAN - PESOS 51 VAR(J,K) THE VARIANCE COVARIANCE MATRIX 52 * 53 * THE AIJ COEFFICIENTS OF THE ROTATION ROW ENTERED AS A VECTOR GAMS 2.50A Windows NT/95/98 10/28/02 14:48:44 PAGE 2 G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m C o m p i l a t i o n 54 * 55 R(J) ROTATION CONSTRAINT AIJ'S 56 /X1 -1 57 X2 1 58 X3 -1 59 X4 1/ 60 * 61 * THE RHS OF THE LAND AND LABOR CONSTRAINTS ENTERED AS A VECTOR 62 * 63 B(M) RHS OF LAND LABOR CONSTRAINTS 64 /LAND 200 65 LABOR 10000/; 66 * 67 * CALCULATING THE AVERAGE GROSS MARGIN 68 * 69 AGM(J) = SUM(T,GM(T,J))/CARD(T); 70 * 71 * CALCULATING THE DEVIATIONS OF THE ANNUAL GROSS MARGINS FROM THE MEAN 72 * 73 DEV(T,J) = GM(T,J)-AGM(J); 74 * 75 * CALCULATING THE VARIANCE, COVARIANCE MATRIX 76 * 77 VAR(J,K) = SUM(T, DEV(T,J)*DEV(T,K))/(CARD(T)-1); 78 * 79 * REQUESTING THAT THE AVERAGE GROSS MARGIN AND THE ANNUAL DEVIATIONS 80 * BE PRINTED OUT 81 * 82 DISPLAY VAR, AGM, DEV; 83 * 84 * SPECIFYING COEFFICIENTS AS SCALARS 85 * 86 SCALARS INC AVERAGE TOTAL INCOME LEVEL /60000/ 87 * 88 * SPECIFYING THE VARIABLES IN THE MODEL 89 * 90 VARIABLES V VARIANCE OF TOTAL GROSS MARGIN...
View Full Document

Page1 / 32

hnquadminvarience - GAMS 2.50A Windows NT/95/98 10/28/02...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online