Arrays
In ProModel AutoCAD® Edition, an array is a matrix of cells containing integer values, real values, or expressions depending on the type of array. Each cell in an array works much like a variable, and a reference to a cell in an array can be used anywhere a variable can be used. A two-dimensional array may be thought of as multiple rows, for which each row has multiple columns (similar to a spreadsheet).
To access information about the Arrays in your model, open the Model Elements panel and navigate to the Arrays tab.
Array Tab Column Descriptions
- Name — A descriptive label to easily identify the array and intended use.
- Dimensions — The number of rows and columns the array. A two-dimensional array may be thought of as multiple rows, for which each row has multiple columns. One-dimensional arrays must be written in the form of a two-dimensional array.
- Type — The kind of data or information (integer, real, or expression) that is stored in all array cells. By default, all cells are initialized to zero. Initializing cells to some other value can be done by importing data from a Microsoft Excel file or by assignment in Initialization Logic.
- Import File — The spreadsheet name from which to initialize the array with data. You may enter either a fully qualified path to your Excel file, or a path relative to the .dwg file. For example, if your Excel file is in the same directory as the .mod file, enter the name of the Excel file. Refer to Import Data into Arrays for more information on importing array data.
- Export File — The spreadsheet name to save the array to at the end of a simulation. You may enter either a fully qualified path to your Excel file, or a path relative to the .dwg file. For example, if your Excel file is in the same directory as the .mod file, enter the name of the Excel file. Refer to Export Arrays to Spreadsheets for more information on exporting array data.
- Disable — Ignore the import file, export file, or both during simulation without deleting the import of export file names from the array record. Select None to use the specified import and export files. Note that this field is populated with None by default when an array is initially defined.
- Data Between Reps — When running multiple replications, you may choose to keep the data in the array from one replication to the next, or to clear (reset) the array values every replication. For example, if you select Keep and run a simulation with three replications, the data in the array at the end of the first replication is kept and used as the second replication begins. If you are using an import file, the file is used to initialize the array for the first replication only and is ignored for subsequent replications.
- Notes — Add descriptive information about the array.
Using Arrays
In the previous image, Array1 is defined as an array with 1 row and 10 columns containing integer values. Array2 is defined as an array with 7 rows and 3 columns of real values. Array3 is defined as an array with 3 rows and 12 columns of expressions.
To reference a particular cell within an array, write the array name followed by the row and column numbers within square brackets. Note that the row number precedes the column number within the brackets. For example, Array1's fourth column is expressed as Array1[1, 4]. Note that even one-dimensional arrays must be written in the two-dimensional form. Similarly, Array2's fourth row and second column is expressed as Array2[4, 2].
Array cell values are assigned in exactly the same way that values are assigned to a variable. For example, assigning the value 18.37 to Array2's second row and third column cell is expressed as Array2[2, 3]=18.37.
Example
Using arrays can simplify a model. Suppose you need to model an assembly line that attaches components to a computer motherboard. Furthermore, you want to track component part usage over time. Without an array, hundreds of individual entities of various types must represent hundreds of individual components. Keeping track of all the components would be very complex, not to mention all attach routings for performing the assembly. Instead of entities, various cells in an array could track the number of each component type used during the simulation.
An array can do the job more efficiently. The initial inventory level for each component can be stored in an external file and imported into the array cells at the simulation start. The first cell might contain the transistor inventory level; the second can contain the capacitor inventory level and so on. When a motherboard arrives at the location adding the components, each cell’s value is decremented according to the number of that component type attached to the motherboard. If each motherboard requires twelve transistors and five capacitors, then every time a motherboard arrives at the location, the array’s first cell is reduced by twelve and the second cell is reduced by five. Thus, the model becomes simplified because it requires fewer entities and less logic.
Import Data into Arrays
When you import data from a Microsoft Excel spreadsheet into an array, ProModel AutoCAD® Edition loads the data from left to right (i.e., within a row), and then from top to bottom (i.e., within a column). The limit to the number of rows and columns your arrays have depends upon the your Excel version, the array type defined (integer, real, expression), and your computer's memory limit and operating system.
Steps to Import Excel Data into an Array
- Go to ProModel > Model Elements > Arrays.
- Select the array record.
- Select the Import File column cell. A list of Import fields to define appears.
- For File, type the Excel file name to use. Alternatively, you may select Browse and navigate to the file.
- For Sheet, type the exact worksheet name within the Excel file containing the data to use.
- For Cell Start, type the data's starting location cell reference. The value stored in this cell occupies the first position (i.e., the first row and first column) in the array. Type the cell reference (e.g., A1), which is the worksheet column letter and row number.
- For Cell End, type the data's ending location cell reference. The value stored in this cell occupies the last position (i.e., the last row and last column) in the array. Type the cell reference (e.g., A10), which is the column letter and row number.
Note: The number of rows and columns to be imported should be no greater than those numbers for the size of the destination array. The data to be imported can be a subset of the full data set in the Excel worksheet.
Import Array Field Descriptions
- File — The Excel file name from which to import data. You may type either a fully qualified path to your Excel file or a path relative to the .dwg file. For example, if your Excel file is in the same directory as the .dwg file, enter the name of the Excel file.
- Sheet — The Excel file worksheet name from which to import the array data.
Note: If your spreadsheet contains only a single data set, ProModel AutoCAD® Edition automatically loads the data into the array. You do not need to define any cell information unless you want to limit the contents of the array to a portion (i.e., a subset) of the import data set. Importing data into an array requires Microsoft Excel 2016.
- Cell Start — The data's starting location cell reference. The value stored in this cell occupies the first position (i.e., the first row and first column) in the array.
- Cell End — The data's ending location cell reference. The value stored in this cell occupies the last position (i.e., the last row and last column) in the array.
Note: This cell's column letter and/or row number must be greater than the Cell Start.
Export Array Data to Spreadsheets
When you export the array contents array to a Microsoft Excel worksheet, ProModel AutoCAD® Edition loads the data into the worksheet from left to right (i.e., within a row), and then from top to bottom (i.e., within a column).
Note: Exporting data from an array to a worksheet requires Microsoft Excel 2016.
Steps to Export Array Contents to a Spreadsheet
- Go to ProModel > Model Elements > Arrays.
- Select the array record.
- Select the Export File column cell. A list of Import fields to define appears.
- For File, type the Excel file name to use. Alternatively, you may select Browse and navigate to the file.
- For Sheet, type the exact worksheet name within the Excel file to use.
- For Cell Start, type the data's starting location cell reference. This cell receives the value stored in the first position (i.e., the first row and first column) of the array. Type the cell reference (e.g., A1), which is the worksheet column letter and row number.
- For Cell End, type the data's ending location cell reference. This cell receives the value stored in the last position (i.e., the last row and last column) of the array. Type the cell reference (e.g., A10), which is the column letter and row number.
Note: The number of rows and columns specified for the worksheet should be the same as those numbers for the array size. All array rows and columns are exported to the Excel worksheet. If you want the data export to occur only after the final replication, select Export after final replication only. Otherwise, the export occurs after each replication.
Export Array Field Descriptions
- File — The Excel file name to export the array data. You may type either a fully qualified path to your Excel file or a path relative to the .dwg file. For example, if your Excel file is in the same directory as the .mod file, enter the name of the Excel file.
- Sheet — The Excel file worksheet name to export the array data.
- Cell Start — The spreadsheet cell to receive the first piece of data.
- Cell End — The spreadsheet cell to receive the last piece of data exported from the array.
Note:
- This cell's column letter and/or the row number must be greater than the Cell Start.
- If you export multiple times to the same spreadsheet, ProModel AutoCAD® Edition overwrites the spreadsheet with new data for each run of the simulation. If you wish to prevent this, you can make a backup of the spreadsheet between each run of the simulation.
- When the simulation is run, the array data is saved to the specified worksheet. If you run multiple scenarios and/or replications, array data from each run is written to a separate, automatically created worksheet in the Excel file.