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 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.
{#HS:556992796-4729#}
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:
--
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. |
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 ?
--
On Sunday, April 8, 2018 at 11:37:49 PM UTC+2, AMPL Google Group 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 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.
{#HS:556992796-4729#}
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:
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. |
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 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. |
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.
{#HS:556992796-4729#}
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:
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. |
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:
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 |
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.
{#HS:556992796-4729#}
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]
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. |
Free forum by Nabble | Edit this page |