[AMPL 18349] How to make summation with condition

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[AMPL 18349] How to make summation with condition

Anas
I am very beginner in the AMPl

How to write the summation in the file 

I do not know how to put a condition in the summation and exclude the variable where j1 = j2 
what I can do is sum { j1 in J1, j2 in J2} Theta [ j1, j2] 
but this command will now exclude the summation when j1 = j2 


Is there any brief introduction for ampl mathematic expression,

Thanks a lot 
Anas  

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

question.PNG (20K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 18350] How to make summation with condition

AMPL mailing list
sum {j1 in J1, j2 in J2: j1 <> j2} Theta [j1,j2]

This is covered in Section 5.5 of the AMPL book, https://ampl.com/BOOK/CHAPTERS/08-sets1.pdf#page=7. In particular the use of : conditions in indexing expressions is described beginning at the bottom of page 80.

--
Robert Fourer
[hidden email]
{#HS:796794735-38072#}
On Fri, Mar 8, 2019 at 11:07 AM UTC, Ampl Modeling Language <[hidden email]> wrote:
I am very beginner in the AMPl

How to write the summation in the file

I do not know how to put a condition in the summation and exclude the variable where j1 = j2
what I can do is sum { j1 in J1, j2 in J2} Theta [ j1, j2]
but this command will now exclude the summation when j1 = j2


Is there any brief introduction for ampl mathematic expression,

Thanks a lot
Anas



--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.