[AMPL 18267] Syntax Error

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

[AMPL 18267] Syntax Error

Murilo Souza
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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2)) <<< ;


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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2));

--
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 18271] Syntax Error

AMPL mailing list
There is an imbalance between parentheses ( and ) after the = sign.

--
Robert Fourer
[hidden email]
{#HS:789195227-37401#}
On Wed, Feb 27, 2019 at 3:01 PM UTC, Ampl Modeling Language <[hidden email]> wrote:
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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2)) <<< ;

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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2));



--
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 18292] Syntax Error

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

Re: [AMPL 18293] Syntax Error

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

Re: [AMPL 18307] Syntax Error

AMPL mailing list
Your description suggests that you should write the constraint like this:

DTT3 = sqrt(1e-20 + sum {h in Ordem_Harm: h mod 3 =0} (Vh_filtro[i,h]^2))/u*100;

--
Robert Fourer
[hidden email]
{#HS:789195227-37401#}
On Thu, Feb 28, 2019 at 6:04 PM UTC, Ampl Modeling Language <[hidden email]> wrote:
Thanks! I got it!

Now, in another line in my code, i got this error:


syntax error
context: DTT3 = sqrt(1e-20+sum{h in Ordem_Harm} (Vh_filtro[i,h]^2 >>> if <<< h mod 3 == 0))/u*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.



On Thu, Feb 28, 2019 at 11:47 AM UTC, Ampl Modeling Language <[hidden email]> wrote:
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];



On Wed, Feb 27, 2019 at 4:11 PM UTC, AMPL Google Group <[hidden email]> wrote:
There is an imbalance between parentheses ( and ) after the = sign.

--
Robert Fourer
[hidden email]


On Wed, Feb 27, 2019 at 3:01 PM UTC, Ampl Modeling Language <[hidden email]> wrote:
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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2)) <<< ;

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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2));



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

[AMPL 18310] Re: Syntax Error

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

[AMPL 18310] Re: Syntax Error

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

Re: [AMPL 18320] Syntax Error

AMPL mailing list
You are getting an error because you are using a set expression "1 .. 4" in your data file:

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]
{#HS:789195227-37401#}
On Sat, Mar 2, 2019 at 9:41 PM UTC, Ampl Modeling Language <[hidden email]> wrote:
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



On Sat, Mar 2, 2019 at 9:12 PM UTC, Ampl Modeling Language <[hidden email]> wrote:
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



On Sat, Mar 2, 2019 at 5:16 AM UTC, AMPL Google Group <[hidden email]> wrote:
Your description suggests that you should write the constraint like this:

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:
Thanks! I got it!

Now, in another line in my code, i got this error:


syntax error
context: DTT3 = sqrt(1e-20+sum{h in Ordem_Harm} (Vh_filtro[i,h]^2 >>> if <<< h mod 3 == 0))/u*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.



On Thu, Feb 28, 2019 at 11:47 AM UTC, Ampl Modeling Language <[hidden email]> wrote:
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];



On Wed, Feb 27, 2019 at 4:11 PM UTC, AMPL Google Group <[hidden email]> wrote:
There is an imbalance between parentheses ( and ) after the = sign.

--
Robert Fourer
[hidden email]


On Wed, Feb 27, 2019 at 3:01 PM UTC, Ampl Modeling Language <[hidden email]> wrote:
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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2)) <<< ;

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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2));



--
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 18350] Syntax Error

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

Re: [AMPL 18351] Syntax Error

AMPL mailing list
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

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]
{#HS:789195227-37401#}
On Fri, Mar 8, 2019 at 12:20 PM UTC, Ampl Modeling Language <[hidden email]> wrote:
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?



On Mon, Mar 4, 2019 at 3:42 PM UTC, AMPL Google Group <[hidden email]> wrote:
You are getting an error because you are using a set expression "1 .. 4" in your data file:

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



On Sat, Mar 2, 2019 at 9:12 PM UTC, Ampl Modeling Language <[hidden email]> wrote:
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



On Sat, Mar 2, 2019 at 5:16 AM UTC, AMPL Google Group <[hidden email]> wrote:
Your description suggests that you should write the constraint like this:

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:
Thanks! I got it!

Now, in another line in my code, i got this error:


syntax error
context: DTT3 = sqrt(1e-20+sum{h in Ordem_Harm} (Vh_filtro[i,h]^2 >>> if <<< h mod 3 == 0))/u*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.



On Thu, Feb 28, 2019 at 11:47 AM UTC, Ampl Modeling Language <[hidden email]> wrote:
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];



On Wed, Feb 27, 2019 at 4:11 PM UTC, AMPL Google Group <[hidden email]> wrote:
There is an imbalance between parentheses ( and ) after the = sign.

--
Robert Fourer
[hidden email]


On Wed, Feb 27, 2019 at 3:01 PM UTC, Ampl Modeling Language <[hidden email]> wrote:
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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2)) <<< ;

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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2));



--
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 18354] Syntax Error

Murilo Souza
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:
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

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
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="EH1jMyeNCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...
{#HS:789195227-37401#}
On Fri, Mar 8, 2019 at 12:20 PM UTC, Ampl Modeling Language <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="EH1jMyeNCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
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?



On Mon, Mar 4, 2019 at 3:42 PM UTC, AMPL Google Group <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="EH1jMyeNCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
You are getting an error because you are using a set expression "1 .. 4" in your data file:

set Barras := 1 .. 4;

This is syntactically correct but does not produce the set you want; see <a href="https://ampl.com/faqs/why-does-set-s-50-70-give-me-a-set-of-only-3-members/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fampl.com%2Ffaqs%2Fwhy-does-set-s-50-70-give-me-a-set-of-only-3-members%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHtZblYYsHB-_JoSZJJY5znNbbHog&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fampl.com%2Ffaqs%2Fwhy-does-set-s-50-70-give-me-a-set-of-only-3-members%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHtZblYYsHB-_JoSZJJY5znNbbHog&#39;;return true;">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
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="EH1jMyeNCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...


On Sat, Mar 2, 2019 at 9:41 PM UTC, Ampl Modeling Language <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="EH1jMyeNCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
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



On Sat, Mar 2, 2019 at 9:12 PM UTC, Ampl Modeling Language <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="EH1jMyeNCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
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



On Sat, Mar 2, 2019 at 5:16 AM UTC, AMPL Google Group <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="EH1jMyeNCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
Your description suggests that you should write the constraint like this:

DTT3 = sqrt(1e-20 + sum {h in Ordem_Harm: h mod 3 =0} (Vh_filtro[i,h]^2))/u*100;

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


On Thu, Feb 28, 2019 at 6:04 PM UTC, Ampl Modeling Language <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="EH1jMyeNCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
Thanks! I got it!

Now, in another line in my code, i got this error:


syntax error
context: DTT3 = sqrt(1e-20+sum{h in Ordem_Harm} (Vh_filtro[i,h]^2 >>> if <<< h mod 3 == 0))/u*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.



On Thu, Feb 28, 2019 at 11:47 AM UTC, Ampl Modeling Language <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="EH1jMyeNCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
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];



On Wed, Feb 27, 2019 at 4:11 PM UTC, AMPL Google Group <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="EH1jMyeNCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
There is an imbalance between parentheses ( and ) after the = sign.

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


On Wed, Feb 27, 2019 at 3:01 PM UTC, Ampl Modeling Language <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="EH1jMyeNCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">am...@...> wrote:
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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2)) <<< ;

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)))/((Xcf[k]/(fq*(2*hs[k]+1)))^2+(h*Xcf[k]/((2*hs[k]+1)^2)-Xcf[k]/h)^2));



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