Constraint with a set defined in a set

10 views
Skip to first unread message

Erry Olden

unread,
Mar 16, 2018, 9:25:40 AM3/16/18
to AMPL Modeling Language
Hi,

I cannot write correctly the following expression:

s.t. Max_Raw_Inv {t in TIME: t>lt[r]}:

      sum{r in RAWMAT} lotSize[r]*Order[r,t-lt[r]] <= invRawCap;


the problem is that the "t in time" must start after a value define by "lt[r]" and lt is defined in RAWMAT.

If I write the expression as above it doesn't work, because i get the error that r is not defined, if I add "r in RAWMAT" before the "t in TIME" it doesn't work anyway.


Can you help me finding the correct formulation?


Thank you.


Luca

AMPL Google Group

unread,
Mar 16, 2018, 2:05:43 PM3/16/18
to am...@googlegroups.com
You can move the condition inside the sum as follows:

s.t. Max_Raw_Inv {t in TIME}:
sum{r in RAWMAT: t>lt[r]} lotSize[r]*Order[r,t-lt[r]] <= invRawCap;




--
Paras Tiwari
am...@googlegroups.com
{#HS:542652831-2873#}
--
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 post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



Reply all
Reply to author
Forward
0 new messages