Difference between revisions of "Tutorial: Arrays"

Line 24: Line 24:
  
 
==Summarizing variables using Expression syntax==
 
==Summarizing variables using Expression syntax==
 +
Although Analytica offers a convenient and visually intuitive interface with which to define variables, it is often helpful for users to be able to enter definitions directly using ''Expression syntax''. Every variable type and every functional expression can be represented this way. In addition to its usefulness in building models, expression syntax is a convenient and efficient way to summarize examples in the documentation. This efficiency is evident in the following four-line summary of the '''Car cost '''model from the previous chapter:
  
 +
'''Variable MPY := <span style="color: blue">12K</pre>'''
 +
 +
'''Variable MPG := <span style="color: blue">Sequence(20,50,5)</span>'''
 +
 +
'''Variable Fuel_price := <span style="color: blue">3</span>'''
 +
 +
'''Variable Fuel_cost := <span style="color: blue">MPY*Fuel_price/MPG</span>'''
 +
 +
In order to expedite the process of building the model, we will summarize new variables in this for- mat throughout the rest of this chapter. It is useful to be familiar with Expression syntax since you will also see it in User Guide and Wiki examples:
 +
 +
* The first term indicates the ''Class ''of the object being defined. There is a Class identifier for each type of node found in the node palette. These include: '''Decision, Variable, Chance, Objective, Module, Index, Constant '''and '''Function'''
 +
* The second term contains the ''Identifier ''for the object. (Keep in mind that identifiers are not allowed to contain spaces.)
 +
* A colon followed by a equal sign (''':=''') is referred to as the ''assignment operator''.
 +
* The expression to the right of the assignment operator defines the object. Conveniently, this portion of the summary line exactly matches the syntax that Analytica requires in the definition field. '''In fact, you can copy this directly into Analytica if you wish!''' For your convenience, the portions of the summary line that can be copied into the definition field will be highlighted in <span style="color: blue">blue</span>.
  
 
==See Also==
 
==See Also==

Revision as of 07:59, 1 July 2015

Other languages:
English • ‎español

Analytica Tutorial >

This chapter shows you how to:

  • Create and define an Index
  • Define an array variable as a Table
  • Understand principles of array abstraction when combining arrays in an expression
  • Use conditional expressions and logical values when defining an array
  • Define variables using Expression syntax
  • Use local variables to simplify an expression
  • Analyze a multi-dimensional result by pivoting indexes
  • Reduce an array using subscripts
  • Use array reducing functions such as Sum() and NPV()

This chapter demonstrates Intelligent Arrays, one of the most powerful features of Analytica. An array can be generally defined as a variable to which multiple values are assigned simultaneously. For example, in the previous chapter you assigned a list of values to a single variable, Miles per gallon. This is an example of a simple one-dimensional array. When you defined Fuel cost using the Miles per gallon array variable as an input, it also became an array. This demonstrates the concept of array abstraction. Array variables can be used just like ordinary variables in expressions. Whenever you expand an index of the array to include more values, or even add an entirely new index along a new dimension, all dependent variables downstream will be extended automatically! Intelligent arrays allow you to scale your model without making any changes to the design.

This Chapter is rich in content and covers lots of ground. The example model is still somewhat simplified, but it is chosen to be complex enough to demonstrate as many important array concepts as possible. The workflow will be streamlined to allow you to concentrate on the ideas with-out getting bogged down with procedural details. Therefore, you should already be familiar with the basic mechanics of Analytica‘s user interface.

The prerequisite skills include:

  • Creating a new model; Opening an existing model; Save; Save As... (See Chapter 1)
  • Creating and defining new variables; Entering attributes in Attribute or Object windows; Drawing influence arrows between nodes. (See Chapter 4)

Summarizing variables using Expression syntax

Although Analytica offers a convenient and visually intuitive interface with which to define variables, it is often helpful for users to be able to enter definitions directly using Expression syntax. Every variable type and every functional expression can be represented this way. In addition to its usefulness in building models, expression syntax is a convenient and efficient way to summarize examples in the documentation. This efficiency is evident in the following four-line summary of the Car cost model from the previous chapter:

Variable MPY := 12K

Variable MPG := Sequence(20,50,5)

Variable Fuel_price := 3

Variable Fuel_cost := MPY*Fuel_price/MPG

In order to expedite the process of building the model, we will summarize new variables in this for- mat throughout the rest of this chapter. It is useful to be familiar with Expression syntax since you will also see it in User Guide and Wiki examples:

  • The first term indicates the Class of the object being defined. There is a Class identifier for each type of node found in the node palette. These include: Decision, Variable, Chance, Objective, Module, Index, Constant and Function
  • The second term contains the Identifier for the object. (Keep in mind that identifiers are not allowed to contain spaces.)
  • A colon followed by a equal sign (:=) is referred to as the assignment operator.
  • The expression to the right of the assignment operator defines the object. Conveniently, this portion of the summary line exactly matches the syntax that Analytica requires in the definition field. In fact, you can copy this directly into Analytica if you wish! For your convenience, the portions of the summary line that can be copied into the definition field will be highlighted in blue.

See Also

Tutorial Chapter 4 <- Working with Arrays (Tables) -> Creating the Party Problem Model
Comments


You are not allowed to post comments.