AnsweredAssumed Answered

Arrays with one-to-one links between arrays and another type

Question asked by pmlwd@leeds.ac.uk on Aug 26, 2016
Latest reply on Aug 30, 2016 by pmlwd@leeds.ac.uk

Hi there

 

Does Mosel support data structures that link non-elementary types to other types, such as a whole array to a single real value? At the moment I have an approach that uses a sorted list with entries consisting of arrays and corresponding identifying numbers. Those identifying numbers are used as part of the indexes of arrays that hold the data in which I am interested. This works fine, but I have to look within the sorted list to retrieve the identifying numbers of an array (or determine that an entry for that array does not exist). With a binary search, this isn't too much of a problem with the sizes of my current datasets (and binary searches of course scale well), but a model structure using a sparse array of arrays would be easier for other reasons besides searching time. I attach below some code that fails when attempting to populate A, an array whose index is a set of arrays.

 

Any help or suggestions would be greatly appreciated.

 

model "Test structure"

options noimplicit

 

     declarations

          A=1..3

          B=array(A) of integer

          C:B

          D:set of B

     end-declarations

 

     C(1):=1

     C(2):=2

     C(3):=3

 

     function return_array(b:B):B

          returned:=b

     end-function

 

     D+={return_array(C)}

     finalize(D)

 

     declarations

          E:array(D) of boolean

     end-declarations

 

     ! Without the following line, this runs and the entry E(C) takes the value of false, the default.

      E(C):=true ! Generates the following error (151): Incompatible type for subscript 1 of 'E'.

 

end-model

Outcomes