• Subject: Lua representation of complex tabular data, for use by simulation
• From: "Laritz, Thomas" <thomas.laritz@...>
• Date: Thu, 21 Aug 2003 16:30:54 -0400

Hi

We are developing a C++ simulation which requires complex tabular (as well as scalar and string) data to be read in at the start of execution. These data are read from files.  We'd like to start using Lua syntax to specify these input files.  However, given the varied nature of the tabular data, it seems that there might be many ways (some better than others) to represent this tabular data using Lua's capabilities.  Can anyone, who has faced this problem, share any techniques, examples or SW?

Of course, we'd like to make the input files easy to read by a human when using an ascii editor, and we'd like to make the interfacing SW (whether it be Lua scripts or C++ code) as simple as possible.

I will further explain by use of an example.  Assume we're tracking average car prices.  We have a 3-dimensional matrix tracking cost vs. Style, Brand and Year.  This may be visualized as an Excel workbook with multiple worksheets, ie:
___________________________________
/__________________________________/ 2000 ...
/__________________________________/ 2001 (Year)
(Style)  /_________________________________ / 2002
Economy | \$8k   \$7k   \$9k     \$7.5k   \$8.2k| 2003
Sedan   | \$15k  \$19k  \$14k    \$17k    \$18k |||||
Luxury  | \$23k  \$28k  \$25k    \$30k    \$29k |||/
Sports  | \$19k  \$24k  \$22k    \$28k    \$32k ||/
SUV     | \$26k  \$28k  \$24k    \$31k    \$30k |/
+----------------------------------+
Ford  GM  Chrysler Toyota  Honda
(Brand)

In this case, the independent variables are style, brand, and year; the dependent variable is cost.

Q) What is the best way to represent this kind of 3-dimensional data in Lua?  (Keep in mind that our we also use 1-D and 2-D tabular data.)

Q) What if we added more dimensions (ie, independent variables), like Color (red/black/blue/etc) and State Sold (FL/MI/WA/etc)?  (Thus, we need tables with up to 5 dimensions.)

Q) What if we wanted to track not only cost, but also fuel efficiency (ie, 2 or more dependent variables)?  Is there some method of combining this data into one table, rather than specifying two separate tables?

Q) What if some data are not present?  For example, what if Toyota did not produce any vehicle prior to the year 2002?  (Note: In our application, specification of 0 for the missing data would not be appropriate.)

Q) What if some of the dependent variables are C-array indices (ie, 0, 1, 2).  Can some default value be assumed for the independent variables in this case?

Tom LaRitz
thomas.laritz@lmco.com
407-356-9227

• Follow-Ups: