I am new to gams (so probably a stupid question) and trying to set up a model with the main error being “set is already under control”. I can easily create the model in excel, but can’t here. Here is the following code that I am trying to use to solve whether or not to keep or cull a cow to reach a specific threshold. All the values need to be summed over all cows i. Thanks for all your help!

Set

i cows / cowone, cowtwo, cowthree / ;

Parameters

a(i) net present value of cow i in cases

/ cowone 500

cowtwo 400

cowthree 450 /

b(i) yield of cow i in cases

/ cowone 10000

cowtwo 8000

cowthree 9000 /

c(i) SCC of cow i in cases

/ cowone 5900000

cowtwo 3500000

cowthree 2500000 /

d(i) Cull vlaue of cow i in cases

/ cowone 100

cowtwo 90

cowthree 80 /;

Variables

vc(i) Value of cow i if culled in all cases

vr(i) Value of cow i if retained in all cases

*this is an attempt at a binary constraint

z total net present value ;

Equations

NPV define objective function

SCC(i) SCC for all cows i

Yield(i) milk for all cows i

Mix(i) mix in bulk tank;

NPV … z =e= sum(i, (a(i)*vr(i))+ (d(i)*vc(i)));

SCC(i) … sum(i, vr(i)*c(i)) =E= “SCC”;

Yield(i) … sum(i, vr(i)*b(i)) =E= “Yield”;

Mix(i) … “SCC”/“Yield” =l= 400;

Value … sum(i, vc(i)+vr(i)) =E= 1;

Model dairy /all/ ;

Solve dairy using nlp maximizing z ;

Display y.l, y.m ;

–

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.

To post to this group, send email to gamsworld@googlegroups.com.

Visit this group at http://groups.google.com/group/gamsworld.

For more options, visit https://groups.google.com/d/optout.