csv2gdx4.gms : CSVRead Example 4 - Dealing with missing Labels and Duplicates

Description

This model demonstrates how to use the CSVRead 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 CSVRead Documentation.

Keywords: CSVRead, data exchange, GAMS language features, traveling salesman problem

  1. Missing labels


Category : GAMS Data Utilities library


Main file : csv2gdx4.gms   includes :  csv2gdx4.gms

$title CSVRead Example 4 - Dealing with missing Labels and Duplicates (CSV2GDXE4,SEQ=113)

$onText
This model demonstrates how to use the CSVRead 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 CSVRead Documentation.

Keywords: CSVRead, 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

Set
   i    'cities'
   axes 'x1 and x2 axes';

Parameter coord(i,axes) 'coordinate of city i';

$callTool csvread EUCData.csv id=coord dimids=i,axes fieldSep=semiColon autoCol=x autoRow=city values=1,2 trace=0
$ifE errorLevel<>0 $abort Problems reading EUCData.csv!

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

Set
   row   'UELs generated by autoRow'
   color 'set of colors';

Parameter data(row,color,color);

$callTool csvread duplicates.csv id=data dimids=row,color,color index=1,2 values=3 autoRow=row trace=4
$ifE errorLevel<>0 $abort Problems reading duplicates.csv!

display row, color, data;