HELP!Questions about linear planning
Posted: Sun Apr 02, 2023 4:40 pm
HELP! I have two questions.
This is a question about daily nutrient.
1.When you can only choose to eat one item a day, what do you need to eat to satisfy your nutrition?
2.When you have to eat three different foods every day, how do you choose to meet your nutritional needs?
*Saturated fat no more than 22
I tried for a long time and still can't solve it.
I wonder what equation needs to be added to the equation to solve the problem of choosing only one item and choosing three different items.
$CALL GDXXRW.EXE D:\GAMS\test.xlsx @D:\GAMS\homework.txt output=D:\GAMS\homework.gdx
$GDXIN D:\GAMS\homework.gdx
sets
i(*)
j(*)
;
$LOAD i j
display i,j;
parameters
C(i)
N(i,j)
L(j)
;
$LOAD C N L
display C,N,L;
positive variables
x(i)
w
;
free variable
z
;
equations
obj
Nutrition1(j)
Nutrition2
Nutrition3
;
obj.. z =e= sum(i,C(i)*x(i));
Nutrition1(j)$(ord(j)>=1 and ord(j)<=3).. sum(i,N(i,j)*x(i)) =g= L(j)$(ord(j)>=1 and ord(j)<=3) ;
Nutrition2.. sum(i,N(i,'4')*x(i)) =l= L('4');
Nutrition3.. w +sum(i,n(i,'5')*x(i)) =g= L('5');
*option limrow = 1000000;
model Ne /all/
solve Ne using lp minimizing z;
This is a question about daily nutrient.
1.When you can only choose to eat one item a day, what do you need to eat to satisfy your nutrition?
2.When you have to eat three different foods every day, how do you choose to meet your nutritional needs?
*Saturated fat no more than 22
I tried for a long time and still can't solve it.
I wonder what equation needs to be added to the equation to solve the problem of choosing only one item and choosing three different items.
$CALL GDXXRW.EXE D:\GAMS\test.xlsx @D:\GAMS\homework.txt output=D:\GAMS\homework.gdx
$GDXIN D:\GAMS\homework.gdx
sets
i(*)
j(*)
;
$LOAD i j
display i,j;
parameters
C(i)
N(i,j)
L(j)
;
$LOAD C N L
display C,N,L;
positive variables
x(i)
w
;
free variable
z
;
equations
obj
Nutrition1(j)
Nutrition2
Nutrition3
;
obj.. z =e= sum(i,C(i)*x(i));
Nutrition1(j)$(ord(j)>=1 and ord(j)<=3).. sum(i,N(i,j)*x(i)) =g= L(j)$(ord(j)>=1 and ord(j)<=3) ;
Nutrition2.. sum(i,N(i,'4')*x(i)) =l= L('4');
Nutrition3.. w +sum(i,n(i,'5')*x(i)) =g= L('5');
*option limrow = 1000000;
model Ne /all/
solve Ne using lp minimizing z;