`I'm new to AMPL and I'm having a hard time understanding why I'm getting a feedback about my variables being already defined.
I keep getting message stating: diet0.mod line 2 offset 16 Xbread is already defined context: var >>> Xbread <<< >= 0; followed by respective variables being also already defined.
This is the code I'm working with:
# Install dependencies
%pip install -q amplpy
# Google Colab & Kaggle integration
from amplpy import AMPL, ampl_notebook
ampl = ampl_notebook(
modules=\["coin"\], # modules to install
license_uuid="default", # license to use
) # instantiate AMPL object and register magics
%%writefile diet0.mod
# Variables
var Xbread >= 0;
var Xmeat >= 0;
var Xpotatoes >= 0;
var Xcabbage >= 0;
var Xmilk >= 0;
var Xgelatin >= 0;
minimize cost:
0.30*Xbread + 1*Xmeat + 0.05*Xpotatoes + 0.08*Xcabbage + 0.23*Xmilk + 0.48*Xgelatin;
# Constraints
subject to A:
1254*Xbread+1457*Xmeat+318*Xpotatoes+46*Xcabbage+309*Xmilk+1725*Xgelatin>=3000;
subject to B:
39*Xbread+73*Xmeat+8*Xpotatoes+4*Xcabbage+16*Xmilk+43*Xgelatin >=70;
subject to C:
418*Xbread+41*Xmeat+42*Xpotatoes+141*Xcabbage+536*Xmilk+0*Xgelatin>=800;
subject to D:
70*Xpotatoes+860*Xcabbage+720*Xmilk>=500;
%%ampl_eval
model diet0.mod;
option solver cbc;
solve;
display Xbread; Xmeat; Xpotatoes; Xcabbage; Xmilk; Xgelatin;```
I have tried resetting the variables but it didn't fix the issue. I didn't find the answer in similar questions here. Any help/hints would be helpful.