*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX* $ontext * Exercise (3): MY FARM Model with sets and sum *### The objective of the exercise: 1) Getting acquainted with the GAMS programming language. *### The problem: A farmer wants to maximize his profit using 200 ha of land and 10000 hours of p_labor avaip_lable. He has the option of cultivating three types of cols: wheat, barley, rapeseed and sugarbeet. The profit received and p_labor hours required for producing one ha of each crop are presented in the table below. How much of each crop does he need to cultivate in order to maximize his profit? Item Wheat Barley Rapeseed Sugarbeet Profit in Eurp/ha 253 443 284 516 Required p_labor hours/ha 25 36 27 87 *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX* $offtext sets cols / wheat barley rapeseed sugarbeet / ; Parameters p_UVAG(cols) gross margin p_lab(cols) p_labour quantity ; p_UVAG("wheat") = 253; p_UVAG("barley") = 443; p_UVAG("rapeseed") = 284; p_UVAG("sugarbeet") = 516; p_lab("wheat") = 25; p_lab("barley") = 36; p_lab("rapeseed") = 27; p_lab("sugarbeet") = 87; Variables v_obje objective function value ; Positive variable v_actLevl(cols) land area planted with crop ; Equations e_land land constraint e_labour labour constraint e_obj objective function ; e_obj .. v_obje =E= sum (cols, v_actLevl(cols)*p_UVAG(cols)); e_land .. sum (cols, v_actLevl(cols)) =L= 200; e_labour .. sum (cols, p_lab(cols)*v_actLevl(cols)) =L= 10000; Model myfarm /e_land, e_labour,e_obj /; Solve myfarm using lp maximizing v_obje; *-------- * Exercise 6 - Scenario analysis *-------- Parameter p_results(*,*); p_results(cols, "base") = v_actLevl.L(cols); p_results("Labour", "base") = sum (cols,p_lab(cols)*v_actLevl.L(cols)); p_results("Gross Margin", "base") = v_obje.L; *-------- * Exercise 6.1 - Increase gross margin *-------- p_UVAG("rapeseed") = 450; Solve myfarm using lp maximizing v_obje; p_results(cols, "R-Hi") = v_actLevl.L(cols); p_results("Labour", "R-Hi") = sum (cols, p_lab(cols)*v_actLevl.L(cols)); p_results("Gross Margin", "R-Hi") = v_obje.L; * restore old rapeseed gross margin p_UVAG("rapeseed") = 284; *-------- * Exercise 6.2 - VCS *-------- * Add VCS payment as a parameter Parameter p_vcs(cols); p_vcs("wheat") = 175; * Define a new objective function including the VCS Equations e_obj_vcs objective function including volunatry coupled support payments; e_obj_vcs .. v_obje =E= sum (cols, v_actLevl(cols)*(p_UVAG(cols) + p_vcs(cols))) ; * Create a new model replacing the objective function with our new one * and solve the new model model myfarm_vcs / myfarm - e_obj + e_obj_vcs/; Solve myfarm_vcs using lp maximizing v_obje; * store the results p_results(cols, "VCS") = v_actLevl.L(cols); p_results("Labour", "VCS") = sum (cols, p_lab(cols)*v_actLevl.L(cols)); p_results("Gross Margin","VCS") = v_obje.L; set vcs / vcs_170 * vcs_175 /; loop (vcs, p_vcs("wheat") = 169 + ord(vcs); Solve myfarm_vcs using lp maximizing v_obje; p_results(cols, vcs) = v_actLevl.L(cols); p_results("Labour", vcs) = sum (cols, p_lab(cols)*v_actLevl.L(cols)); p_results("Gross Margin", vcs) = v_obje.L; p_results("Total Payments","VCS")= sum (cols, v_actLevl.L(cols)*(p_vcs(cols))) ; ); *-------- * Exercise 6.3 - Decoupled support (DIS) *-------- Parameter p_dis; p_dis = 105; Equations e_obj_dis objective function including decoupled income support payments ; e_obj_dis .. v_obje =E= sum (cols, v_actLevl(cols)*(p_UVAG(cols) + p_dis)) ; model myfarm_dis / myfarm - e_obj + e_obj_dis /; Solve myfarm_dis using lp maximizing v_obje; p_results(cols, "DIS") = v_actLevl.L(cols); p_results("Labour", "DIS") = sum (cols, p_lab(cols)*v_actLevl.L(cols)); p_results("Gross Margin", "DIS") = v_obje.L; p_results("Total Payments","DIS")= sum (cols, v_actLevl.L(cols)*(p_vcs(cols) + p_dis)) ; *-------- * Exercise 6.4 - Sugarbeet quota *-------- p_UVAG("sugarbeet") = 650; Parameter p_quota(cols); p_quota("sugarbeet") = 20; Equation e_quota(cols) quota constraint ; e_quota(cols)$p_quota(cols) .. v_actLevl(cols) =L= p_quota(cols); model myfarm_quot / myfarm + e_quota /; Solve myfarm_quot using lp maximizing v_obje; p_results(cols, "QUOT") = v_actLevl.L(cols); p_results("Labour", "QUOT") = sum (cols, p_lab(cols)*v_actLevl.L(cols)); p_results("Gross Margin", "QUOT") = v_obje.L; *-------- * Exercise 6.5 - Sugarbeet quota & VCS *-------- model myfarm_quot_comb / myfarm_vcs + e_quota /; *p_vcs("wheat") = 250; Solve myfarm_quot_comb using lp maximizing v_obje; p_results(cols, "QUOT_VCS") = v_actLevl.L(cols); p_results("Labour", "QUOT_VCS") = sum (cols, p_lab(cols)*v_actLevl.L(cols)); p_results("Gross Margin", "QUOT_VCS") = v_obje.L; display p_results;