$TITLE A FARMING PROBLEM (FARMING,SEQ=1) $OFFUPPER * This problem finds an optimal farming strategy. * * References: * Katta Murty, Operations Research * Prentice Hall, 1995 * Chapter 2-10. * SETS CROPS / wheat, corn / ANIMS /pigs, chickens/ CTYPES grains are bought or sold /buy, sell/ ANIMUSAGE /wheatbt, wheatsold, cornbt, cornsold, floor, hours, price/ ANIMTYPES /pigswtby pigswtsl pigscnby pigscnsl chickswtby chickswtsl chickscnby chickscnsl/ USAGESELL(animusage) / wheatsold cornsold/; PARAMETER *** data for the crops YIELD(CROPS) bushels per acre per year /wheat 55 corn 95 / HOURS(CROPS) manhours per bushel /wheat .15 corn .70 / SELLPRICE(CROPS) selling price per bushel /wheat 1.75 corn .95 / BUYPRICE(CROPS) buying price per bushel /wheat 2.50 corn 1.50 /; SCALAR AREATOT acres for growing /120/ CULT manhours for cultivation per acre per year /4/; TABLE RES(animtypes,animusage) wheatbt wheatsold cornbt cornsold floor hours price pigswtby 25 0 0 0 25 25 200 pigswtsl 0 25 0 0 25 25 200 pigscnby 0 0 20 0 25 25 200 pigscnsl 0 0 0 20 25 25 200 chickswtby 10 0 0 0 15 40 200 chickswtsl 0 10 0 0 15 40 200 chickscnby 0 0 25 0 15 40 200 chickscnsl 0 0 0 25 15 40 200; SCALAR AREAF square feet for raising animals /10000/ HOURSf hours available for raising animals /2000/; SCALAR HOURSTOT total manhours available for the farmer /4000/ HIRERATE additional labour cost per hour /4/; VARIABLES Z total profit; POSITIVE VARIABLE ACRES(crops) acres devoted for each crop NUMBER(animtypes) number of animals raised of each type BUY(crops) bushels of each crop bought for animals EAT(crops) bushels of each crop eaten by animals HIRING number of hours of hired labour for animals ; EQUATIONS PROFIT define objective function LABOUR limit of total labour hours LABOUR1 limit of farmer labour hours LABOUR2 limit of total crop labour hours RAISE square foot limit for raising animals FOOD amount of bushels of farmer's grain used for animals GROW acre limit for growing crops; PROFIT .. Z =E= SUM(crops, (ACRES(crops)*YIELD(crops)-EAT(crops))*SELLPRICE(crops)) +SUM(animtypes, NUMBER(animtypes)*RES(animtypes,"price") ) - SUM(crops, BUY(crops)*BUYPRICE(crops) ) - HIRING*HIRERATE; LABOUR .. sum(crops, yield(crops)*hours(crops)*acres(crops) ) + sum(animtypes, RES(animtypes,"hours")*number(animtypes)) =L= (HOURSTOT-HIRING*.1) + HIRING; LABOUR1 .. HOURSTOT-HIRING*.1 =G= 0; LABOUR2 .. sum(crops, yield(crops)*hours(crops)*acres(crops) ) =L= (HOURSTOT/2 - HIRING*.1) + HIRING; RAISE .. SUM(animtypes, RES(animtypes,"floor")*number(animtypes)) =L=AREAF; FOOD .. SUM((animtypes,usagesell), RES(animtypes,usagesell)*number(animtypes) ) =L= SUM(crops, ACRES(crops)*YIELD(crops) ) ; GROW .. SUM(crops, acres(crops) ) =L= AREATOT ; MODEL FARMING /ALL/ ; SOLVE FARMING USING LP MAXIMIZING Z ; DISPLAY grow.l, grow.m, number.l, number.m