# Working with One-Dimensional Arrays

One-dimensional arrays are far simpler to understand than two-dimensional arrays. The simple illustration here shows how to incorporate a one-dimensional arrayed structure into your model. The illustration looks at company with offices in Boston, Chicago, and Los Angeles.

1. Use the Array Editor to define one or more dimensions

Enter the Array Editor through either the Map, Model, or Equation menu. When you do, you'll see a dialog that looks like the one in Figure 11-3. Within the dialog you can create new dimensions. For each dimension, you can define the associated elements. As the annotations within Figure 11-3 suggest, there is great power within the Array Editor dialog.

Figure 11-3 Array Editor Dialog

2. Transform model variables into arrayed variables

Once you have created one or more Dimensions, you can begin to transform model variables into arrayed variables. Note that whenever you transform a stock into an arrayed stock, its attached flows are automatically arrayed for you. In modeling mode, open a stock or converter dialog and check the Array check box. Then, use the pop-up list of dimensions to select the Dimension that you wish to apply to the variable. Figure 11-4 illustrates the process of transforming a reservoir into an arrayed reservoir. The process of transforming converters into arrayed converters is analogous.

Figure 11-4 Transforming a reservoir into an arrayed reservoir

3. Define the equation logic for arrayed variables

To define the equation logic for an arrayed variable, you must engage in two distinct activities. First, you must determine whether you decide whether to apply a single generic equation to all elements within the arrayed variable. Then, you need to click in the equation logic - either a single generic equation or a specific equation for each element of the array. As you'll see, the application of a single generic equation can minimize both the analytic complexity and the creation time associated with defining the equation logic for arrayed variables.

To Apply to All, or Not to Apply to All...That is the question When Apply To All is checked within an equation dialog, you are telling the software to use the same generic equation for all elements within the arrayed variable. For example, imagine that you have an arrayed stock of entitled Animal Population. If Apply To All is checked in the reservoir's dialog, the single number that you enter for the initial value will be used to define the initial value for all the elements in the array. If you type 100 as the initial value, each population within the arrayed variable will have an initial value of 100. Similarly, if the arrayed variable is a flow or converter production, with Required Inputs of Workers and productivity, you could click in the equation Workers * productivity. This equation would be used to define all elements in the arrayed variable. Figure 11-4 (above) illustrated a stock with Apply To All selected.

When Apply to All is checked, you have access to all stock, flow, and converter dialog settings (for example, stock type, non-negative, flow time-stamping, unit conversion, biflow vs. uniflow, 1-D vs 2-D, Dimension Names) should be selected while Apply To All is checked. If Apply To All is unchecked, these options will be become inaccessible.

If you want to create an arrayed graphical function, Apply to All must be checked within the main equation define dialog. Once you have defined the input to the graphical function, click the Become Graph button at the bottom of the dialog. You can then define a single graphical relationship that will be applied to all elements within the Array. (Within the graphical function dialog itself, you can uncheck Apply to All and sketch individual curves for each model element)

When you uncheck the Apply To All box in an arrayed variable's dialog, you must provide a separate definition for each element within the arrayed variable. Use the paging arrows shown in Figure 11-5 to walk through each element in the arrayed variable.

Figure 11-5 Defining Individual Elements Within an Arrayed Variable - Apply to All Not Checked

Clicking in the equation logic Once you have determined whether to use Apply to All option, you are ready to specify the equation logic for the arrayed variable. If you are using constants or have non-arrayed variables on the Required Inputs list or Allowable Inputs list, define each element or use the Inputs just as you would non-arrayed variables. With constants or scalar inputs, defining the equation logic is easy.

When the inputs to your arrayed variable are themselves arrayed variables, clicking in the equation logic is almost as easy. After you click on the input, a secondary dialog will emerge. You'll use this dialog to tell the software which element of the arrayed input to use to define the elements within the arrayed variable. Figure 11-6 shows how to click in the equation logic for an arrayed variable, when Apply To All is checked. Note that in this instance, one generic equation is used to define multiple elements in an appropriate fashion.

Figure 11-6 Defining Logic Using One-Dimensional Arrayed Input Variables - Apply to All Checked

When you uncheck the Apply to All box, you'll need to provide a specific equation for each element within the arrayed variable. Use the paging arrows to navigate through each element in the arrayed variable to enter the unique definition for each. Remember that all Required Inputs must be used to define each element in the arrayed variable. Operations for this process are outlined in Figure 11-7

Figure 11-7 Defining Logic Using One-Dimensional Arrayed Input Variables - Apply to All Not Checked

Figure 11-8 summarizes the options with an arrayed input variable's secondary dialog.

Figure 11-8 Secondary Dialog - One-Dimensional Arrayed Variable