Hello, i'm very new to AMPL, and i'm getting a syntax error on a constraint on my model:
-- syntax error context: yf_real[k,h] = >>> (Xcf[k]/(fq*(2*hs[k]+1)))/(( Heres the constraint: s.t. admit_filtro_real {k in Barras_Candidatas, h in Ordem_Harm}: yf_real[k,h] = (Xcf[k]/(fq*(2*hs[k]+1)))/(( 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. |
{#HS:789195227-37401#}
On Wed, Feb 27, 2019 at 3:01 PM UTC, 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. |
Thanks for the reply, i got it!
-- But now, in another line of my code, i'm getting these two errors, not sure why... i've used sum{} in a similar way before, and it worked. codigo.mod, line 64 (offset 2990): C is undefined context: sum{C in Colunas} >>> Yh_filtro_real[L,C,h]*Vh_filtro_real[C,h]-Yh_filtro_imag[L,C,h] <<< *Vh_filtro_imag[C,h] = Ih_real[L,h]; codigo.mod, line 64 (offset 2990): C is undefined context: sum{C in Colunas} >>> Yh_filtro_real[L,C,h]*Vh_filtro_real[C,h]-Yh_filtro_imag[L,C,h]*Vh_filtro_imag[C,h] <<< = Ih_real[L,h]; 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. |
In reply to this post by AMPL mailing list
Thanks! I got it!
-- Now, in another line in my code, i got this error: syntax error context: DTT3[i] = sqrt(1e-20+sum{h in Ordem_Harm} (Vh_filtro[i,h]^2 >>> if <<< h mod 3 == 0))/u[i]*100; But i'm not really sure how to use a "if" condition here, so i'll try to explain this restriction a little bit: I've seen in the AMPL book, that, the "a mod b" computes the remainder between a and b. In my problem, i got this: Ordem_Harm := 3 .. 25 by 2; # (only odd numbers between 3 and 25) So, in this restriction, if the remainder of the division between h and 3 is equal 0 (i.e, its an odd number multiple of 3), i got that restriction that needs to be satisfied. 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. |
Your description suggests that you should write the constraint like this:
{#HS:789195227-37401#}
DTT3 = sqrt(1e-20 + sum {h in Ordem_Harm: h mod 3 =0} (Vh_filtro[i,h]^2))/u*100; -- Robert Fourer [hidden email]
On Thu, Feb 28, 2019 at 6:04 PM UTC, 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. |
In reply to this post by Murilo Souza
Thanks again!
-- My model file is ok now, no more errors, but i got some errors in my data file now. I got this parameter defined in my model file: param Ih_real{Linhas,Ordem_Harm}; and in my data file, i got this: set Linhas := 1 .. 4; set Ordem_Harm = 3 .. 15 by 2; param Ih_real: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 := 1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2 0.0 0.0 0.0 0.0 -34.8415 0.0 -18.3912 0.0 0.0 0.0 1.80851 0.0 9.55292 0.0 0.0 3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0; And i got a lot of errors, but the first one is this: 2 item(s) missing in last line of table, which starts with "0" context: N 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 >>> ; <<< 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. |
In reply to this post by Murilo Souza
Thanks Robert!
-- My model and data files got no errors now, but i got a lot of errors when using the solve command, im going to post one of them here: Error executing "solve" command: error processing param u: 3 invalid subscripts discarded: u[2] u[3] u[4] and heres how u is defined in the model file: param u{Barras}; and in my data file, i got this: set Barras := 1 .. 4; param: u := 1 12492.40 2 12409.20 3 12413.10 4 12414.10; 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 are getting an error because you are using a set expression "1 .. 4" in your data file:
{#HS:789195227-37401#}
set Barras := 1 .. 4; This is syntactically correct but does not produce the set you want; see https://ampl.com/faqs/why-does-set-s-50-70-give-me-a-set-of-only-3-members/ for a further explanation. Instead you should define the set in your model file like this: param nBarras integer > 0; set Barras := 1 .. nBarras; Then in your data file, specify just the value for nBarras: param nBarras := 4; -- Robert Fourer [hidden email]
On Sat, Mar 2, 2019 at 9:41 PM UTC, 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. |
Oh, i see! Thanks for the explanation!
-- Now, my last error seems to be this one: ampl: solve; Error executing "solve" command: error processing param Ih_real: 32 invalid subscripts discarded: Ih_real[1,1] Ih_real[1,2] Ih_real[1,4] and 29 more. Error executing "solve" command: error processing param Ih_imag: 32 invalid subscripts discarded: Ih_imag[1,1] Ih_imag[1,2] Ih_imag[1,4] and 29 more. In my model file i got this: param N; param hmax; set Linhas := 1 .. N; set Ordem_Harm := 3 .. hmax by 2; param Ih_real{Linhas,Ordem_Harm}; # Real part param Ih_imag{Linhas, Ordem_Harm}; # Imaginary part And in my data file, i got this: param N := 4; param hmax := 15; param Ih_real: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 := 1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2 0.0 0.0 0.0 0.0 -34.8415 0.0 -18.3912 0.0 0.0 0.0 1.80851 0.0 9.55292 0.0 0.0 3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0; param Ih_imag: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 := 1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2 0.0 0.0 0.0 0.0 26.2423 0.0 6.62378 0.0 0.0 0.0 16.2161 0.0 10.7456 0.0 0.0 3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0; And i have another question... i have defined this variable: var DTT3{Barras} <= DTT3_max; where : set Barras := 1 .. N; and param DTT3_max default 5; Is this the correct way to define that all those DTT3 in the Barras set needs to be less or equal than 5? 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. |
Your data tables for lh_real and lh_imag should only have columns for 3, 5, 7, 9, 11, 13, 15, since those are the members of Ordem_Harm. You are getting messages like
{#HS:789195227-37401#}
32 invalid subscripts discarded: Ih_real[1,1] Ih_real[1,2] Ih_real[1,4] and 29 more. because you have included columns headed by other values such as 1, 2, 4, etc. -- Robert Fourer [hidden email]
On Fri, Mar 8, 2019 at 12:20 PM UTC, 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. |
Great! Thanks a lot for all your help Robert!
-- Em sexta-feira, 8 de março de 2019 14:58:21 UTC-3, AMPL Google Group escreveu:
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 |