[AMPL 2827] Backward loop in AMPL

View: New views
3 Messages — Rating Filter:   Alert me  

[AMPL 2827] Backward loop in AMPL

by janachr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello AMPL professionals,

i try to program a backward loop in AMPL... Is it possible?

For example,

k in A runs from 1 to 10 and (i,j) in B too. (i=1..10, j=1..10)

param T {k in A} = if k=entr then 0 else (max ({(i,j) in B} if j=k
then (time[i,j]+T[i]))) ;

How can I let run k, i and j in this expression backwards, from 10 to
1 ??

I am waiting eagerly for the answer.

jana





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---


[AMPL 2831] Re: Backward loop in AMPL

by Paul A. Rubin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


You can loop backward if you define the indexing set as ordered in
reverse.  Short example (sorry, don't have time for anything more
complex):

param n := 5;
set S ordered := 1..n;  # index set, usual order
set T ordered by reversed S := S;  # same set, reverse order
for {t in T} display t;  # 5, 4, 3, 2, 1

/Paul

On Sep 16, 5:31 pm, jana...@... wrote:

> Hello AMPL professionals,
>
> i try to program a backward loop in AMPL... Is it possible?
>
> For example,
>
> k in A runs from 1 to 10 and (i,j) in B too. (i=1..10, j=1..10)
>
> param T {k in A} = if k=entr then 0 else (max ({(i,j) in B} if j=k
> then (time[i,j]+T[i]))) ;
>
> How can I let run k, i and j in this expression backwards, from 10 to
> 1 ??
>
> I am waiting eagerly for the answer.
>
> jana
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---


[AMPL 2835] Re: Backward loop in AMPL

by janachr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thank you very much!!

On 17 Sep., 16:12, Paul <ru...@...> wrote:

> You can loop backward if you define the indexing set as ordered in
> reverse.  Short example (sorry, don't have time for anything more
> complex):
>
> param n := 5;
> set S ordered := 1..n;  # index set, usual order
> set T ordered by reversed S := S;  # same set, reverse order
> for {t in T} display t;  # 5, 4, 3, 2, 1
>
> /Paul
>
> On Sep 16, 5:31 pm, jana...@... wrote:
>
> > Hello AMPL professionals,
>
> > i try to program a backward loop in AMPL... Is it possible?
>
> > For example,
>
> > k in A runs from 1 to 10 and (i,j) in B too. (i=1..10, j=1..10)
>
> > param T {k in A} = if k=entr then 0 else (max ({(i,j) in B} if j=k
> > then (time[i,j]+T[i]))) ;
>
> > How can I let run k, i and j in this expression backwards, from 10 to
> > 1 ??
>
> > I am waiting eagerly for the answer.
>
> > jana
>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to ampl@...
To unsubscribe from this group, send email to ampl+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---