ContentsIndexHome
PreviousUpNext
Inserting data into an identifier

In order to assign data to AIMMS, you will need to open up a kind of IData object.

To obtain access to, for instance, a multidimensional parameter Supply, you can call the openMultiDim method of the ISession interface.

  aimmsSession = AIMMS.openSession(args[0], args[1]);
  IMultiDimData parameterSupply = session.openMultiDim("Supply");

The IMultiDimData interface offers two types of methods to add data to an identifier: insert and setValue. The difference between these two methods lies in the way in which the SDK will deal with the domain sets corresponding to the multidimensional identifier at hand. The insert method will insert the data into the multidimensional identifier, but it will also insert the specified tuple into the domain sets and their supersets when necessary. The setValue method will first check if all elements of the specified tuple exists in their corresponding domain sets, and then insert the data into the multidimensional identifier. If the check fails an AimmsRuntimeException is thrown. 

insert:

  parameterSupply.insert(new Tuple("London"), 20.0);
  parameterSupply.insert(new Tuple("Paris"), 30.0);
  parameterSupply.close();

  IMultiDimData parameterDemand = session.openMultiDim("Demand");
  parameterDemand.insert(new Tuple("Oslo"), 10.0);
  parameterDemand.insert(new Tuple("Madrid"), 15.0);
  parameterDemand.insert(new Tuple("Berlin"), 20.0);
  parameterDemand.close();

setValue:

  IMultiDimData parameterUnitTransportCost = session.openMultiDim("UnitTransportCost");
  try {
    parameterUnitTransportCost.setValue(new Tuple("London", "Oslo"), 7.0);
    parameterUnitTransportCost.setValue(new Tuple("London", "Madrid"), 12.0);
    parameterUnitTransportCost.setValue(new Tuple("London", "Berlin"), 18.0);
    parameterUnitTransportCost.setValue(new Tuple("Paris", "Oslo"), 14.0);
    parameterUnitTransportCost.setValue(new Tuple("Paris", "Madrid"), 23.0);
    parameterUnitTransportCost.setValue(new Tuple("Paris", "Berlin"), 17.0);
  } catch (AimmsRuntimeException e) {
    // deal with data consistency problem
  }
  parameterUnitTransportCost.close();