Problem with modelling Feed Mix problem

Problems with syntax of GAMS
Post Reply
jack_
User
User
Posts: 1
Joined: 1 year ago

Problem with modelling Feed Mix problem

Post by jack_ »

Here is my current code

*Broiler poultry feed cost optimization


sets age Dietary concerning age
/Max_Starter,Min_Starter,Max_Finisher,Min_Finisher/

ingr ingredients
/Maize Maize,
Bajra Bajra,
Wheat Wheat,
Sorghum Sorghum,
BRice Broken Rice,
RiceB Rice Bran,
WheatB Wheat Bran,
SoybeanM Soybean Meal,
CSM Cottonseed Meal,
GroundnutC Groundnut Cake,
SOC Sunflower oil cake,
FishM Fish Meal,
MBM Meat and bone meal,
LimestoneP Limestone powder,
DCP Di-calcium phosphate,
Salt Salt
/

supl supplements
/MetaE,Prot,Fat,Cal,P,Ly,Met,Sod,Chlo,Cost/;

parameter Data (age,ingr,supl)

$call GDXXRW C:\gamstest\PoultryData.xlsx output=C:\gamstest\PoultryData.gdx par=Data rng=Data!a1:l65 rdim=2 cdim=1
$GDXIN C:\gamstest\PoultryData.gdx
$LOAD Data
$GDXIN

display Data;

Parameter ResMax_Starter(supl) Resource constraint Max_Starter
/MetaE 3500
Prot 40.0
Fat 2.5
Cal 1.5
P 0.7
Ly 2.5
Met 0.7
Sod 0.3
Chlo 0.5/

ResMin_Starter (supl) Resource constraint Min_Starter
/MetaE 2800
Prot 15.0
Fat 1.0
Cal 0.5
P 0.1
Ly 0.5
Met 0.2
Sod 0.02
Chlo 0.05/

ResMax_Finisher (supl) Resource constraint Max_Finisher
/MetaE 4000
Prot 22.0
Fat 6.0
Cal 1.0
P 0.6
Ly 2.0
Met 0.7
Sod 0.3
Chlo 0.5/

ResMin_Finisher (supl) Resource constraint Min_Finisher
/MetaE 3050
Prot 13.0
Fat 1.0
Cal 0.3
P 1.0
Ly 0.5
Met 0.2
Sod 0.02
Chlo 0.05/

report0(*,*)
report1(*,supl,*);

free variable MinCost;
positive Variable DIET(ingr,supl);
equation objf objective function
ResConst(ingr) resource constraint feed mix
ResConstMaxStarter(supl) resource constraint Max_Starter
ResConstMinStarter(supl) resource constraint Min_Starter
ResConstMaxFinisher(supl) resource constraint Max_Finisher
ResConstMinFinisher(supl) resource constraint Min_Finisher
OptTarg_ (ingr)
;

objf.. MinCost =E= sum ((age,ingr), Data(age,ingr,"Cost")*DIET(ingr,supl));

ResConst(ingr).. sum (supl, DIET(ingr,supl)) =E=1;

ResConstMaxStarter(supl).. sum (ingr, Data(ingr,supl,"MetaE")*DIET(ingr,supl)) =L= ResMax_Starter(supl);

ResConstMinStarter(supl).. sum (ingr, Data(ingr,supl,"MetaE")*DIET(ingr,supl)) =L= ResMin_Starter(supl);

ResConstMaxFinisher(supl).. sum (ingr, Data(ingr,supl,"MetaE")*DIET(ingr,supl)) =L= ResMax_Finisher(supl);

ResConstMinFinisher(supl).. sum (ingr, Data(ingr,supl,"MetaE")*DIET(ingr,supl)) =L= ResMin_Finisher(supl);

OptTarg_MetaE(ingr).. sum (ingr, Data(age,ingr,"MetaE")*DIET(age,ingr)) =L= OptTarg_MetaE;

model poultry_base /objf, ResConst, ResConstMetaERes, OptTarg_MetaE/;
solve poultry_base using LP minimizing MinCost;

report0 ("base", "MinCost") = MinCost.l ;
report0 ("base", "MetaE") = Sum((ingr,supl), Data(ingr,supl,"MetaE")*DIET.l(ingr,supl));

report0("base",ingr) = Sum(age, DIET.l(ingr,supl));

report1("base",supl,"MinCost") =sum ((supl), Data(ingr,supl,"Cost")*DIET.l(ingr,supl));
report1("base",supl,"MetaE") = Sum((ingr),Data(ingr,"MetaE")*DIET.l(ingr,supl));

report1("base",supl,ingr) = DIET.l(ingr,supl);

display report0;
display report1;

I'm having problems with the code. The target is to get the minimum cost, as well as the optimal ingredients mix with concering the restrictions of the supplements.
The optimal ingredient mix should be 1kg of the sum of the ingredients.
Can somebody help? I'm kind of stuck right now

I attached my Excel file where the tab Data and the tab Diet requirements are important (the diet requirements specify the lower and upper restrictions.
Poultrydata.txt
(2.42 KiB) Downloaded 51 times
Post Reply