[AMPL 16050] syntax error

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

[AMPL 16050] syntax error

sahebeh.azar
Hi all,

How can I solve this problem in a for loop?

The code that I have is:
                          
for {j in A}{
for {i in B}{
                   ...
                   ...
                   ...
                  let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]};
                   ...}}
Because I defined A before, I cannot define it again. So, what should I do?
I also changed the name of j into another name but I still have this problem.

WBR

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16054] syntax error

AMPL mailing list
You don't need to define 'j' again in the let statement. You can do min_poll[j] within the loop and j refers to the member of A.

--
Paras Tiwari
[hidden email]
{#HS:552219047-4216#}
On Sat, Mar 31, 2018 at 3:29 PM UTC, <[hidden email]> wrote:
Hi all,

How can I solve this problem in a for loop?

The code that I have is:

for {j in A}{
for {i in B}{
...
...
...
let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]};
...}}
Because I defined A before, I cannot define it again. So, what should I do?
I also changed the name of j into another name but I still have this problem.

WBR

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16061] syntax error

sahebeh.azar
I know but I have to use :  . I need to define j in A : k in min_poll[j]!!

On Sunday, April 1, 2018 at 9:27:09 PM UTC+4:30, AMPL Google Group wrote:
You don't need to define 'j' again in the let statement. You can do min_poll[j] within the loop and j refers to the member of A.

--
Paras Tiwari
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="DEg3ZcdSAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...
{#HS:552219047-4216#}
On Sat, Mar 31, 2018 at 3:29 PM UTC, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="DEg3ZcdSAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
Hi all,

How can I solve this problem in a for loop?

The code that I have is:

for {j in A}{
for {i in B}{
...
...
...
let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]};
...}}
Because I defined A before, I cannot define it again. So, what should I do?
I also changed the name of j into another name but I still have this problem.

WBR

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="DEg3ZcdSAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ampl+uns...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="DEg3ZcdSAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@....
Visit this group at <a href="https://groups.google.com/group/ampl" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/ampl&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/ampl&#39;;return true;">https://groups.google.com/group/ampl.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16070] syntax error

AMPL mailing list
You shouldn't get any error message when you use the new indexing variable name. What error are you getting when you use the new indexing variable name instead of 'j'? The error might be other problem not related to the indexing variable.

Thanks,
Paras

--
Paras Tiwari
[hidden email]
{#HS:552219047-4216#}
On Sun, Apr 1, 2018 at 6:53 PM UTC, <[hidden email]> wrote:
I know but I have to use : . I need to define j in A : k in min_poll[j]!!



On Sun, Apr 1, 2018 at 4:56 PM UTC, AMPL Google Group <[hidden email]> wrote:
You don't need to define 'j' again in the let statement. You can do min_poll[j] within the loop and j refers to the member of A.

--
Paras Tiwari
[hidden email]


On Sat, Mar 31, 2018 at 3:29 PM UTC, <[hidden email]> wrote:
Hi all,

How can I solve this problem in a for loop?

The code that I have is:

for {j in A}{
for {i in B}{
...
...
...
let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]};
...}}
Because I defined A before, I cannot define it again. So, what should I do?
I also changed the name of j into another name but I still have this problem.

WBR

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16072] syntax error

sahebeh.azar
I want to achieve this answer like following example:
I have set min_poll and I need to get set min_CH.
set min_poll {j in A}
set min_CH {k in B}

set min_poll[1] := 21;
set min_poll[16] := 22;

set min_CH[21] := 1;
set min_CH[22] := 16;

I have to use this code in a for loop. The code that I have:

for {j in A}{
for {i in B}{   
let {x in candid[j]} dis_thr_poll[j,x]:=sqrt((X_CH[j]-X_CP[x])^2+(Y_CH[j]-Y_CP[x])^2);
let dist[j]:= min {x in candid[j]} dis_thr_poll[j,x];
 let min_poll[j] := {min {x in candid[j]: dis_thr_poll[j,x] = dist[j]} x};
then let  DD:= {{min_poll[j]} union {DD}};
 then let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]}; --------------------> How can I solve this problem? 

}
}

On Monday, April 2, 2018 at 11:17:57 PM UTC+4:30, AMPL Google Group wrote:
You shouldn't get any error message when you use the new indexing variable name. What error are you getting when you use the new indexing variable name instead of 'j'? The error might be other problem not related to the indexing variable.

Thanks,
Paras

--
Paras Tiwari
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="avslzWenAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...
{#HS:552219047-4216#}
On Sun, Apr 1, 2018 at 6:53 PM UTC, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="avslzWenAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
I know but I have to use : . I need to define j in A : k in min_poll[j]!!



On Sun, Apr 1, 2018 at 4:56 PM UTC, AMPL Google Group <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="avslzWenAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
You don't need to define 'j' again in the let statement. You can do min_poll[j] within the loop and j refers to the member of A.

--
Paras Tiwari
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="avslzWenAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...


On Sat, Mar 31, 2018 at 3:29 PM UTC, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="avslzWenAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
Hi all,

How can I solve this problem in a for loop?

The code that I have is:

for {j in A}{
for {i in B}{
...
...
...
let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]};
...}}
Because I defined A before, I cannot define it again. So, what should I do?
I also changed the name of j into another name but I still have this problem.

WBR

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="avslzWenAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ampl+uns...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="avslzWenAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@....
Visit this group at <a href="https://groups.google.com/group/ampl" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/ampl&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/ampl&#39;;return true;">https://groups.google.com/group/ampl.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16075] syntax error

AMPL mailing list
You can write following statement outside the loop:

let{k in B,j in A,t in min_poll[j]: t=k} min_CH[k] := {j} ;

--
Paras Tiwari
[hidden email]
{#HS:552219047-4216#}
On Mon, Apr 2, 2018 at 8:39 PM UTC, <[hidden email]> wrote:
I want to achieve this answer like following example:
I have set min_poll and I need to get set min_CH.
set min_poll {j in A}
set min_CH {k in B}

set min_poll[1] := 21;
set min_poll[16] := 22;

set min_CH[21] := 1;
set min_CH[22] := 16;

I have to use this code in a for loop. The code that I have:

for {j in A}{
for {i in B}{
let {x in candid[j]} dis_thr_poll[j,x]:=sqrt((X_CH[j]-X_CP[x])^2+(Y_CH[j]-Y_CP[x])^2);
let dist[j]:= min {x in candid[j]} dis_thr_poll[j,x];
let min_poll[j] := {min {x in candid[j]: dis_thr_poll[j,x] = dist[j]} x};
then let DD:= {{min_poll[j]} union {DD}};
then let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]}; --------------------> How can I solve this problem?

}
}



On Mon, Apr 2, 2018 at 6:47 PM UTC, AMPL Google Group <[hidden email]> wrote:
You shouldn't get any error message when you use the new indexing variable name. What error are you getting when you use the new indexing variable name instead of 'j'? The error might be other problem not related to the indexing variable.

Thanks,
Paras

--
Paras Tiwari
[hidden email]


On Sun, Apr 1, 2018 at 6:53 PM UTC, <[hidden email]> wrote:
I know but I have to use : . I need to define j in A : k in min_poll[j]!!



On Sun, Apr 1, 2018 at 4:56 PM UTC, AMPL Google Group <[hidden email]> wrote:
You don't need to define 'j' again in the let statement. You can do min_poll[j] within the loop and j refers to the member of A.

--
Paras Tiwari
[hidden email]


On Sat, Mar 31, 2018 at 3:29 PM UTC, <[hidden email]> wrote:
Hi all,

How can I solve this problem in a for loop?

The code that I have is:

for {j in A}{
for {i in B}{
...
...
...
let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]};
...}}
Because I defined A before, I cannot define it again. So, what should I do?
I also changed the name of j into another name but I still have this problem.

WBR

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16077] syntax error

sahebeh.azar
You are right but is there any way that I use inside the loop? I need it exactly inside the for loop!

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16077] syntax error

sahebeh.azar
In reply to this post by AMPL mailing list
Thank yooooou
It works in the for loop

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16077] syntax error

sahebeh.azar
In reply to this post by AMPL mailing list
I am sorry to bother you, but that code does not work when I change some character!
Let me explain what I want:
I have set min_poll and I want to get set min_CH as below:
set min_poll {j in A};
set min_CH {k in DD};

set min_poll[5] := 11;
set min_poll[8] := 9;
set min_poll[27] := 16;
set min_poll[41] := 5;
set min_poll[42] := 11;
set min_poll[44] := 16;

set min_CH[11] := 5,42;
set min_CH[9] := 8;
set min_CH[16] := 27,44;
set min_CH[5] := 41;

I would like to achieve this through a for loop:
for {j in A}{
for {i in B}{
let {x in candid[j]} dis_thr_poll[j,x]:=sqrt((X_CH[j]-X_CP[x])^2+(Y_CH[j]-Y_CP[x])^2);
let dist[j]:= min {x in candid[j]} dis_thr_poll[j,x];
let min_poll[j] := {min {x in candid[j]: dis_thr_poll[j,x] = dist[j]} x};
then let DD:= {{min_poll[j]} union {DD}};
then let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]}; --------------------> How can I solve this problem?
 
On Tuesday, April 3, 2018 at 4:11:57 AM UTC+4:30, AMPL Google Group wrote:
You can write following statement outside the loop:

let{k in B,j in A,t in min_poll[j]: t=k} min_CH[k] := {j} ;

--
Paras Tiwari
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lsHf5XK3AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...
{#HS:552219047-4216#}
On Mon, Apr 2, 2018 at 8:39 PM UTC, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lsHf5XK3AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
I want to achieve this answer like following example:
I have set min_poll and I need to get set min_CH.
set min_poll {j in A}
set min_CH {k in B}

set min_poll[1] := 21;
set min_poll[16] := 22;

set min_CH[21] := 1;
set min_CH[22] := 16;

I have to use this code in a for loop. The code that I have:

for {j in A}{
for {i in B}{
let {x in candid[j]} dis_thr_poll[j,x]:=sqrt((X_CH[j]-X_CP[x])^2+(Y_CH[j]-Y_CP[x])^2);
let dist[j]:= min {x in candid[j]} dis_thr_poll[j,x];
let min_poll[j] := {min {x in candid[j]: dis_thr_poll[j,x] = dist[j]} x};
then let DD:= {{min_poll[j]} union {DD}};
then let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]}; --------------------> How can I solve this problem?

}
}



On Mon, Apr 2, 2018 at 6:47 PM UTC, AMPL Google Group <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lsHf5XK3AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
You shouldn't get any error message when you use the new indexing variable name. What error are you getting when you use the new indexing variable name instead of 'j'? The error might be other problem not related to the indexing variable.

Thanks,
Paras

--
Paras Tiwari
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lsHf5XK3AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...


On Sun, Apr 1, 2018 at 6:53 PM UTC, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lsHf5XK3AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
I know but I have to use : . I need to define j in A : k in min_poll[j]!!



On Sun, Apr 1, 2018 at 4:56 PM UTC, AMPL Google Group <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lsHf5XK3AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
You don't need to define 'j' again in the let statement. You can do min_poll[j] within the loop and j refers to the member of A.

--
Paras Tiwari
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lsHf5XK3AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...


On Sat, Mar 31, 2018 at 3:29 PM UTC, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="lsHf5XK3AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
Hi all,

How can I solve this problem in a for loop?

The code that I have is:

for {j in A}{
for {i in B}{
...
...
...
let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]};
...}}
Because I defined A before, I cannot define it again. So, what should I do?
I also changed the name of j into another name but I still have this problem.

WBR

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="lsHf5XK3AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ampl+uns...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="lsHf5XK3AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@....
Visit this group at <a href="https://groups.google.com/group/ampl" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/ampl&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/ampl&#39;;return true;">https://groups.google.com/group/ampl.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16080] syntax error

AMPL mailing list
In reply to this post by sahebeh.azar
Inside the loop "for {j in A} { . . . }" the value of j is fixed to be a particular member of A, and you cannot change the value of j. Thus inside the loop you cannot use j as the running index in another indexing expression like {j in A : k in min_poll[j]}. You could use a different index, as in this example:

let {k in DD} min_CH[k] := {jj in A : k in min_poll[jj]};

Or, you could move the whole let statement outside the "for {j in A}" loop. However I cannot tell you whether you should use one of these solutions or the other -- or even another one entirely -- because I am not familiar with your application. It appears to me that you need to think harder about what you are trying to do with this statement, and you need to try your loops on some test data to see if min_CH[k] is computed as you intend.

--
Robert Fourer
[hidden email]
{#HS:552219047-4216#}
On Tue, Apr 3, 2018 at 12:00 PM UTC, <[hidden email]> wrote:
Thank yooooou
It works in the for loop

--
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 Tue, Apr 3, 2018 at 12:00 PM UTC, <[hidden email]> wrote:
I am sorry to bother you, but that code does not work when I change some character!
Let me explain what I want:
I have set min_poll and I want to get set min_CH as below:
set min_poll {j in A};
set min_CH {k in DD};

set min_poll[5] := 11;
set min_poll[8] := 9;
set min_poll[27] := 16;
set min_poll[41] := 5;
set min_poll[42] := 11;
set min_poll[44] := 16;

set min_CH[11] := 5,42;
set min_CH[9] := 8;
set min_CH[16] := 27,44;
set min_CH[5] := 41;

I would like to achieve this through a for loop:
for {j in A}{
for {i in B}{
let {x in candid[j]} dis_thr_poll[j,x]:=sqrt((X_CH[j]-X_CP[x])^2+(Y_CH[j]-Y_CP[x])^2);
let dist[j]:= min {x in candid[j]} dis_thr_poll[j,x];
let min_poll[j] := {min {x in candid[j]: dis_thr_poll[j,x] = dist[j]} x};
then let DD:= {{min_poll[j]} union {DD}};
then let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]}; --------------------> How can I solve this problem?



On Tue, Apr 3, 2018 at 12:00 PM UTC, <[hidden email]> wrote:
You are right but is there any way that I use inside the loop? I need it exactly inside the for loop!

--
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 Mon, Apr 2, 2018 at 11:41 PM UTC, AMPL Google Group <[hidden email]> wrote:
You can write following statement outside the loop:

let{k in B,j in A,t in min_poll[j]: t=k} min_CH[k] := {j} ;

--
Paras Tiwari
[hidden email]


On Mon, Apr 2, 2018 at 8:39 PM UTC, <[hidden email]> wrote:
I want to achieve this answer like following example:
I have set min_poll and I need to get set min_CH.
set min_poll {j in A}
set min_CH {k in B}

set min_poll[1] := 21;
set min_poll[16] := 22;

set min_CH[21] := 1;
set min_CH[22] := 16;

I have to use this code in a for loop. The code that I have:

for {j in A}{
for {i in B}{
let {x in candid[j]} dis_thr_poll[j,x]:=sqrt((X_CH[j]-X_CP[x])^2+(Y_CH[j]-Y_CP[x])^2);
let dist[j]:= min {x in candid[j]} dis_thr_poll[j,x];
let min_poll[j] := {min {x in candid[j]: dis_thr_poll[j,x] = dist[j]} x};
then let DD:= {{min_poll[j]} union {DD}};
then let {k in DD} min_CH[k]:= {j in A : k in min_poll[j]}; --------------------> How can I solve this problem?

}
}



--
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.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16082] syntax error

sahebeh.azar
I really thank you for your attention.

--
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.