AYUDA AMPL

1,645 views
Skip to first unread message

Mnr

unread,
May 4, 2014, 2:31:55 PM5/4/14
to am...@googlegroups.com
Tengo un problema. Al ejecutar el programa me da el siguiente error en el fichero de datos y no sé por qué:
************************************************************

   NEOS Server Version 5.0
   Job#     : 3000604
   Password : ZedzOmlS
   Solver   : lp:Gurobi:AMPL
   Start    : 2014-05-04 13:16:03
   End      : 2014-05-04 13:16:08
   Host     : neos-6.neos-server.org

   Disclaimer:

   This information is provided without any express or
   implied warranty. In particular, there is no warranty
   of any kind concerning the fitness of this
   information  for any particular purpose.
*************************************************************
Load Avg: ( 15.08 , 13.61 , 9.29 )
File exists
You are using the solver gurobi_ampl.
Executing AMPL.
processing data.

amplin, line 73 (offset 2184):
	expected [
context:  set Sf >>> := <<< 

amplin, line 81 (offset 2330):
	Sfo is already defined
context:   >>> Sfo:=
1 3 4
2 2 4
3 2 3 4
4 3 4
5 2 3 4;
#conujnto de sectores que pueden ser volados por el vuelo f excluyendo el aeropuerto de destino
set Sfd:=
1 1 3 
2 1 2 
3 1 2 3
4 1 3 
5 1 2 3;

#conjunto de los periodos de tiempo de llegada factibles para el vuelo f en el sector j.
set Tjf:= 1 2 3 4
1 (2,4) (4,6) (5,8) (8,10)
2 (1,3) (3,7) (7,9) (9,10)
3 (1,4) (4,6) (4,7) (6,10)
4 (1,3) (2,5) (4,7) (7,10)
5 (1,4) (3,5) (4,8) (8,10);

set Lif:= 1 2 3 4
1 3 3 4 4
2 2 4 4 4
3 2 3 4 4
4 3 3 3 4
5 2 3 4 4;

set Pif:= 1 2 3 4
1 1 1 1 3
2 1 1 2 2
3 1 1 2 3
4 1 1 1 3
5 1 1 2 3;


set C dimen 2: f fprima:=
1  2 
3  4
5  1;

#capacidad de llegada en el aaeropuerto k en tiempo t
param A:= 1  2 
       1  1 0
       2  2 2
       3  0 3
       4  3 2
       5  1 1
       6  2 1
       7  2 4
       8  1 3
       9  1 1
       10 2 4;

#capacidad de salida en el aeropuerto k en el tiempo t
param D:=  1 2
        1  2 3
        2  1 2
        3  4 0
        4  2 2
        5  3 4 
        6  3 2
        7  1 1
        8  3 4
        9  0 5
        10 3 3;

#capacidad del sector j en el tiempo t
param Sj:= 1 2 3 4
1  1 2 1 1
2  2 2 3 2
3  0 3 2 1
4  2 2 2 2
5  1 1 1 1
6  3 1 2 2 
7  1 2 3 1
8  3 4 2 1
9  2 1 3 3
10 1 1 1 1;

#tiempo de llegada programado del vuelo f
param af:=
1 6
2 10
3 5
4 7
5 8;

#tiempo de salida programado del vuelo f
param df:=
1 3
2 4
3 1
4 4
4 2;

#aeropuerto de salida del vuelo f
param origf:= 
1 1
2 1
3 1
4 1
5 1;

#aeropuerto de llegada del vuelo f
param destf:=
1 2
2 2
3 2
4 2
5 2;

param OTjf:= 1 2 3 4
1 4 6 8 10
2 3 7 9 10
3 4 6 7 10
4 3 5 7 10
5 4 5 8 10;

param UTjf:= 1 2 3 4
1 2 4 5 8
2 1 3 7 9
3 1 4 4 6
4 1 2 4 7
5 1 3 4 8;

param lfjprimaj:= 1 2 3 4
1 1 1 1 1
2 1 1 1 1
3 1 1 1 1
4 1 1 1 1
5 1 1 1 1;


param saf:=
1 0.5
2 0.5 <<< 

amplin, line 86 (offset 2368):
	syntax error
context:  5 2 3  >>> 4; <<< 
processing commands.
 Error (2) in /opt/ampl/ampl -R amplin

Robert Fourer

unread,
May 5, 2014, 12:52:29 PM5/5/14
to am...@googlegroups.com
An error message like this,

amplin, line 73 (offset 2184):
expected [
context: set Sf >>> := <<<

occurs when Sf is defined as an indexed collection of sets (for example, "set Sf {1..n};") but then data is provided for Sf without a subscript. In the data file it is necessary to provide the data for each set separately (for example, "set Sf[1] := ...; set Sf[2] := ...;" and so forth).

An error message like this,

amplin, line 81 (offset 2330):
Sfo is already defined
context: >>> Sfo:=

often occurs when a data statement is read in model mode. This might just be a side-effect of the previous error, so your first step should be to correct that error and try again.

Bob Fourer
am...@googlegroups.com



Miriam Núñez-Romero Olmo

unread,
May 6, 2014, 6:07:59 AM5/6/14
to am...@googlegroups.com
Gracias. 
Y como puedo definir el conjunto de los periodos de tiempo de llegada factibles para el 
vuelo f en el sector j. Porque yo he intentado definirlo así:

set Tjf[1,1]:=interval (2,4);
set Tjf[1,2]:=interval (4,6);
set Tjf[1,3]:=interval (5,8);
set Tjf[1,4]:=interval (8,10);
set Tjf[2,1]:=interval (1,3);
set Tjf[2,2]:=interval (3,7);
set Tjf[2,3]:=interval (7,9);
set Tjf[2,4]:=interval (9,10);
set Tjf[3,1]:=interval (1,4);
set Tjf[3,2]:=interval (4,6);
set Tjf[3,3]:=interval (4,7);
set Tjf[3,4]:=interval (6,10);
set Tjf[4,1]:=interval (1,3);
set Tjf[4,2]:=interval (2,5);
set Tjf[4,3]:=interval (4,7);
set Tjf[4,4]:=interval (7,10);
set Tjf[5,1]:=interval (1,4);
set Tjf[5,2]:=interval (3,5);
set Tjf[5,3]:=interval (4,8);
set Tjf[5,4]:=interval (8,10);

y en el fichero de model:
set Tjf{1..vuelo,1..sector} within T;

donde vuelo=5 y sector=4

Pero esto me da el siguiente error:
*************************************************************
Load Avg: ( 33.14 , 32.42 , 31.29 )
File exists
You are using the solver gurobi_ampl.
Executing AMPL.
processing data.

amplin, line 109 (offset 2990):
	Tjf needs 1, not 2 subscripts
context:  set Tjf[1,1]:=interval (2,4 >>> ) <<< ;







--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/Akw6CXICyuU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

Robert Fourer

unread,
May 7, 2014, 11:20:40 AM5/7/14
to am...@googlegroups.com
A reasonable setup for this situation could be as follows:

param nT integer > 0;
set T = 1..nT;

param vuelo integer > 0;
param sector integer > 0;
param start {1..vuelo,1..sector} integer in 1..T;
param end {f in 1..vuelo, j in 1..sector} integer in 1..T, >= start[f,j];
set Tjf {f in 1..vuelo, j in 1..sector} = start[f,j]..end[f,j];

Then in the data file you only need to give parameter values for nT, vuelo, sector, start[f,j], and end[f,j], after which the sets T and Tjf are defined automatically.

Bob Fourer
am...@googlegroups.com

=======

From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of Miriam Núñez-Romero Olmo
Sent: Tuesday, May 6, 2014 5:08 AM
To: am...@googlegroups.com
Subject: Re: [AMPL 8579] AYUDA AMPL

Gracias.
Y como puedo definir el conjunto de los periodos de tiempo de llegada factibles para el
vuelo f en el sector j. Porque yo he intentado definirlo así:

set Tjf[1,1]:=interval (2,4);
set Tjf[1,2]:=interval (4,6);
set Tjf[1,3]:=interval (5,8);
...

Miriam Núñez-Romero Olmo

unread,
May 8, 2014, 12:31:51 PM5/8/14
to am...@googlegroups.com
Ahora me da otro error distinto y la verdad es que no entiendo por qué. Adjunto todos los ficheros para ver si me pueden dar una solución.
Gracias
El error es el siguiente:
*************************************************************
Load Avg: ( 16.64 , 15.81 , 14.76 )
File exists
You are using the solver gurobi_ampl.
Executing AMPL.
processing data.
Error at _cmdno 3 executing "solve" command
(file amplin, line 279, offset 4858):
error processing objective z:
	can't evaluate pow(-1,1.7): Numerical argument out of domain
processing commands.
 Error (2) in /opt/ampl/ampl -R amplin


datosej1.txt
modeloej1.txt
solveej1.txt

fbahr

unread,
May 8, 2014, 12:59:22 PM5/8/14
to am...@googlegroups.com
> error processing objective z: can't evaluate pow(-1,1.7): Numerical argument out of domain

(-1)^1.7 is not a real number, cf. http://www.wolframalpha.com/input/?i=pow%28-1%2C1.7%29

--fbahr

Miriam Núñez-Romero Olmo

unread,
May 12, 2014, 1:34:20 PM5/12/14
to am...@googlegroups.com
tengo un problema: al resolver me da el siguiente error pero en el programa no tengo definidas variables que nos ean lineales ni restricciones que no sean lineales. Adjunto los ficheros por si me puede ayudar. Gracias de antemano.

Un saludo
*************************************************************
Load Avg: ( 15.91 , 15.82 , 16.08 )
File exists
You are using the solver gurobi_ampl.
Executing AMPL.
processing data.
processing commands.

Presolve eliminates 12 constraints and 10 variables.
Adjusted problem:
210 variables:
	20 binary variables
	190 nonlinear variables
177 constraints; 1164 nonzeros
	40 nonlinear constraints
	137 linear constraints
	177 inequality constraints
1 linear objective; 35 nonzeros.

Gurobi 5.5.0: outlev=1
threads=4
Gurobi 5.5.0: Gurobi can't handle nonquadratic nonlinear constraints.
datosej1.txt
modeloej1.txt
solveej1.txt
Message has been deleted

fbahr

unread,
May 12, 2014, 2:39:53 PM5/12/14
to am...@googlegroups.com
Your constraint(s) r3 includes a max expression involving (a) decision variable(s) -- this makes your model non-linear (cf. http://ampl.com/faqs/why-does-ampl-treat-my-linear-program-as-nonlinear/).

Fortunately for you, there's a (quite) simple linearization technique (introducing binary variables, though) -- as discussed in Paul Rubin's blog:
> http://orinanobworld.blogspot.com/2011/01/max-and-min-functions-in-mip.html

--fbahr

Robert Fourer

unread,
May 13, 2014, 1:55:53 PM5/13/14
to am...@googlegroups.com
Because your constraint has the particular form

subject to r3{j in S, t in T}:
sum {f in F, j0 in Sf[f]}
max( 0, w[f,j0,t]-sum{jprima in Lif[j,f]}w[f,jprima,t] ) <= Sj[t,j];

I think you should be able to create a linear equivalent without binary variables. You would have to define, say,

var Z {j in S, t in T, f in F, j0 in Sf[f]} >= 0;

and then add constraints

subj to Zmax {j in S, t in T, f in F, j0 in Sf[f]}:
Z[j,t,f,j0] >= w[f,j0,t]-sum{jprima in Lif[j,f]}w[f,jprima,t];

Then your constraint could be written as

subject to r3{j in S, t in T}:
sum {f in F, j0 in Sf[f]} Z[j,t,f,j0] <= Sj[t,j];

Bob Fourer
am...@googlegroups.com

=======

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of fbahr
Sent: Monday, May 12, 2014 1:40 PM
To: am...@googlegroups.com
Subject: Re: [AMPL 8642] AYUDA AMPL

Your constraint(s) r3 includes a max expression involving (a) decision variable(s) -- this makes your model non-linear (cf. http://ampl.com/faqs/why-does-ampl-treat-my-linear-program-as-nonlinear/).

Fortunately for you, there's a (quite) simple linearization technique (introducing binary variables, though) -- as discussed in Paul Rubin's blog:
> http://orinanobworld.blogspot.com/2011/01/max-and-min-functions-in-mip.html

--fbahr

=======

On Monday, May 12, 2014 7:34:20 PM UTC+2, Mnr wrote:
tengo un problema: al resolver me da el siguiente error pero en el programa no tengo definidas variables que nos ean lineales ni restricciones que no sean lineales. Adjunto los ficheros por si me puede ayudar.

.......

francisco...@correounivalle.edu.co

unread,
Oct 26, 2016, 6:40:10 PM10/26/16
to AMPL Modeling Language

Robert Fourer

unread,
Oct 27, 2016, 10:54:01 AM10/27/16
to am...@googlegroups.com
These messages do not give enough information to say what is causing the error. Can you attach your complete model and data files?

Bob Fourer
am...@googlegroups.com



Miriam Núñez-Romero Olmo

unread,
Oct 27, 2016, 10:57:36 AM10/27/16
to am...@googlegroups.com

Thanks you, but I solved the error  two years ago


--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/Akw6CXICyuU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+unsubscribe@googlegroups.com.

To post to this group, send email to am...@googlegroups.com.

Robert Fourer

unread,
Oct 27, 2016, 11:52:08 AM10/27/16
to am...@googlegroups.com
Strange ... Apparently your question was forwarded to the group by someone else yesterday. I didn't look closely at the dates in the NEOS log.

Bob Fourer
am...@googlegroups.com

=======

maria florencia valdivia aranda

unread,
Nov 1, 2016, 7:29:32 PM11/1/16
to AMPL Modeling Language

maria florencia valdivia aranda

unread,
Nov 1, 2016, 7:48:22 PM11/1/16
to AMPL Modeling Language
Bunas tardes...necesito ayuda con el codigo adjunto...
 tira el error de la imagen adjunta...
Seria de mucha ayuda algun comentario al respecto

Gracias !!!!!!!
Saludos
1-11 AMPL.txt
ampl error.png

Robert Fourer

unread,
Nov 2, 2016, 4:55:48 PM11/2/16
to am...@googlegroups.com
You should concentrate on fixing the first error, since it may be causing later errors. It seems that the data for set Sf does not correspond properly to the definition of Sf in the model, but to get more detailed help you would need to post the model and data files.

Bob Fourer
am...@googlegroups.com

=======

Robert Fourer

unread,
Nov 2, 2016, 4:59:28 PM11/2/16
to am...@googlegroups.com
It appears that "data C:\AMPL\acol.dat" was made into a comment in the file acol.run -- there is a # symbol in front of it. Thus your command "include C:\AMPL\acol.run" did not cause any data to be read, and you received the "no data for ..." message when you tried to solve.

Bob Fourer
am...@googlegroups.com

=======

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of maria florencia valdivia aranda
Sent: Tuesday, November 1, 2016 6:48 PM
To: AMPL Modeling Language
Subject: [AMPL 12868] Re: AYUDA AMPL

Reply all
Reply to author
Forward
0 new messages