7.3 Sparse Data Vectors

MPL allows you to choose between a dense or sparse storage for the specification of datavectors. MPL is typically a little faster when it processes dense data as compared to sparse data, but storage is needed for every element. Therefore, when you are working with large matrixes containing relatively few nonzero elements, sparse storage becomes significantly more effective.

To define a sparse data vector, you surround the list of elements with brackets instead of the usual parentheses. Inside the brackets you list each nonzero element preceded by its subscript:



    A[i] := [2: 4.0, 5: 3.0, 6: -4.0] ;

    ProdCost[plant, machine, product] := [

          p1,  m11,  A1,  73.30,
          p1,  m11,  A2,  52.90,
          p1,  m12,  A3,  65.40,
          p1,  m13,  A3,  47.60,

          p2,  m21,  A1,  79.00,
          p2,  m21,  A3,  66.80,
          p2,  m22,  A2,  52.00,

          p3,  m31,  A1,  75.80,
          p3,  m31,  A3,  50.90,
          p3,  m32,  A1,  79.90,
          p3,  m32,  A2,  52.10,

          p4,  m41,  A1,  82.70,
          p4,  m41,  A2,  63.30,
          p4,  m41,  A3,  53.80];

In most cases when you have larger data sets the data itself is normally not specified in the actual model file but instead either is stored in an external datafile or a database table. See Chapter 7.5 Reading Data from External Datafiles and Chapter 7.6 Import Data from Database for further information.

MPL also allows you to separately specify whether the data will be stored sparse or dense in memory, independently of how it is defined in the model. Simply put either of the keywords DENSE or SPARSE in front of the section keyword DATA.


Back To Top | Maximal Home Page | Table of Contents | Previous Page | Next Page