error with the mod command: I is already defined

18 views
Skip to first unread message

Anwar Muheidat

unread,
Oct 15, 2024, 5:59:10 PM10/15/24
to AMPL Modeling Language
Hello together,
so basically I got the variable var I and also s.t. I which has to be like that based on the task we got from our prof.

But if I put in the command for my mod, I get following error:

I is already defined

context: s.t. >>> I[ <<< t-1]+q[t]-d[t]=I[t];

For further understanding, I will send you my whole mod:

set T:= 1..4; #Anzahl der Perioden

param d; #Nachfrage in Periode

param I0; #Anfangslagerbestand

param s; #Rüstkostensatz

param h; #Lagerhaltungskostensatz

param M; #Eine hinreichend große Zahl

var q {t in T}>=0;

var x {t in T} binary;

var I {t in T}>=0;

minimize Kosten: sum{t in T} (s*x[t]+h*I[t]);

s.t. I[t-1]+q[t]-d[t]=I[t];

s.t. q[t]<=M*x[t];

s.t. q[t]>=0;

s.t. I[t]>=0;

s.t. x[t] binary;

Also another question: How come that some commands are in purple and some not ?


Thanks in Advance.


Anwar

AMPL Google Group

unread,
Oct 15, 2024, 8:27:26 PM10/15/24
to AMPL Modeling Language


--
Robert Fourer

We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
{#HS:2735516758-129335#}
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/79f5685a-3e2d-47bc-8604-747a721d5408n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages