syntax error in .dat

373 views
Skip to first unread message

Nico

unread,
Nov 10, 2016, 5:01:29 PM11/10/16
to AMPL Modeling Language
Dear Bob,

I have some problems concerning my .dat files.


Everytime when I want to define one or two dimensional params in my .dat file I get an error message.

My .dat looks like this:


param T := 4;        

param Beta := 0.95;      

param epsilon := 0.1;

param D :=
1 60
2 83
3 91
4 83
;
The error message:

C:\AMPL\\Modell\minLos.dat, line 12 (offset 192):
 syntax error
context:  1  >>> 60 <<<


I receive the same Syntax error if I want to define a two dimensional param:

param q:  1  2  3  4:=
             1 25 20 0 0 
             2 0 0 0 0
             3 0 0 25 0
             4 0 0 0 15;


For the first example I defined param D in the .mod file as follows:

param D{i in 1..T} >= 0;


To me, it Looks like it should be done and as described in the book. Thats why i don't have a clue why it doesn't work..

Thanks a lot in advance,

Best regards
Nico.

Robert Fourer

unread,
Nov 11, 2016, 5:01:31 PM11/11/16
to am...@googlegroups.com
This is exactly the error that we see when we try to read your data file as if it is a model file. Check again that you are defining these params in a model file read with a "model" command, and are then reading the data file with a "data" command. But it that is indeed what you are doing, try posting the complete model and data files to this group, and also a transcript or screenshot of your AMPL session.

Bob Fourer
am...@googlegroups.com

=======

Amir Lm

unread,
Nov 11, 2016, 5:09:07 PM11/11/16
to AMPL Modeling Language, 4...@ampl.com
Hi Bob,

Would you please have a look at my problem explained in below.
I am just looking for a way to reduce the memory usage by AMPL or expand the solving time.
Many thanks for your time in advance!

CPLEX is giving me the memory error as follows.

CPLEX 12.6.1.0: ran out of memory.
0 MIP simplex iterations
0 branch-and-bound nodes
No basis.

I have put the command below.

ampl: model IntM-S.mod;
ampl: data IntM-S.dat;
ampl: options solver cplex;
ampl: option show_stats 1;
ampl: option cplex_options 'mipdisplay=2 nodefile=3';
ampl: solve;

and CPLEX gave the the presolve of:

Presolve eliminates 277 constraints and 955 variables.
Adjusted problem:
2695 variables:
2340 binary variables
25 integer variables
330 linear variables
902 constraints, all linear; 21926 nonzeros
385 equality constraints
517 inequality constraints
1 linear objective; 2180 nonzeros.

CPLEX 12.6.1.0: mipdisplay=2
nodefile=3
MIP Presolve eliminated 228 rows and 180 columns.
MIP Presolve modified 445 coefficients.
Reduced MIP has 519 rows, 2360 columns, and 13704 nonzeros.
Reduced MIP has 2335 binaries, 13 generals, 0 SOSs, and 0 indicators.
Probing time = 0.03 sec. (3.30 ticks)
MIP Pre solved modified 30 coefficients.
Reduced MIP has 519 rows, 2360 columns, and 13704 nonzeros.
Reduced MIP has 2335 binaries, 13 generals, 0 SOSs, and 0 indicators.
Probing time = 0.03 sec. (3.20 ticks)
Clique table members: 8227.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: deterministic, using up to 4 threads.
Root relaxation solution time = 0.08 sec. (17.02 ticks)

Any idea why do I still get this?!

There may be further error information in the clone logs.

GUB cover cuts applied:  13
Clique cuts applied:  48
Cover cuts applied:  256
Implied bound cuts applied:  3
Flow cuts applied:  2
Mixed integer rounding cuts applied:  111
Zero-half cuts applied:  26
Lift and project cuts applied:  3
Gomory fractional cuts applied:  13

Root node processing (before b&c):
  Real time             =    3.35 sec. (1476.59 ticks)
Parallel b&c, 4 threads:
  Real time             =  404.18 sec. (223642.10 ticks)
  Sync time (average)   =   36.63 sec.
  Wait time (average)   =   37.01 sec.
                          ------------
Total (root+branch&cut) =  407.54 sec. (225118.69 ticks)
Freeing branch-and-bound tree with 252652 nodes
211000 nodes freed
223000 nodes freed
248000 nodes freed
CPLEX 12.6.1.0: ran out of memory.
0 MIP simplex iterations
0 branch-and-bound nodes
No basis. 

Javier Ramirez

unread,
Dec 19, 2022, 2:46:06 AM12/19/22
to AMPL Modeling Language
Hi

Can you solve the syntax error?

Thanks!

AMPL Google Group

unread,
Dec 19, 2022, 6:45:48 PM12/19/22
to AMPL Modeling Language
The data for a scalar parameter (like T, Beta, or epsilon in the example) can be given in the model. But data for an indexed parameter, like D, has to be given separately from the definition of the parameter. Usually there is a model file that specifies, say,

param T := 4;
param Beta := 0.95;
param epsilon := 0.1;
param D {1..T};

Then in a data file, the values for the indexed parameter are given:


param D :=
1 60
2 83
3 91
4 83
;

The model file is read with a model statement, and the data file is read with a data statement, as in this example:

model test.mod;
data test.dat;

Alternatively, if you want to put everything in test.mod, just put a data statement without a filename before the data:

param T := 4;
param Beta := 0.95;
param epsilon := 0.1;
param D {1..T};

data;

param D :=
1 60
2 83
3 91
4 83
;

(The data for the scalar parameters can also be given in the data file rather than in the model, if that is convenient.)


--
Robert Fourer
am...@googlegroups.com
{#HS:2101587859-113291#}
Reply all
Reply to author
Forward
0 new messages