Hello Sirs;
-- If I have two sets , set of sources and set of destination, and each source has a pair of x and y coordinates, like wise the destination, each has a pair of x and y coordinates. see the attached document which is the mathematical representation of the euclidean distance. how do I computes the distance in ampl given the set of coordinates of the sources and destinations ? Thanks Nasir A. 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. Euclidean distance.docx (18K) Download Attachment |
You need a param for x and y
{#HS:554625591-4464#}
Below is an example: param n:=2; param xa{1..n}; param ya{1..n}; param xb{1..n}; param yb{1..n}; param d{i in 1..n} := sqrt( ((xa[i]-xb[i])^2+(ya[i]-yb[i])^2) ); data; param xa:= 1 1 2 2; param ya := 1 3 2 4; param xb := 1 4 2 5; param yb := 1 6 2 7; -- Paras Tiwari [hidden email]
On Wed, Apr 4, 2018 at 3:50 PM UTC, <[hidden email]> wrote:
--
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. |
thanks, it realy works On Wed, 4 Apr 2018 18:51 AMPL Google Group, <[hidden email]> wrote:
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. |
Good day sirs, How do I define the euclidean distance having two subscripts , I.e. a pair, one from set plants and the second from city, each of plants and city have pairs of coordinates ? Thanks Nasir Abdullahi On Wed, 4 Apr 2018 20:08 Nasiru Abdullahi, <[hidden email]> wrote:
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. |
You can define a two dimensional set for plants and city and define a param over plants and city as follows:
{#HS:554625591-4464#}
set plants dimen 2; set city dimen 2; set distance{plants,city}; However, it's not clear to me how you are calculating the distance. -- Paras Tiwari [hidden email]
On Tue, Apr 10, 2018 at 10:56 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
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. |
On 4/11/18, Nasiru Abdullahi <[hidden email]> wrote:
> Thanks; > This is how I want to calculate the distance..see the attached > mathematical expression. > the two sets has pairs of coordinates, for each "X" and "Y" > > In otherwords, each set "plants" has pairs x and y coordinates, like > wise for each set "city" has pairs x and y coordinates > > how to write a computed parameter of the distance formula using these > sets and how to to write the data for these sets > > Thanks > I appreciates > Nasir A. > > > > On 4/11/18, AMPL Google Group <[hidden email]> wrote: >> -- Please reply above this line -- >> >> >> You can define a two dimensional set for plants and city and define a >> param over plants and city as follows: >> >> set plants dimen 2; >> set city dimen 2; >> set distance{plants,city}; >> >> However, it's not clear to me how you are calculating the distance. >> -- >> Paras Tiwari >> [hidden email] >> >> >> >> >> >> >> >> >> >>> On Tue, Apr 10, 2018 at 10:56 PM UTC, Zeyad Kassem' Via Ampl Modeling >>> Language <[hidden email]> wrote: >>> >>> Good day sirs, >>> How do I define the euclidean distance having two subscripts , I.e. a >>> pair, one from set plants and the second from city, each of plants and >>> city have pairs of coordinates ? >>> Thanks >>> Nasir Abdullahi >>> >>> >>>> On Wed, Apr 4, 2018 at 10:35 PM UTC, Zeyad Kassem' Via Ampl Modeling >>>> Language <[hidden email]> wrote: >>>> >>>> thanks, it realy works >>>> >>>> >>>>> On Wed, Apr 4, 2018 at 5:50 PM UTC, AMPL Google Group >>>>> <[hidden email]> wrote: >>>>> >>>>> You need a param for x and y >>>>> Below is an example: >>>>> param n:=2; >>>>> >>>>> param xa{1..n}; >>>>> param ya{1..n}; >>>>> param xb{1..n}; >>>>> param yb{1..n}; >>>>> param d{i in 1..n} := sqrt( ((xa[i]-xb[i])^2+(ya[i]-yb[i])^2) ); >>>>> >>>>> data; >>>>> >>>>> param xa:= 1 1 2 2; >>>>> param ya := 1 3 2 4; >>>>> param xb := 1 4 2 5; >>>>> param yb := 1 6 2 7; >>>>> >>>>> >>>>> -- >>>>> Paras Tiwari >>>>> [hidden email] >>>>> >>>>> >>>>> >>>>>> On Wed, Apr 4, 2018 at 3:50 PM UTC, Zeyad Kassem' Via Ampl Modeling >>>>>> Language <[hidden email]> wrote: >>>>>> >>>>>> Hello Sirs; >>>>>> If I have two sets , set of sources and set of destination, and each >>>>>> source has a pair of x and y coordinates, like wise the destination, >>>>>> each has a pair of x and y coordinates. see the attached document >>>>>> which is the mathematical representation of the euclidean distance. >>>>>> how do I computes the distance in ampl given the set of coordinates >>>>>> of the sources and destinations ? >>>>>> Thanks Nasir A. -- >>>>>> 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] [1]. >>>>>> To post to this group, send email to [hidden email] [2]. >>>>>> Visit this group at https://groups.google.com/group/ampl [3]. >>>>>> For more options, visit https://groups.google.com/d/optout [4]. >>>>>> >>>>>> >>>>>> Links: >>>>>> ------ >>>>>> [1] mailto:[hidden email] >>>>>> [2] mailto:[hidden email] >>>>>> [3] https://groups.google.com/group/ampl >>>>>> [4] https://groups.google.com/d/optout >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>> >>> >> >> -- >> 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. >> > 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. Euclidean distance.docx (19K) Download Attachment |
One possibility would be to define "set A; set B;" (sets of origins and destinations) and then "param xA {A}; param yA {A};" (x and y coordinates of origins) and "param xB {B}; param yB {B};" (x and y coordinates of destinations. Then you could write the formula for "param dist {a in A, b in B} = . . .". The data for A, xA, yA can be combined in a single data statement, and similarly for B, xB, yB.
{#HS:554625591-4464#}
Thanks Paras -- Paras Tiwari [hidden email]
On Wed, Apr 11, 2018 at 12:42 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
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. |
Free forum by Nabble | Edit this page |