Description
This model demonstrates how to use the CSV2GDX tool on data with missing labels, i.e. the autoCol and autoRow option is used to process the data. The file EUCData.csv contains the extracted euclidian coordinates of the first nine cities of berlin52.tsp from TSPLib. You might want to import the data to calculate a complete distance matrix inside GAMS to find an optimal traveling salesman tour for instance. This model is referenced in "Getting Started Example 3 - Dealing with missing labels and duplicates" from the CSV2GDX Documentation. Keywords: CSV2GDX, data exchange, GAMS language features, traveling salesman problem 1. Missing labels
Category : GAMS Data Utilities library
Main file : csv2gdx4.gms includes : csv2gdx4.gms
$title CSV2GDX Example 4 - Dealing with missing Labels and Duplicates (CSV2GDXE4,SEQ=113)
$onText
This model demonstrates how to use the CSV2GDX tool on data with missing labels,
i.e. the autoCol and autoRow option is used to process the data.
The file EUCData.csv contains the extracted euclidian coordinates of the first
nine cities of berlin52.tsp from TSPLib.
You might want to import the data to calculate a complete distance matrix
inside GAMS to find an optimal traveling salesman tour for instance.
This model is referenced in "Getting Started Example 3 - Dealing with missing
labels and duplicates" from the CSV2GDX Documentation.
Keywords: CSV2GDX, data exchange, GAMS language features, traveling salesman problem
$offText
* 1. Missing labels
$onEcho > EUCData.csv
565.0;575.0
25.0;185.0
345.0;750.0
945.0;685.0
845.0;655.0
880.0;660.0
25.0;230.0
525.0;1000.0
580.0;1175.0
$offEcho
$call csv2gdx EUCData.csv id=coord fieldSep=semiColon autoCol=x autoRow=city colCount=2 values=1,2 trace=0
$ifE errorLevel<>0 $abort Problems reading EUCData.csv!
Set
i 'cities'
axes 'x1 and x2 axes';
$gdxIn EUCData.gdx
$load i = dim1
$load axes = dim2
Parameter coord(i,axes) 'coordinate of city i';
$load coord
$gdxIn
display coord;
Alias (i,j);
Parameter c(i,j) 'euclidian distance between i and j';
c(i,j) = eDist(coord(i,"x1") - coord(j,"x1"),coord(i,"x2") - coord(j,"x2"));
display c;
* 2. Duplicates
$onEcho > duplicates.csv
red,red,1
red,red,2
red,green,3
blue,blue,4
$offEcho
$call csv2gdx duplicates.csv id=data index=1,2 value=3 colCount=3 autoRow=row trace=0
$ifE errorLevel<>0 $abort Problems reading duplicates.csv!
Set
row 'UELs generated by autoRow'
color 'set of colors';
$gdxIn duplicates.gdx
$load row = dim1
$load color = dim2
$loadM color = dim3
Parameter data(row,color,color);
$load data
$gdxIn
display row, color, data;