[AMPL 16115] Index within Index

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

[AMPL 16115] Index within Index

Zeyad Kassem
Hi, 

I am solving network flow problem. So, you have from bus and to bus and branch number in the below set. 

param: BRANCH: branch_fbus branch_tbus branch_x branch_rateA branch_rateC


You also have the below parameters which will be defined in terms of branch as below. 

param branch_x{bust,bust}<=0; 
param branch_rateA{bust,bust}>=0;
param branch_rateC{BRANCH}>=0; 
param branch_cost{BRANCH}>=0; 
param branch_curr{BRANCH}>=0; 
param branch_max{BRANCH}>=0; 

The problem is that we have variables that will be defined as an index within an index, as it will access the "from bus" from the branch index as per below. 

subject to constraints{k in BRANCH}:
p_g[branch_fbus[k]]-bus_Pdn[branch_fbus[k]]=sum{n in branch_fbus, j in branch_tbus: branch_fbus[n]== branch_fbus[k]} branch_p_flow[n,j]- sum{j in branch_fbus, n in branch_tbus: branch_tbus[n]== branch_fbus[k]} branch_p_flow[j,n];

But this gives me a syntax error. 

I have done the below to be able to do it 

set BRANCH;
set branch_fbus{BRANCH};

set branch_tbus{BRANCH};

param l in BRANCH; 
set bust =  bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];

var p_g{bust}; # Generated power


Any Help !!! Thanks a lot !!! 

--
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 16119] Index within Index

AMPL mailing list
You have defined p_g over bust, but you are trying to access it over branch_fbus[k] in your constraint. You can't access {k in BRANCH} p_g[branch_fbus[k]] when you define var p_g{bust}. Are you trying to write a balance constraint? I would recommend you to refer to https://ampl.com/BOOK/CHAPTERS/18-network.pdf (page 322) to understand the balance constraint.

Thanks,
Paras

--
Paras Tiwari
[hidden email]
{#HS:556992796-4729#}
On Sun, Apr 8, 2018 at 1:55 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Hi,

I am solving network flow problem. So, you have from bus and to bus and branch number in the below set.

param: BRANCH: branch_fbus branch_tbus branch_x branch_rateA branch_rateC


You also have the below parameters which will be defined in terms of branch as below.

param branch_x{bust,bust}<=0;
param branch_rateA{bust,bust}>=0;
param branch_rateC{BRANCH}>=0;
param branch_cost{BRANCH}>=0;
param branch_curr{BRANCH}>=0;
param branch_max{BRANCH}>=0;

The problem is that we have variables that will be defined as an index within an index, as it will access the "from bus" from the branch index as per below.

subject to constraints{k in BRANCH}:
p_g[branch_fbus[k]]-bus_Pdn[branch_fbus[k]]=sum{n in branch_fbus, j in branch_tbus: branch_fbus[n]== branch_fbus[k]} branch_p_flow[n,j]- sum{j in branch_fbus, n in branch_tbus: branch_tbus[n]== branch_fbus[k]} branch_p_flow[j,n];

But this gives me a syntax error.

I have done the below to be able to do it

set BRANCH;
set branch_fbus{BRANCH};

set branch_tbus{BRANCH};

param l in BRANCH;
set bust = bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];

var p_g{bust}; # Generated power


Any Help !!! Thanks a lot !!!

--
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 16120] Index within Index

Zeyad Kassem
Yes, I have defined p_g over bust but please note that I have written the below also. I guess this should make it work right ? 

set BRANCH;
set branch_fbus{BRANCH};

set branch_tbus{BRANCH};

param l in BRANCH;
set bust = bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];



On Sunday, April 8, 2018 at 11:37:49 PM UTC+2, AMPL Google Group wrote:
You have defined p_g over bust, but you are trying to access it over branch_fbus[k] in your constraint. You can't access {k in BRANCH} p_g[branch_fbus[k]] when you define var p_g{bust}. Are you trying to write a balance constraint? I would recommend you to refer to <a href="https://ampl.com/BOOK/CHAPTERS/18-network.pdf" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fampl.com%2FBOOK%2FCHAPTERS%2F18-network.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEGjz1qgKQUPsIJQEVe_sjSbS-t8w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fampl.com%2FBOOK%2FCHAPTERS%2F18-network.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEGjz1qgKQUPsIJQEVe_sjSbS-t8w&#39;;return true;">https://ampl.com/BOOK/CHAPTERS/18-network.pdf (page 322) to understand the balance constraint.

Thanks,
Paras

--
Paras Tiwari
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="dxRepPYHBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...
{#HS:556992796-4729#}
On Sun, Apr 8, 2018 at 1:55 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="dxRepPYHBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
Hi,

I am solving network flow problem. So, you have from bus and to bus and branch number in the below set.

param: BRANCH: branch_fbus branch_tbus branch_x branch_rateA branch_rateC


You also have the below parameters which will be defined in terms of branch as below.

param branch_x{bust,bust}<=0;
param branch_rateA{bust,bust}>=0;
param branch_rateC{BRANCH}>=0;
param branch_cost{BRANCH}>=0;
param branch_curr{BRANCH}>=0;
param branch_max{BRANCH}>=0;

The problem is that we have variables that will be defined as an index within an index, as it will access the "from bus" from the branch index as per below.

subject to constraints{k in BRANCH}:
p_g[branch_fbus[k]]-bus_Pdn[branch_fbus[k]]=sum{n in branch_fbus, j in branch_tbus: branch_fbus[n]== branch_fbus[k]} branch_p_flow[n,j]- sum{j in branch_fbus, n in branch_tbus: branch_tbus[n]== branch_fbus[k]} branch_p_flow[j,n];

But this gives me a syntax error.

I have done the below to be able to do it

set BRANCH;
set branch_fbus{BRANCH};

set branch_tbus{BRANCH};

param l in BRANCH;
set bust = bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];

var p_g{bust}; # Generated power


Any Help !!! Thanks a lot !!!

--
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="dxRepPYHBwAJ" 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="dxRepPYHBwAJ" 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 16122] Index within Index

AMPL mailing list
You have defined over bust, but you are accessing over branch_fbus. If you look at your statement p_g[branch_fbus[k]] p_g is being indexed over branch_fbus. So, you are defining over one set/param, but accessing over another. You need to be consistent in defining and accessing the variable.

Thanks,
Paras

--
Paras Tiwari
[hidden email]
{#HS:556992796-4729#}
On Mon, Apr 9, 2018 at 1:47 AM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Yes, I have defined p_g over bust but please note that I have written the
below also. I guess this should make it work right ?

*set BRANCH;*



On Sun, Apr 8, 2018 at 9:37 PM UTC, AMPL Google Group <[hidden email]> wrote:
You have defined p_g over bust, but you are trying to access it over branch_fbus[k] in your constraint. You can't access {k in BRANCH} p_g[branch_fbus[k]] when you define var p_g{bust}. Are you trying to write a balance constraint? I would recommend you to refer to https://ampl.com/BOOK/CHAPTERS/18-network.pdf (page 322) to understand the balance constraint.

Thanks,
Paras

--
Paras Tiwari
[hidden email]


On Sun, Apr 8, 2018 at 1:55 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Hi,

I am solving network flow problem. So, you have from bus and to bus and branch number in the below set.

param: BRANCH: branch_fbus branch_tbus branch_x branch_rateA branch_rateC


You also have the below parameters which will be defined in terms of branch as below.

param branch_x{bust,bust}<=0;
param branch_rateA{bust,bust}>=0;
param branch_rateC{BRANCH}>=0;
param branch_cost{BRANCH}>=0;
param branch_curr{BRANCH}>=0;
param branch_max{BRANCH}>=0;

The problem is that we have variables that will be defined as an index within an index, as it will access the "from bus" from the branch index as per below.

subject to constraints{k in BRANCH}:
p_g[branch_fbus[k]]-bus_Pdn[branch_fbus[k]]=sum{n in branch_fbus, j in branch_tbus: branch_fbus[n]== branch_fbus[k]} branch_p_flow[n,j]- sum{j in branch_fbus, n in branch_tbus: branch_tbus[n]== branch_fbus[k]} branch_p_flow[j,n];

But this gives me a syntax error.

I have done the below to be able to do it

set BRANCH;
set branch_fbus{BRANCH};

set branch_tbus{BRANCH};

param l in BRANCH;
set bust = bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];

var p_g{bust}; # Generated power


Any Help !!! Thanks a lot !!!

--
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 16133] Index within Index

Zeyad Kassem
Dear Paras, 

Thank you for the clarification. However, I have done the below union. Does this make it the same index for bust and  branch_fbus. So, I can index freely over bust &  branch_fbus &  branch_fbus ? 

param l in BRANCH; 
set bust =  bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];

Anyways I have another Syntax error when I write the below. 

param k{BRANCH};
param branch_x{branch_fbus[k],branch_tbus[k]}<=0;


I want to access the branch_x through  branch_fbus &  branch_tbus.  branch_fbus &  branch_tbus are indexed over BRANCH for the below set. 

I don't know why I get the syntax error. 

param: BRANCH: branch_fbus branch_tbus branch_x branch_rateA branch_rateC

Thanks a lot for your support !! 

Best Regards, 

Zeyad Kassem


On Mon, Apr 9, 2018 at 7:56 PM, AMPL Google Group <[hidden email]> wrote:
You have defined over bust, but you are accessing over branch_fbus. If you look at your statement p_g[branch_fbus[k]] p_g is being indexed over branch_fbus. So, you are defining over one set/param, but accessing over another. You need to be consistent in defining and accessing the variable.

Thanks,
Paras

--
Paras Tiwari
[hidden email]
{#HS:556992796-4729#}
On Mon, Apr 9, 2018 at 1:47 AM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Yes, I have defined p_g over bust but please note that I have written the
below also. I guess this should make it work right ?

*set BRANCH;*



On Sun, Apr 8, 2018 at 9:37 PM UTC, AMPL Google Group <[hidden email]> wrote:
You have defined p_g over bust, but you are trying to access it over branch_fbus[k] in your constraint. You can't access {k in BRANCH} p_g[branch_fbus[k]] when you define var p_g{bust}. Are you trying to write a balance constraint? I would recommend you to refer to https://ampl.com/BOOK/CHAPTERS/18-network.pdf (page 322) to understand the balance constraint.

Thanks,
Paras

--
Paras Tiwari
[hidden email]


On Sun, Apr 8, 2018 at 1:55 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Hi,

I am solving network flow problem. So, you have from bus and to bus and branch number in the below set.

param: BRANCH: branch_fbus branch_tbus branch_x branch_rateA branch_rateC


You also have the below parameters which will be defined in terms of branch as below.

param branch_x{bust,bust}<=0;
param branch_rateA{bust,bust}>=0;
param branch_rateC{BRANCH}>=0;
param branch_cost{BRANCH}>=0;
param branch_curr{BRANCH}>=0;
param branch_max{BRANCH}>=0;

The problem is that we have variables that will be defined as an index within an index, as it will access the "from bus" from the branch index as per below.

subject to constraints{k in BRANCH}:
p_g[branch_fbus[k]]-bus_Pdn[branch_fbus[k]]=sum{n in branch_fbus, j in branch_tbus: branch_fbus[n]== branch_fbus[k]} branch_p_flow[n,j]- sum{j in branch_fbus, n in branch_tbus: branch_tbus[n]== branch_fbus[k]} branch_p_flow[j,n];

But this gives me a syntax error.

I have done the below to be able to do it

set BRANCH;
set branch_fbus{BRANCH};

set branch_tbus{BRANCH};

param l in BRANCH;
set bust = bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];

var p_g{bust}; # Generated power


Any Help !!! Thanks a lot !!!

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

--
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 16136] Index within Index

AMPL mailing list
Can you send us your model, data and run file? You can send to in [hidden email] if you don't want to send in a public group. We will run your model at our end and advise you about the problem.

Thanks,
Paras

--
Paras Tiwari
[hidden email]
{#HS:556992796-4729#}
On Tue, Apr 10, 2018 at 7:59 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Dear Paras,

Thank you for the clarification. However, I have done the below union. Does this make it the same index for bust and branch_fbus. So, I can index freely over bust & branch_fbus & branch_fbus ?

param l in BRANCH;
set bust = bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];

Anyways I have another Syntax error when I write the below.

param k{BRANCH};
param branch_x{branch_fbus[k],branch_tbus[k]}<=0;


I want to access the branch_x through branch_fbus & <b style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">branch_tbus. <b style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">branch_fbus & <b style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">branch_tbus are indexed over BRANCH for the below set.</b></b></b>

I don't know why I get the syntax error.

param: BRANCH: branch_fbus branch_tbus branch_x branch_rateA branch_rateC

Thanks a lot for your support !!

Best Regards,

Zeyad Kassem



On Mon, Apr 9, 2018 at 5:55 PM UTC, AMPL Google Group <[hidden email]> wrote:
You have defined over bust, but you are accessing over branch_fbus. If you look at your statement p_g[branch_fbus[k]] p_g is being indexed over branch_fbus. So, you are defining over one set/param, but accessing over another. You need to be consistent in defining and accessing the variable.

Thanks,
Paras

--
Paras Tiwari
[hidden email]


On Mon, Apr 9, 2018 at 1:47 AM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Yes, I have defined p_g over bust but please note that I have written the
below also. I guess this should make it work right ?

*set BRANCH;*



On Sun, Apr 8, 2018 at 9:37 PM UTC, AMPL Google Group <[hidden email]> wrote:
You have defined p_g over bust, but you are trying to access it over branch_fbus[k] in your constraint. You can't access {k in BRANCH} p_g[branch_fbus[k]] when you define var p_g{bust}. Are you trying to write a balance constraint? I would recommend you to refer to https://ampl.com/BOOK/CHAPTERS/18-network.pdf (page 322) to understand the balance constraint.

Thanks,
Paras

--
Paras Tiwari
[hidden email]


On Sun, Apr 8, 2018 at 1:55 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Hi,

I am solving network flow problem. So, you have from bus and to bus and branch number in the below set.

param: BRANCH: branch_fbus branch_tbus branch_x branch_rateA branch_rateC


You also have the below parameters which will be defined in terms of branch as below.

param branch_x{bust,bust}<=0;
param branch_rateA{bust,bust}>=0;
param branch_rateC{BRANCH}>=0;
param branch_cost{BRANCH}>=0;
param branch_curr{BRANCH}>=0;
param branch_max{BRANCH}>=0;

The problem is that we have variables that will be defined as an index within an index, as it will access the "from bus" from the branch index as per below.

subject to constraints{k in BRANCH}:
p_g[branch_fbus[k]]-bus_Pdn[branch_fbus[k]]=sum{n in branch_fbus, j in branch_tbus: branch_fbus[n]== branch_fbus[k]} branch_p_flow[n,j]- sum{j in branch_fbus, n in branch_tbus: branch_tbus[n]== branch_fbus[k]} branch_p_flow[j,n];

But this gives me a syntax error.

I have done the below to be able to do it

set BRANCH;
set branch_fbus{BRANCH};

set branch_tbus{BRANCH};

param l in BRANCH;
set bust = bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];

var p_g{bust}; # Generated power


Any Help !!! Thanks a lot !!!

--
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 16138] Index within Index

Zeyad Kassem
Dear Paras, 

Please find attached the files. 

Best Regards, 
Zeyad Kassem

On Tue, Apr 10, 2018 at 10:41 PM, AMPL Google Group <[hidden email]> wrote:
Can you send us your model, data and run file? You can send to in [hidden email] if you don't want to send in a public group. We will run your model at our end and advise you about the problem.

Thanks,
Paras

--
Paras Tiwari
[hidden email]
{#HS:556992796-4729#}
On Tue, Apr 10, 2018 at 7:59 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Dear Paras,

Thank you for the clarification. However, I have done the below union. Does this make it the same index for bust and branch_fbus. So, I can index freely over bust & branch_fbus & branch_fbus ?

param l in BRANCH;
set bust = bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];

Anyways I have another Syntax error when I write the below.

param k{BRANCH};
param branch_x{branch_fbus[k],branch_tbus[k]}<=0;


I want to access the branch_x through branch_fbus & <b style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">branch_tbus. <b style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">branch_fbus & <b style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">branch_tbus are indexed over BRANCH for the below set.</b></b></b>

I don't know why I get the syntax error.

param: BRANCH: branch_fbus branch_tbus branch_x branch_rateA branch_rateC

Thanks a lot for your support !!

Best Regards,

Zeyad Kassem



On Mon, Apr 9, 2018 at 5:55 PM UTC, AMPL Google Group <[hidden email]> wrote:
You have defined over bust, but you are accessing over branch_fbus. If you look at your statement p_g[branch_fbus[k]] p_g is being indexed over branch_fbus. So, you are defining over one set/param, but accessing over another. You need to be consistent in defining and accessing the variable.

Thanks,
Paras

--
Paras Tiwari
[hidden email]


On Mon, Apr 9, 2018 at 1:47 AM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Yes, I have defined p_g over bust but please note that I have written the
below also. I guess this should make it work right ?

*set BRANCH;*



On Sun, Apr 8, 2018 at 9:37 PM UTC, AMPL Google Group <[hidden email]> wrote:
You have defined p_g over bust, but you are trying to access it over branch_fbus[k] in your constraint. You can't access {k in BRANCH} p_g[branch_fbus[k]] when you define var p_g{bust}. Are you trying to write a balance constraint? I would recommend you to refer to https://ampl.com/BOOK/CHAPTERS/18-network.pdf (page 322) to understand the balance constraint.

Thanks,
Paras

--
Paras Tiwari
[hidden email]


On Sun, Apr 8, 2018 at 1:55 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Hi,

I am solving network flow problem. So, you have from bus and to bus and branch number in the below set.

param: BRANCH: branch_fbus branch_tbus branch_x branch_rateA branch_rateC


You also have the below parameters which will be defined in terms of branch as below.

param branch_x{bust,bust}<=0;
param branch_rateA{bust,bust}>=0;
param branch_rateC{BRANCH}>=0;
param branch_cost{BRANCH}>=0;
param branch_curr{BRANCH}>=0;
param branch_max{BRANCH}>=0;

The problem is that we have variables that will be defined as an index within an index, as it will access the "from bus" from the branch index as per below.

subject to constraints{k in BRANCH}:
p_g[branch_fbus[k]]-bus_Pdn[branch_fbus[k]]=sum{n in branch_fbus, j in branch_tbus: branch_fbus[n]== branch_fbus[k]} branch_p_flow[n,j]- sum{j in branch_fbus, n in branch_tbus: branch_tbus[n]== branch_fbus[k]} branch_p_flow[j,n];

But this gives me a syntax error.

I have done the below to be able to do it

set BRANCH;
set branch_fbus{BRANCH};

set branch_tbus{BRANCH};

param l in BRANCH;
set bust = bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];

var p_g{bust}; # Generated power


Any Help !!! Thanks a lot !!!

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

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

DCOPF.run (246 bytes) Download Attachment
DCOPFL.dat (10K) Download Attachment
DCOPFN.mod (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16140] Index within Index

AMPL mailing list
When I look at your data file, branch_fbus should be a param not a set because you have duplicate members in branch_fbus. You have specified data as if branch_fbus is a param indexed by the set BRANCH. However, you have declared branch_fbus as a set and defined BRANCH as the subset of cross product of branch_fbus and branch_tbus. You should be clear about the relationship among BRANCH, branch_fbus and branch_tbus. If BRANCH is the subset of the cross product of branch_fbus and branch_tbus then branch_fbus and branch_tbus should not have duplicate members.

If you are trying to reduce the redundancy in specifying data, I would recommend you to read https://ampl.com/BOOK/CHAPTERS/12-data.pdf (pp:151). Similarly refer to https://ampl.com/BOOK/CHAPTERS/09-sets2.pdf (pp 93) to define a set of dimension two.



--
Paras Tiwari
[hidden email]
{#HS:556992796-4729#}
On Tue, Apr 10, 2018 at 10:56 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Dear Paras,

Please find attached the files.

Best Regards,
Zeyad Kassem



On Tue, Apr 10, 2018 at 8:41 PM UTC, AMPL Google Group <[hidden email]> wrote:
Can you send us your model, data and run file? You can send to in [hidden email] if you don't want to send in a public group. We will run your model at our end and advise you about the problem.

Thanks,
Paras

--
Paras Tiwari
[hidden email]


On Tue, Apr 10, 2018 at 7:59 PM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Dear Paras,

Thank you for the clarification. However, I have done the below union. Does this make it the same index for bust and branch_fbus. So, I can index freely over bust & branch_fbus & branch_fbus ?

param l in BRANCH;
set bust = bus_num union genD_bus union branch_fbus[l] union branch_tbus[l];

Anyways I have another Syntax error when I write the below.

param k{BRANCH};
param branch_x{branch_fbus[k],branch_tbus[k]}<=0;


I want to access the branch_x through branch_fbus & <b style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">branch_tbus. <b style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">branch_fbus & <b style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">branch_tbus are indexed over BRANCH for the below set.</b></b></b>

I don't know why I get the syntax error.

param: BRANCH: branch_fbus branch_tbus branch_x branch_rateA branch_rateC

Thanks a lot for your support !!

Best Regards,

Zeyad Kassem



On Mon, Apr 9, 2018 at 5:55 PM UTC, AMPL Google Group <[hidden email]> wrote:
You have defined over bust, but you are accessing over branch_fbus. If you look at your statement p_g[branch_fbus[k]] p_g is being indexed over branch_fbus. So, you are defining over one set/param, but accessing over another. You need to be consistent in defining and accessing the variable.

Thanks,
Paras

--
Paras Tiwari
[hidden email]


On Mon, Apr 9, 2018 at 1:47 AM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Yes, I have defined p_g over bust but please note that I have written the
below also. I guess this should make it work right ?

*set BRANCH;*



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