In many systems, you will want to create and manipulate elements that represent collections of data, rather than individual items. For example, you may want to create an element that represents your company's revenue for each of the last five years, or an element that represents the salmon population in each of 20 streams.
One way to do this, of course, would be to create separate elements for each object you wanted to model (e.g., five elements representing revenue, 20 elements representing salmon populations).
Such an approach, however, is not desirable for two reasons:
• It could require you to create a very large number of elements (e.g., if you wanted revenues for the past 25 years or wanted to evaluate salmon populations in 200 streams). This could result in very large, cluttered models.
• Usually, you will want to carry out the same types of calculations and operations on all related objects in such a collection (e.g., multiply all revenues by 2, compute the number of salmon eggs this year for all 20 streams based on the current salmon population). Having to do this individually for every object in a large collection would be very cumbersome and time-consuming.
To address these kinds of problems, GoldSim allows you to create and manipulate vectors and matrices (collectively referred to as arrays). For example, you could create a vector element that represented the salmon populations in each of a number of streams:
You could also create a matrix element that represented the salmon population in each of streams over a period of three years:
In addition to adding data in the form of vectors and matrices, you can manipulate these arrays in equations. For example, you could create an Expression element, and define it as:
2 * Salmon_Population
The output of the Expression would be an array, identical to the Salmon_Population array, except each item of the array would be two times greater.
If you did not use arrays to carry out this calculation, rather than creating 2 elements, you would need to create 40 elements (20 Data elements and 20 Expression elements) to accomplish the same thing!
Vectors and matrices are applicable to almost any kind of system, and you will likely want to take advantage of this feature in most of your models.
An example model which uses vectors and matrices within different elements (Arrays.gsm) can be found in the General Examples folder in your GoldSim directory (accessed by selecting File | Open Example... from the main menu). In addition, ArrayTimeSeries.gsm (in the Time Series subfolder of General Examples) includes examples of how Time Series elements can be used to generate arrays.
The following topics describe how you can create and use vectors and matrices in your models.
Learn more about:
Defining Vectors and Matrices Using Data Elements
Defining Vectors Using Stochastic Elements
Defining Arrays in Input Fields Using Array Constructor Functions
Using a Vector as a Lookup Table