Skip to main content

 

equivalent sparse data and list data

Today I got a question to turn a sparse table into a row of lists, as illustrated above.
As you can see, the data is the same, just presented differently.

To transform the left representation to the right, it helps to work with an indexed set:
 

A list has positions 1 up to max size of the list; which is no more than there are columns:


With that we can declare the essence of the list structure as:


There are two ways to fill the data, first a more explicit one:

As you can see, this requires two references to the indexed set, the first one to limit the elements visited, and the second one to get the position of i_col within the indexed set.

By binding the index i_col not to the set s_cols, but directly to the indexed set is_colElems(i_row), the transformation becomes more compact.

Once the essence is constructed, we can copy the values, and create a string parameter to present the data actually in list format:







 

 

Be the first to reply!

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator