ContentsIndexHome
PreviousUpNext
Retrieving data

If you want to retrieve the data of an identifier you have to start by opening a reference to the data of that identifier, for instance a scalar.

  IScalarData variableTotalCost = session.openScalar("TotalCost");

Retrieving the data associated with the scalar data reference is straightforward:

  double totalCost = variableTotalCost.Double;
  variableTotalCost.close();

Next we continue by examining the data of a multidimensional identifier; as always, first open up the reference to the data:

  IMultiDimData variableTransport = session.openMultiDim("Transport");

Now, you might use the getDouble method of the IMultiDimData object to obtain a single value for a position in the identifier; but here we aim to iterate over all the values of the transport variable, so we create an iterator:

  IIterator it = variableTransport.createIterator();

And we iterate the data by repeatedly invoking the next method and querying the current position and value:

  IIterator it = variableTransport.createIterator();
  while (it.next())
  {
    Console.Out.WriteLine(it.Tuple + " : " + it.Double);
  }
  it.close();

For AIMMS models it is very typical that identifier data is sparsely populated with non-default values. AIMMS therefore always stores identifier data in a sparse format. An iterator in the SDK therefore also offers the data in a sparse manner. So the output of the above iteration is:

('London','Oslo'): 5
('London','Madrid'): 15
('Paris','Oslo'): 5
('Paris','Berlin'): 20

i.e., the data points

('London','Berlin'): 0
('Paris','Madrid'): 0

are skipped by the iterator, because they have a default (0.0) value.