Toggle navigation
Navigation
Analytica Docs home
Functions by category
Contents of User Guide
Recent changes
Help on wiki editing
Lumina site
Buy or upgrade Analytica
This page
Special page
Tools
Special pages
Login
Export translations
Settings
Group
ADE Server Class Reference
ADE User Guide
CAEngine
CAEngine::AddModule
CAEngine::CloseModel
CAEngine::Command
CAEngine::CreateModel
CAEngine::CreateObject
CAEngine::CurrentModule
CAEngine::DefaultDefTableRenderingStyle
CAEngine::DefaultEvaluationTimeLimit
CAEngine::DefaultRenderingStyle
CAEngine::DeleteObject
CAEngine::ErrorCode
CAEngine::ErrorText
CAEngine::Flags
CAEngine::GetObjectByName
CAEngine::Log
CAEngine::MonitorProcess
CAEngine::OpenModel
CAEngine::OutputBuffer
CAEngine::ReadScript
CAEngine::ResetError
CAEngine::SaveModel
CAEngine::SaveModuleFile
CAEngine::Send
CAEngine::SendCommand
CAEngine::SetCallbackObject
CAIndex
CAIndex::GetNumberByValue
CAIndex::GetValueByNumber
CAIndex::IndexElements
CAIndex::Name
CAIndex::RenderingStyle
CALicense
CALicense::CanUseOptimizer
CALicense::ErrorCode
CALicense::ErrorText
CALicense::MaxLicenseInstances
CALicense::NewCAEngine
CALicense::RlmHostId
CALicense::RlmPath
CALicense::RlmUserId
CALicense::SetApplicationLicenseCode
CAObject
CAObject::ClassType
CAObject::CreateDefTable
CAObject::DefinitionType
CAObject::DefTable
CAObject::Evaluate
CAObject::GetAttribute
CAObject::MethodEvaluationTimeLimit
CAObject::Name
CAObject::PictureToFile
CAObject::PictureToStream
CAObject::RenderingStyle
CAObject::Result
CAObject::ResultTable
CAObject::ResultType
CAObject::SetAttribute
CARenderingStyle
CARenderingStyle::FullPrecision
CARenderingStyle::GeneralExpression
CARenderingStyle::NewLineAsCRLF
CARenderingStyle::NullValue
CARenderingStyle::NumberAsText
CARenderingStyle::ReferenceAsText
CARenderingStyle::SafeArrayLowerBound
CARenderingStyle::StringQuotes
CARenderingStyle::UndefValue
CATable
CATable::AtomicValue
CATable::GetDataByElements
CATable::GetDataByLabels
CATable::GetIndexObject
CATable::GetSafeArray
CATable::GraphHeight
CATable::GraphToFile
CATable::GraphToStream
CATable::GraphWidth
CATable::GraphWithStoredPivot
CATable::IndexName
CATable::IndexNames
CATable::Name
CATable::NumDims
CATable::ObtainTable
CATable::PutSafeArray
CATable::ResultType
CATable::SetDataByElements
CATable::SetDataByLabels
CATable::SetIndexOrder
CATable::Slice
CATable::Subscript
CATable::TableType
CATable::Update
IAdeUICallbacks
IAdeUICallbacks::AskMsgChoice
IAdeUICallbacks::AskMsgComboBox
IAdeUICallbacks::AskMsgNumber
IAdeUICallbacks::AskMsgText
IAdeUICallbacks::FileOpenCompleted
IAdeUICallbacks::GetFilename
IAdeUICallbacks::HideProgressBar
IAdeUICallbacks::MsgBox
IAdeUICallbacks::OpenURL
IAdeUICallbacks::ShowPdfFile
IAdeUICallbacks::ShowProgressBar
Installation of ADE
Introduction to ADE
The ADE Tutorial
TranslateTest
Tutorial: Arrays
User:Karenlee
Using the ADE Server
Working with Models, Modules, and Files in ADE
Tutorial: Arrays
Language
aa - Afar
ab - Abkhazian
abs - Ambonese Malay
ace - Achinese
ady - Adyghe
ady-cyrl - Adyghe (Cyrillic script)
aeb - Tunisian Arabic
aeb-arab - Tunisian Arabic (Arabic script)
aeb-latn - Tunisian Arabic (Latin script)
af - Afrikaans
ak - Akan
aln - Gheg Albanian
alt - Southern Altai
am - Amharic
ami - Amis
an - Aragonese
ang - Old English
anp - Angika
ar - Arabic
arc - Aramaic
arn - Mapuche
arq - Algerian Arabic
ary - Moroccan Arabic
arz - Egyptian Arabic
as - Assamese
ase - American Sign Language
ast - Asturian
atj - Atikamekw
av - Avaric
avk - Kotava
awa - Awadhi
ay - Aymara
az - Azerbaijani
azb - South Azerbaijani
ba - Bashkir
ban - Balinese
bar - Bavarian
bbc - Batak Toba
bbc-latn - Batak Toba (Latin script)
bcc - Southern Balochi
bcl - Central Bikol
be - Belarusian
be-tarask - Belarusian (Taraškievica orthography)
bg - Bulgarian
bgn - Western Balochi
bh - Bhojpuri
bho - Bhojpuri
bi - Bislama
bjn - Banjar
bm - Bambara
bn - Bangla
bo - Tibetan
bpy - Bishnupriya
bqi - Bakhtiari
br - Breton
brh - Brahui
bs - Bosnian
btm - Batak Mandailing
bto - Iriga Bicolano
bug - Buginese
bxr - Russia Buriat
ca - Catalan
cbk-zam - Chavacano
cdo - Min Dong Chinese
ce - Chechen
ceb - Cebuano
ch - Chamorro
cho - Choctaw
chr - Cherokee
chy - Cheyenne
ckb - Central Kurdish
co - Corsican
cps - Capiznon
cr - Cree
crh - Crimean Turkish
crh-cyrl - Crimean Tatar (Cyrillic script)
crh-latn - Crimean Tatar (Latin script)
cs - Czech
csb - Kashubian
cu - Church Slavic
cv - Chuvash
cy - Welsh
da - Danish
de - German
de-at - Austrian German
de-ch - Swiss High German
de-formal - German (formal address)
din - Dinka
diq - Zazaki
dsb - Lower Sorbian
dtp - Central Dusun
dty - Doteli
dv - Divehi
dz - Dzongkha
ee - Ewe
egl - Emilian
el - Greek
eml - Emiliano-Romagnolo
en - English
en-ca - Canadian English
en-gb - British English
eo - Esperanto
es - Spanish
es-419 - Latin American Spanish
es-formal - español (formal)
et - Estonian
eu - Basque
ext - Extremaduran
fa - Persian
ff - Fulah
fi - Finnish
fit - Tornedalen Finnish
fj - Fijian
fo - Faroese
fr - French
frc - Cajun French
frp - Arpitan
frr - Northern Frisian
fur - Friulian
fy - Western Frisian
ga - Irish
gag - Gagauz
gan - Gan Chinese
gan-hans - Gan (Simplified)
gan-hant - Gan (Traditional)
gcr - Guianan Creole
gd - Scottish Gaelic
gl - Galician
glk - Gilaki
gn - Guarani
gom - Goan Konkani
gom-deva - Goan Konkani (Devanagari script)
gom-latn - Goan Konkani (Latin script)
gor - Gorontalo
got - Gothic
grc - Ancient Greek
gsw - Swiss German
gu - Gujarati
gv - Manx
ha - Hausa
hak - Hakka Chinese
haw - Hawaiian
he - Hebrew
hi - Hindi
hif - Fiji Hindi
hif-latn - Fiji Hindi (Latin script)
hil - Hiligaynon
ho - Hiri Motu
hr - Croatian
hrx - Hunsrik
hsb - Upper Sorbian
ht - Haitian Creole
hu - Hungarian
hu-formal - magyar (formal)
hy - Armenian
hyw - Western Armenian
hz - Herero
ia - Interlingua
id - Indonesian
ie - Interlingue
ig - Igbo
ii - Sichuan Yi
ik - Inupiaq
ike-cans - Eastern Canadian (Aboriginal syllabics)
ike-latn - Eastern Canadian (Latin script)
ilo - Iloko
inh - Ingush
io - Ido
is - Icelandic
it - Italian
iu - Inuktitut
ja - Japanese
jam - Jamaican Creole English
jbo - Lojban
jut - Jutish
jv - Javanese
ka - Georgian
kaa - Kara-Kalpak
kab - Kabyle
kbd - Kabardian
kbd-cyrl - Kabardian (Cyrillic script)
kbp - Kabiye
kg - Kongo
khw - Khowar
ki - Kikuyu
kiu - Kirmanjki
kj - Kuanyama
kjp - Eastern Pwo
kk - Kazakh
kk-arab - Kazakh (Arabic script)
kk-cn - Kazakh (China)
kk-cyrl - Kazakh (Cyrillic script)
kk-kz - Kazakh (Kazakhstan)
kk-latn - Kazakh (Latin script)
kk-tr - Kazakh (Turkey)
kl - Kalaallisut
km - Khmer
kn - Kannada
ko - Korean
ko-kp - Korean (North Korea)
koi - Komi-Permyak
kr - Kanuri
krc - Karachay-Balkar
kri - Krio
krj - Kinaray-a
krl - Karelian
ks - Kashmiri
ks-arab - Kashmiri (Arabic script)
ks-deva - Kashmiri (Devanagari script)
ksh - Colognian
ku - Kurdish
ku-arab - Kurdish (Arabic script)
ku-latn - Kurdish (Latin script)
kum - Kumyk
kv - Komi
kw - Cornish
ky - Kyrgyz
la - Latin
lad - Ladino
lb - Luxembourgish
lbe - Lak
lez - Lezghian
lfn - Lingua Franca Nova
lg - Ganda
li - Limburgish
lij - Ligurian
liv - Livonian
lki - Laki
lld - Ladin
lmo - Lombard
ln - Lingala
lo - Lao
loz - Lozi
lrc - Northern Luri
lt - Lithuanian
ltg - Latgalian
lus - Mizo
luz - Southern Luri
lv - Latvian
lzh - Literary Chinese
lzz - Laz
mai - Maithili
map-bms - Basa Banyumasan
mdf - Moksha
mg - Malagasy
mh - Marshallese
mhr - Eastern Mari
mi - Maori
min - Minangkabau
mk - Macedonian
ml - Malayalam
mn - Mongolian
mni - Manipuri
mnw - Mon
mo - Moldovan
mr - Marathi
mrj - Western Mari
ms - Malay
mt - Maltese
mus - Muscogee
mwl - Mirandese
my - Burmese
myv - Erzya
mzn - Mazanderani
na - Nauru
nah - Nāhuatl
nan - Min Nan Chinese
nap - Neapolitan
nb - Norwegian Bokmål
nds - Low German
nds-nl - Low Saxon
ne - Nepali
new - Newari
ng - Ndonga
niu - Niuean
nl - Dutch
nl-informal - Nederlands (informeel)
nn - Norwegian Nynorsk
no - Norwegian
nov - Novial
nqo - N’Ko
nrm - Norman
nso - Northern Sotho
nv - Navajo
ny - Nyanja
nys - Nyungar
oc - Occitan
olo - Livvi-Karelian
om - Oromo
or - Odia
os - Ossetic
pa - Punjabi
pag - Pangasinan
pam - Pampanga
pap - Papiamento
pcd - Picard
pdc - Pennsylvania German
pdt - Plautdietsch
pfl - Palatine German
pi - Pali
pih - Norfuk / Pitkern
pl - Polish
pms - Piedmontese
pnb - Western Punjabi
pnt - Pontic
prg - Prussian
ps - Pashto
pt - Portuguese
pt-br - Brazilian Portuguese
qqq - Message documentation
qu - Quechua
qug - Chimborazo Highland Quichua
rgn - Romagnol
rif - Riffian
rm - Romansh
rmy - Vlax Romani
rn - Rundi
ro - Romanian
roa-tara - Tarantino
ru - Russian
rue - Rusyn
rup - Aromanian
ruq - Megleno-Romanian
ruq-cyrl - Megleno-Romanian (Cyrillic script)
ruq-latn - Megleno-Romanian (Latin script)
rw - Kinyarwanda
sa - Sanskrit
sah - Sakha
sat - Santali
sc - Sardinian
scn - Sicilian
sco - Scots
sd - Sindhi
sdc - Sassarese Sardinian
sdh - Southern Kurdish
se - Northern Sami
sei - Seri
ses - Koyraboro Senni
sg - Sango
sgs - Samogitian
sh - Serbo-Croatian
shi - Tachelhit
shi-latn - Tachelhit (Latin script)
shi-tfng - Tachelhit (Tifinagh script)
shn - Shan
shy-latn - Shawiya (Latin script)
si - Sinhala
simple - Simple English
sk - Slovak
skr - Saraiki
skr-arab - Saraiki (Arabic script)
sl - Slovenian
sli - Lower Silesian
sm - Samoan
sma - Southern Sami
smn - Inari Sami
sn - Shona
so - Somali
sq - Albanian
sr - Serbian
sr-ec - Serbian (Cyrillic script)
sr-el - Serbian (Latin script)
srn - Sranan Tongo
ss - Swati
st - Southern Sotho
stq - Saterland Frisian
sty - себертатар
su - Sundanese
sv - Swedish
sw - Swahili
szl - Silesian
szy - Sakizaya
ta - Tamil
tay - Tayal
tcy - Tulu
te - Telugu
tet - Tetum
tg - Tajik
tg-cyrl - Tajik (Cyrillic script)
tg-latn - Tajik (Latin script)
th - Thai
ti - Tigrinya
tk - Turkmen
tl - Tagalog
tly - Talysh
tn - Tswana
to - Tongan
tpi - Tok Pisin
tr - Turkish
tru - Turoyo
trv - Taroko
ts - Tsonga
tt - Tatar
tt-cyrl - Tatar (Cyrillic script)
tt-latn - Tatar (Latin script)
tum - Tumbuka
tw - Twi
ty - Tahitian
tyv - Tuvinian
tzm - Central Atlas Tamazight
udm - Udmurt
ug - Uyghur
ug-arab - Uyghur (Arabic script)
ug-latn - Uyghur (Latin script)
uk - Ukrainian
ur - Urdu
uz - Uzbek
uz-cyrl - Uzbek (Cyrillic script)
uz-latn - Uzbek (Latin script)
ve - Venda
vec - Venetian
vep - Veps
vi - Vietnamese
vls - West Flemish
vmf - Main-Franconian
vo - Volapük
vot - Votic
vro - Võro
wa - Walloon
war - Waray
wo - Wolof
wuu - Wu Chinese
xal - Kalmyk
xh - Xhosa
xmf - Mingrelian
xsy - Saisiyat
yi - Yiddish
yo - Yoruba
yue - Cantonese
za - Zhuang
zea - Zeelandic
zgh - Standard Moroccan Tamazight
zh - Chinese
zh-cn - Chinese (China)
zh-hans - Simplified Chinese
zh-hant - Traditional Chinese
zh-hk - Chinese (Hong Kong)
zh-mo - Chinese (Macau)
zh-my - Chinese (Malaysia)
zh-sg - Chinese (Singapore)
zh-tw - Chinese (Taiwan)
zu - Zulu
en - English
Format
Export for off-line translation
Export in native format
Fetch
{{DISPLAYTITLE:Tutorial: Arrays}}[[Category:Analytica Tutorial]] <breadcrumbs>Analytica Tutorial > {{PAGENAME}}</breadcrumbs> {{ReleaseBar}} This section (page) introduces you to [[Intelligent Arrays]], which is source of much of Analytica's power and flexibility. An array is a table of values, with one, two, or more dimensions. Even if you often skip tutorials, you may find it valuable to go through this section, because Analytica arrays have some unique aspects different from other modeling tools and computer languages. And it's essential to understand the basics of arrays before you can use Analytica effectively. <div style="column-count:2;-moz-column-count:2;-webkit-column-count:2"> __TOC__ </div> 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 values 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]]() In the previous chapter you defined a single variable, '''Miles per gallon''', as a list of values. 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 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|Intelligent arrays]] allow you to scale your model without making any changes to the design. This section covers lots of ground. The example model is simple, but demonstrates many important array concepts. The approach is streamlined so you can learn the key ideas with-out getting bogged down with procedural details. You should already be familiar with the basic mechanics of Analytica‘s user interface, and know how to: * Create a new model; Open an existing model; Save; Save As... (See [[Tutorial: Open a model to browse]]) * Create and define new variables; Enter attributes in [[Attribute panel|Attribute]] or [[Object window]]s; Draw influence arrows between nodes. (See [[Tutorial: Create a model]]) ==Summarize variables using Expression syntax== You will need to know how to enter definitions directly as [[Expression Syntax|Expressions]]. 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. For example, this summarizes the '''Car cost '''model from the previous section: :<code>Variable MPY := 12K</code> :<code>Variable MPG := Sequence(20, 50, 5)</code> :<code>Variable Fuel_price := 3</code> :<code>Variable Fuel_cost := MPY*Fuel_price/MPG</code> We summarize new variables in this form in this section. It is also widely used throughout the [[Analytica Wiki|Wiki]]: * The first term indicates the [[Class]] of the object being defined. Classes include '''Decision, Variable, Chance, Objective, Module, Index, Constant ''' and '''Function'''. * The second termis the [[Identifier]] for the object. (Identifiers may not contain spaces.) * <code>:=</code>) sometimes known as the [[Assignment Operator :=|assignment operator]]. * The definition is an expression, which could be a number, function call, probability distribution, table, or other expression. It may refer to other variables (the "Inputs" of this variable. You could even copy the expression directly into the Definition of a variable or function. The expressions are marked as <code><nowiki><code></nowiki></code>. ==Fast Tony’s Generic Wheels== In this chapter you extend the '''Car cost '''model to address an important decision scenario: the purchase of a new car. There are three cars to choose from: '''''Standard''''', '''''SUV '''''and '''''Hybrid'''''. There are also three finance options: '''''Cash purchase''''', '''''Lease''''', or '''''Loan'''''. Fast Tony has presented you with an array of decision possibilities, a 3 x 3 array to be exact. Your objective is to determine the option with the lowest total cash outflow over a 24-month period, including fuel. (Maintenance costs are covered under warranty as long as Fast Tony’s cousin, Greasy Tony, is on his feet that day.) Ownership equity will be represented as a positive cash flow on the last period. ==Continue with model== In this chapter, you will continue with the model you developed in [[Tutorial: Create a model]]. The model from the end of [[Tutorial: Create a model]] can be found in the '''Tutorial Models''' directory. Select '''Open''' on the '''File''' menu. {{CalloutAnnotationBlock|[[Image:Chapter_5.1-updated.png]]| {{CalloutAnnotation|Press the ''Example Models'' button.''|n=1|pt=43,95|v=20}} {{CalloutAnnotation|Enter the '''Tutorial Models''' folder.|n=+|v=120}} {{CalloutAnnotation|Open model from [[Tutorial%3A_Create_a_model#Saving_your_model_2|end of Chapter 4]].|pt=117,79|path=R10|n=+|v=220}} }} ==Create an index variable== Index variables define the categories along a dimension of an array. They are represented by index nodes (parallelogram shapes) in the [[influence diagram]]. In this example, your decision will be arrayed by '''Car type''' and '''Finance Option''' so you will need to define an index for each of these dimensions. Index variables are generally defined as a ''list of labels'' or a ''list of values'' representing categories in the array. (For the finance options you will leave out "Loan" for now. It will be added later.) :<code>Index Car_type := ['Standard', 'SUV', 'Hybrid']</code> :<code>Index Finance_option := ['Purchase', 'Lease']</code> {{Release||4.6| :[[File:Chapter_5.2-updated.png]] }}{{Release|5.0|| {{CalloutAnnotationBlock|[[Image:TutChap5CreateIndexes.png]]|{{ CalloutAnnotation|For each of the index nodes listed above, do the following:|v=0|style=border:none;}}{{ CalloutAnnotation|Choose the Edit tool|n=1|path=-|pt=249,27|v=70}}{{ CalloutAnnotation|Drag the Index icon down to the diagram|n=+|path=/|pt=503,27|v=120}}{{ CalloutAnnotation|Enter a title for the node|n=+|v=190}}{{ CalloutAnnotation|Open the definition field and select '''List of text''' from the expression popup menu|n=+|v=270|pt=324,525|path=/}}{{ CalloutAnnotation|Enter labels as shown|n=+|v=400|pt=12,509}} }}<!--5.0-->}} {{#tag:tip|As an alternative to selecting '''''{{Release||4.6|List of Labels}}{{Release|5.0||List of Text}}''''' in [[the Expression popup menu]], you can select '''Expression''' and enter the definition directly using [[Expression Syntax|Expression syntax]]. Simply list the values separated by commas and encase them in square brackets <code>[ ]</code>. Note that all text values in Expression syntax must be enclosed in quotes (single or double).}} ==Defining a variable as a table== Each of the cars has a unique purchase price. You will define '''Car price''' as a '''''Table''''' indexed by '''Car type'''. In this context, a "table" does not necessarily have two dimensions. It can have one (as in this case), two, three or more. :<code>Variable Car_price := Table(Car_type)(22K, 40K, 24K)</code> {{CalloutAnnotationBlock|[[Image:Chapter_5.3-updated.png]]|{{ CalloutAnnotation|Create a new variable titled '''Car price'''.|n=1|v=20|pt=76,87}}{{ CalloutAnnotation|Open the Definition field, then open the Expression popup menu. Select '''''Table'''''.|n=+|v=100|pt=326,400|path=R70!}}{{ CalloutAnnotation|The [[Indexes dialog]] appears. Select the '''Car type''' index and click the transfer button to move it to the selected indexes list. Click '''OK'''.|n=+|v=220|pt=486,160}} }} After you close the [[Indexes dialog]] an [[Edit table]] will appear. Enter the following values for ''Car price'': :Standard: ''''22K'''' :SUV: '''''40K'''' :Hybrid: ''''24K'''' {{CalloutAnnotationBlock|[[File:Chapter_5.4-updated.png]]|{{ CalloutAnnotation|Click the index button if you want to go back to the [[Indexes dialog]].|v=0|pt=12,38}}{{ CalloutAnnotation|Index categories appear as table headings.|v=78|pt=10,134}}{{ CalloutAnnotation|Press '''Tab''' or '''Shift+Tab''' to move through the cells.|v=160|pt=122,161|path=-}} }} <tip> You can draw influence arrows from index nodes to table variables to pre-populate the [[Indexes dialog]] with the chosen indexes. Influence arrows from index nodes are invisible by default but can be made visible by choosing the [[Diagram menu]] and selecting '''''Set diagram style'''''. </tip> Next you will create a variable for lease payments. Fast Tony lists the following monthly payments for the two-year lease option: :Standard: ''''$400'''' :SUV: '''''$700'''' :Hybrid: ''''$500'''' '''Lease Payment''' is similar to the '''Car price''' variable. But this time you will enter the [[definition]] directly using [[Expression Syntax|expression syntax]] instead of using the [[edit table]]. :<code>Variable Lease_payment := [[Table]](Car_type)(400, 700, 500)</code> {{CalloutAnnotationBlock|[[Image:Chapter_5.5-updated.png]]|{{ CalloutAnnotation|Create a new variable titled '''Lease payment'''|n=+|v=0|pt=220,87}}{{ CalloutAnnotation|Open the definition field and select [[image:exprExpression_menu_item.png]] from the Expression popup menu. (This will not change the definition of an existing variable.)|n=+|v=75|pt=407,183|path=-}}{{ CalloutAnnotation|Enter the definition directly as shown|n=+|v=250|pt=113,214}} }} As you can see, [[Table]] definitions follow a specific syntax. The '''Table '''declaration is followed by two lists enclosed in parentheses. The first list contains the indexes by which the table will be arrayed. (In this simple example there is only one index but there can be many.) The second list contains the values. '''It is important for the values to be in the same order as the index categories.''' Recall that the Car type index was defined as: :<code>Index Car_type := ['Standard', 'SUV', 'Hybrid']</code> which matches the respective order of values in the '''Lease payment '''variable. The same principle applies when there is more than one index. For example, a two dimensional array might look like: :[[Table]] (Index_abc, Index_123) ::('a1', 'a2', 'a3', 'b1', 'b2', 'b3', 'c1', 'c2', 'c3') It is generally easier to use an [[edit table]] when multiple dimensions are involved. Finally, re-define the existing '''Miles per gallon '''variable as a table indexed by '''Car type'''. The MPG values for Standard, SUV and Hybrid are 28, 23, and 45 respectively. :<code>Variable Mpg := Table(Car_type)(28, 23, 45)</code> Select the '''Miles per gallon '''variable. Open the Definition field and select [[File:Chapter_5.6-updated.png]] from [[the Expression popup menu]]. Enter the new [[definition]] as shown above. ==Combine arrays== Now that you have established purchase and lease payments, you can combine them in one variable. This time the index will be '''Finance Option'''. :<code>Variable Payments := [[Table]] (Finance_option)(Car_price, Lease_payment)</code> Create a new variable titled '''Payments'''. Open the definition field and select '''''Table''''' from the [[Expression popup menu]]. The [[Indexes dialog]] appears. Select the Finance option index and transfer it to selected indexes list. Click '''OK'''. An edit table will appear. {{CalloutAnnotationBlock|[[Image:Chapter_5.7-updated.png]]|{{ CalloutAnnotation|Ingrese '''''Car_price''''' junto a '''Purchase'''|v=0|pt=138,116|n=1}}{{ CalloutAnnotation|Ingrese '''''Lease_payment''''' junto a '''Lease'''|n=+|v=60|pt=97,134}}{{ CalloutAnnotation|Toca [[image:GreenCheck.png]]|n=+|v=140|pt=15,87}} }} You may have noticed an important difference between this table and the previous tables. In the previous tables you entered number values into the table cells, but this time you are entering expressions! Expressions are valid entries for table cells. With very few exceptions they can be as complex as anything you might enter in a standard definition line, including formulas, logical expressions and conditional expressions. You will see more examples of this later in the chapter. Now look at the result of this new variable. Select the '''Payments''' variable and click the '''Results''' button ([[File:Chapter_4.54-updated.png]]) Something interesting has happened! Notice that the array contains two dimensions even though only one index is called out in the definition of the array: :<code>Variable Payments := [[Table]] (Finance_option)(Car_price, Lease_payment)</code> Why is '''Car type''' included in the result when '''Finance_option''' is the only index included in the definition of the table? The '''Car type''' index is included because it is an index of the input variables '''Car price''' and '''Lease payment'''. You have just encountered one of the most powerful features of Analytica’s array abstraction: The dimensions of arrayed input variables will automatically be incorporated into the resulting output of an expression. The general principle of array abstraction can be summarized as follows: '''In Analytica, the result of an expression is arrayed by the ''union'' set of dimensions from all input variables, and the definition of the expression itself.''' ==Add a dimension to an array== So far, the Payments variable is not very useful for comparing the purchase and lease options. Lease payments are paid every month instead of just once, and there is still ownership equity to consider. In order to represent payments as a stream of cash flows over time, you will need to add a new dimension to the Payments array: Create and define a new index titled Period. Define it as a sequence of months from 0 to 24. :<code>Index Period := [[Sequence]](0, 24)</code> <tip> There is a special shortcut syntax for sequences that have a step value of one: Type the starting value, followed by two periods (..), followed by the final value. For example, the '''Period''' index can be defined as: <code>Index Period := 0..24</code> </tip> Next, you will edit the '''Payments''' definition to include the new index. Try using the edit table for this: {{CalloutAnnotationBlock|[[Image:Chapter_5.8-updated.png]]|{{ CalloutAnnotation|Select the '''Payments''' variable and open the definition field.|n=1|v=50|pt=189,175|path=r(240,103)mbD20/}}{{ CalloutAnnotation|Click the '''''Edit Table''''' button.|n=+|v=180|pt=16,197}} }} There is a button in the top left corner of the edit table, labeled with a parallelogram. Click this button to open the Indexes window. Then add '''Period''' to the list of selected indexes. {{CalloutAnnotationBlock|[[File:Chapter_5.9-updated.png]]|{{ CalloutAnnotation|Click the ''Index button'' in the top-left corner of the edit table.|n=+|v=30|pt=22,41}}{{ CalloutAnnotation|Select the '''Period''' index and add it to the Selected Indexes list.|n=+|v=130|pt=400,123|path=rR15(*,185)(400,185)(278,130)m(400,185)(488,114)m(400,185)}}{{ CalloutAnnotation|Note: By default, Analytica will copy current values to all new slices along the added index.|v=230|pt=216,265}} }} The edit table should now look like this: {{CalloutAnnotationBlock|[[File:Chapter_5.10-updated.png]]|{{ CalloutAnnotation|The '''Period''' index has been added to the '''Payments''' array.|v=0}}{{ CalloutAnnotation|Change vertical and horizontal indexes if necessary to pivot the table as shown.|n=+|v=90|path=(45,89)(67,59)m(45,89)|pt=86,80}} }} The subset of an array corresponding to a singe index value is referred to as a [[slice]]. When you expanded the '''Payments''' array to include a new index, the original values (expressions in this case) were copied into all new slices along the '''Period''' index. The '''Payments''' array is not yet accurate. Under the Purchase column you should have zero values for all periods except Period 0. Lease payments should be included in periods 1 through 24 but not Period 0. It would not take too much effort to edit all the cells to be the way you want them to be. The final definition of the array would look something like this: :[[File:Chapter_5.11-updated.png]] Although this would work, it would not be a very efficient approach. In general, whenever you find yourself editing tables in the same way you would edit a spreadsheet, you are not benefiting from the advantages of array abstraction. ==Use conditional expressions== Expressions can include conditional statements using If...then...else syntax. The condition can be based on a variable or an index value. This is a very useful way of defining array variables. For example, the cash flow for purchasers can be represented as: :<code>[[If]] Period = 0 [[Then]] Car_price [[Else]] 0</code> Likewise, the cash flow for lease holders can be represented as: :<code>[[If]] Period = 0 [[Then]] 0 [[Else]] Lease_payment</code> Specifying a condition based on '''Period''' will automatically add the '''Period''' index to the array. This would have been a better way to add a new dimension to the '''Payments''' variable, compared to the example above. Let’s revert the Payments variable to the way it was before adding the Period index: :<code>Variable Payments := [[Table]](Finance_option)(Car_price, Lease_payment)</code> As you did in the section above, Select the '''Payments''' variable, open the edit table, and click the Index button in the top left corner. Select the '''Period''' index in the Selected Indexes list and transfer it back to left hand box. Click '''OK'''. Answer '''Yes''' when the warning appears: :[[File:Chapter_5.12-updated.png]] {{CalloutAnnotationBlock|[[File:Chapter_5.7-updated.png]]|{{ CalloutAnnotation|The edit table should be back to its original one-dimensional form.|v=5}} }} This time you will add the '''Period''' index by including it in a conditional expression. Edit the cells to include conditional expressions: :<code>Variable Payments := [[Table]](Finance_option)</code> :::<code>([[If]] Period = 0 [[Then]] Car_price [[Else]] 0,</code> :::<code> [[If]] Period = 0 [[Then]] 0 [[Else]] Lease_payment)</code> {{CalloutAnnotationBlock|[[File:Chapter_5.14-updated.png]]|{{ CalloutAnnotation|Enter conditional expressions in the edit table cells as shown.|v=5}} }} Let’s take a step back to consider how many indexes are now included in the '''Payments '''array: * '''Finance_option '''is called out specifically as a table index * '''Period '''is the basis for a condition statement within an expression * '''Car_type '''is an index of the '''Car price '''and '''Lease payment '''input variables. Therefore, you can expect that '''Payments '''will be a three-dimensional array. Conditional expressions can have nested [[If-Then-Else]] statements. In fact, it would be possible to define the '''Payments '''array using only one conditional expression: :<code>Variable Payments :=</code> ::<code>[[If]] Finance_Option = 'Purchase' [[Then]]</code> ::<code> [[If]] Period = 0 [[Then]] Car_price [[Else]] 0</code> ::<code>[[Else]] [[If]] Period = 0 [[Then]] 0</code> ::<code>[[Else]] Lease_payment</code> Esto sería equivalente a la definición de tabla anterior. Las declaraciones lógicas también se pueden utilizar para especificar una condición. Están entre paréntesis e incluyen un signo igual. Cuando se usa en una expresión matemática, una declaración lógica asume un valor de uno si es verdadero, o cero si es falso. Por ejemplo: :<code>24*(2 + 2 = 4) → 24</code> :<code>24*(2 + 2 = 5) → 0</code> Hence another equivalent to the previous table definition is :<code>[[If]] Finance_Option = 'Purchase' [[Then]] (Period=0) * Car_price</code> :<code>[[Else]] (Period>0) * Lease_payment</code> ==View the results of a multi-dimensional array== Representing a multi-dimensional array on a two-dimensional screen presents a challenge. When viewing results in tabular form, Analytica will display only a two-dimensional slice of the data. You can change the orientation and selection of data by ''pivoting ''the table. To do this, select the desired row and column indexes from the row and column pop-up menus. Any leftover indexes become ''slicer indexes ''for which only slice of data (corresponding to a single index value) can be displayed at a time. Seleccione la variable Pagos y haga clic en el botón Resultados ([[File:Chapter_4.54-updated.png]]). Seleccione el botón de vista de tabla ([[File:Chapter_4.58-updated.png]]). You can experiment by selecting different row and column indexes, and by changing the value of the slicer index. {{CalloutAnnotationBlock|[[File:Chapter_5.15-updated.png]]{{ CalloutAnnotation|The slicer menu button displays a pop-up menu of all slicer index values.|v=5|style=left:385px;|pt=104,54|path=lmU15-}}{{ CalloutAnnotation|Slicer steppers change the value of the slicer index sequentially.|v=100|style=left:385px;|pt=231,58|path=l}}|{{ CalloutAnnotation|The row index pop-up menu selects the index of rows.|v=20|pt=47,79}}{{ CalloutAnnotation|The column index pop-up selects the index of columns.|v=100|pt=78,100}} }} Now click on the graph view button ([[File:Chapter_4.56-updated.png]]) The vertical axis of the graph represents data values. The graph indexes can be pivoted to select the desired horizontal axis, key, and slicer index. You can experiment with various graph configurations and slicer values. {{CalloutAnnotationBlock|[[File:Chapter_5.16-updated.png]]|{{ CalloutAnnotation|The graph displays data for only one value of the slicer index.|v=20|pt=110,58}}{{ CalloutAnnotation|The Horizontal Axis pop-up menu selects the index for the horizontal axis.|v=140|pt=146,241|path=rmU20(195,80)mrmD20}} {{ CalloutAnnotation|Key index categories are divided by color.|v=275|pt=131,302}} }} <tip> You can explore various chart types and options by selecting '''''Graph Setup'''''... from the [[Result menu]]. For more details about graphs reference [[Tutorial: Reviewing a model]]. </tip> ==Add a new value to an index== Fast Tony’s loan financing terms require 10% down and 2% of the purchase price per month for 60 months. His financing manager, Big Anthony, explains that at a 12% nominal interest rate (1% per month compounded monthly), the load will be paid off in 60 months. There are severe penal- ties for delinquency but none of them are expressed in dollar values. One of the advantages of ''intelligent arrays ''is that they are easily expandable. So far, you have set up cash flows for purchasers and lease holders. Adding a third financing option is a simple matter of adding a new value to the '''Finance option '''index. :<code>Index Finance_option := ['Purchase','Lease','Loan']</code> Select the '''''Finance option '''''index and open the [[Definition]] field. Select '''''{{Release||4.6|List of Labels}}{{Release|5.0||List of Text}}'''''from the [[Expression popup menu]]. You will see a list of current values in the definition field. Select the bottom value ('''Lease''') and press the '''down-arrow '''key. A new box appears at the bottom of the list. By default the previous label is copied down. Change the new value to '''''Loan'''''. {{CalloutAnnotationBlock|<br><br>[[Image:Chapter_5.17-updated.png]]|{{ CalloutAnnotation|Select '''{{Release||4.6|List of Labels}}{{Release|5.0||List of Text}}''' from the Expression pop-up menu.|n=1|v=0|pt=336,80|path=/}}{{ CalloutAnnotation|Select the bottom category and press ''Enter''.|n=+|v=85|pt=15,71}}{{ CalloutAnnotation|Enter '''Loan''' as the new value.|n=+|v=170|pt=33,94|path=-}} }} Now select the Payments variable and click the Results button ([[File:Chapter_4.54-updated.png]]). A new column appears with zero values by default. {{CalloutAnnotationBlock|[[File:Chapter_5.18-updated.png]]{{ CalloutAnnotation|A new column appears for '''Loan'''.|v=30|style=left:400px;|pt=245,113|path=l-}}|{{ CalloutAnnotation|Click the table view button.|n=+|v=30|pt=11,56}}{{ CalloutAnnotation|Pivot the table as shown.|n=+|v=120}} }} Now you will need to add an expression for loan payments in the edit table: :<code>Car_price*(If Period = 0 then 10% else 2%)</code> Select the '''Payments''' variable. Open the Definition field, then click the '''''Edit table''''' button. {{CalloutAnnotationBlock|[[File:Chapter 5.19-updated.png]]|{{ CalloutAnnotation|Enter the new expression for Loan payments as show.|n=+|pt=100,151}} }} Recall that the input variable '''Car price''' is indexed by '''Car type'''. Therefore, your new expression will be evaluated separately for the Standard car, the SUV and the Hybrid. The new expression also references the '''Period''' index, so it will be evaluated separately for each period as well. {{CalloutAnnotationBlock|[[File:Chapter 5.20-updated.png]]|{{ CalloutAnnotation|Loan payments have been added for all values of '''Car type''' and '''Period'''.|v=50|pt=238,142}} }} ==Using local values and indexes in an expression== Now that you have established all the cash outflows, you can start thinking about how much ownership equity you will have at the end of the 24-month period. Unavoidably you will need to calculate the remaining loan balance at that time. The financial dynamics of a typical loan include compound interest offset by fixed payment amounts. Although the formula for loan balances can be derived fairly easily, this section will focus on how to apply the formula rather than explaining the formula itself. Readers are invited to verify on their own if they wish: Assuming that a constant amount is paid and nominal interest is compounded every month: :<code>B0</code> = Starting balance of the loan :<code>12%</code> = Nominal interest rate :<code>60</code> = The total number of periods required to pay off the loan :<code>Period</code> = A number from 0 to 24 representing the current period :<code>B(Period)</code> = The remaining loan balance for the current period :Let <code>A = (1 + 12% / 12)</code> :<code>B(Period) = B0 * (A^60 - A^Period) / (A^60 - 1)</code> It is easy to verify that <code>B(0) = B0</code> and <code>B(60)=0</code> as required. The quantity <code>A</code> appears several times in this formula so it makes sense to define it as an intermediate variable. To do the same thing in Analytica, you could define a new variable called <code>A</code> and use it as an input to the loan balance variable. But this would clutter your diagram with an unnecessary node. Analytica allows ''local'' values and indexes to be used temporarily within a definition. In this case you will define a local identifier. Create a new variable titled '''Loan balance''' and enter the following definition: :<code>Variable Loan_balance :=</code> ::<code>{{Local}} A := (1 + 12%/12);</code> ::<code>Car_price(1 - 10%) (A^60 - A^Period)/(A^60 - 1)</code> Syntax rules for local objects are as follows: * The instruction line starts with <code>{{Local}}</code> or <code>{{LocalIndex}}</code> to declare a local value or index. * The declaration is followed by an identifier. This can be anything you choose but it must not be identical to any other input contained in the expression. * The ''assignment operator'' <code>:=</code> comes next (colon followed by an equal sign), followed by an expression defining the object. * A semicolon (<code>;</code>) is required to end the instruction line. You may choose to have a visual break (Enter key) after the semicolon for appearance purposes but this is optional. Analytica only looks at semicolons to mark line breaks in code. Each local identifier declaration must be on a separate code line. * The final line of instruction contains the definition as usual. All declared local values and indexes will be available to use in expressions. Local variables are used temporarily and then forgotten after the expression is evaluated. Therefore, the same local identifier (i.e. <code>A</code>) can be used in any number of nodes without conflict. :[[File:Chapter_5.21-updated.png]] A final note about the expression for '''Loan Balance''': Although '''Period '''is an index, you have used it here as a variable in a mathematical expression. This is possible because '''Period '''is a list of numerical values. It would not have been possible to use '''Car type '''or '''Finance option '''in a mathematical formula since they are lists of labels (although they could be used in logical or conditional statements). In general, you can think of an index as a one-dimensional array that uses its own values as an index. By the principles of array abstraction, you should expect '''Loan Balance '''to be a two-dimensional array indexed by '''Car type '''(an index of '''Car price''') and '''Period'''. :[[File:Chapter_5.22-updated.png]] <tip> The Future Value function [[Fv]] is a convenient way to calculate loan balances and annuity values without using formulas. Arguments in order are: Interest rate per period, Future period, Payments (negative for payouts), Initial value. For example, '''Loan Balance''' could be defined as: <code>[[Fv]](1%, Period, -Car_price*2%, Car_price*90%)</code> See [[Financial functions]] in the [[Analytica User Guide]]. </tip> ==Reduce an array using subscripts== Sometimes you may want to reference part of an array variable without using all of its available indexes. [[Subscript]]s allow you to reference a [[slice]] of an array, effectively eliminating one or more dimensions. The [[subscript]] specifies indexes and their desired values for the slice. It is enclosed in square brackets placed immediately after the identifier for the array. For example: The subscript has reduced a two-dimensional array to a one-dimensional array :<code>Variable Final_period_balance := Loan_balance[Period = 24]</code> This refers only to the '''Loan Balance '''values that correspond to Period 24. Recall that '''Loan Balance '''is a two-dimensional array indexed by '''Period '''and '''Car Type'''. The subscripted reference above will eliminate the '''Period '''dimension and return a one-dimensional array indexed only by '''Car_type'''. :[[File:Chapter_5.23-updated.png]] It is possible to eliminate multiple dimensions by including multiple indexes in the [[subscript]], separated by commas. For example: :<code>Variable Final_period_balance := Loan_balance[Period = 24, Car_type = 'SUV']</code> The result of this expression will be a single value corresponding to the loan balance at Period 24 for the SUV: 24.11K An Index value can also be selected according to its position in the index rather than the actual value. To make a positional reference, place the "at" symbol (cat) in front of the index identifier. For example, 'SUV' is second in the order of values for the '''Car type '''index. The following [[subscript]] references are equivalent: :<code>Loan_balance[Car_type = 'SUV']</code> :<code>Loan_balance[@Car_type = 2]</code> The verbal terminology for this reference would be: "'''Loan_balance '''[[slice]]d at position of '''Car_type '''equal to 2". ==Complete cash flows== Now you can add a variable to represent the amount of ownership equity you will have after 24 months. Of course this will depend on the finance option. Assume that the value of every car depreciates by 35% over two years. * Cash purchasers’ equity will be: '''Car_price (1 - 35%)''' * Lease holders’ equity will be zero * Loaners’ equity will be the difference between car value and the loan balance at Period 24: '''Car_price (1 - 35%) - Loan_balance<nowiki>[Period =</nowiki> 24]''' The '''Equity '''variable has only two dimensions: '''Car type '''and '''Finance option'''. It refers to a single slice of the '''Period '''index. You can define the '''Equity '''variable as a table indexed by '''Finance option'''. Each of the expressions above can be entered into the appropriate cell in the edit table: :<code>Variable Equity := Table(Finance_option)</code> :<code>(Car_price*(1 - 35%), 0, (Car_price*(1 - 35%) - Loan_balance[Period = 24]))</code> Alternatively, you can use [[If-Then-Else|conditional]] and [[Logical Operators|logical]] statements as follows: :<code>Variable Equity := If Finance_option = 'Lease' then 0 else</code> :<code>Car_price*(1 - 35%) - (Finance_option = 'Loan')*Loan_balance[Period = 24]</code> Once again, consider how many dimensions your new variable will have. At first you might be tempted to list the indexes as follows: :'''Finance option '''(Specified as a table index or used in a conditional expression) :'''Car type '''(Index of the input variables '''Car price '''and '''Loan balance''') :'''Period '''(Index of the input variable '''Loan balance''') But '''Loan balance '''is not an input to this expression; only a [[slice]] of it is used. The slice is arrayed only by '''Car type'''. Therefore, the Equity variable will be indexed by '''Finance option '''and '''Car type '''but not by '''Period'''. :[[File:Chapter_5.24-updated.png]] ==Combine dissimilar arrays== Now that you have established payments and ownership equity, you can combine them into a single cash flow variable. '''Payments '''will be represented as negative cash flows. '''Equity '''will be represented as a positive cash flow on the last period. Create a new variable titled '''Cash flow '''and enter the following definition: :<code>Variable Cash_flow := If Period = 24 then Equity - Payments else -Payments</code> In this expression you have combined arrays with different numbers of dimensions: :'''Payments '''is indexed by '''Car type''', '''Finance option '''and '''Period. :Equity '''is indexed only by '''Car type '''and '''Finance option'''. There is no ambiguity here since '''(Equity - Payments) '''applies to a [[slice]] along the '''Period''' index. The slice is called out in the conditional statement. Notice that '''Equity '''and '''Payments[Period = 24] '''have the same dimensions. There are other situations where you may want to use a scalar variable (not an array) as an input to an array. Similarly, you may want use an array as an input to another array that has more dimensions. In this situation Analytica will repeat the values of the smaller array for each [[slice]] along the new dimensions. For example, suppose you want to incorporate monthly fuel cost into the '''Cash flow '''variable. Here again you are combining two dissimilar arrays: :'''Cash flow '''is indexed by '''Car type''', '''Finance option '''and '''Period''' :'''Fuel cost '''is indexed only by '''Car type''' Create a new variable titled '''Cash flow with fuel '''and define it as follows: :<code>Variable Cash_flow_with_fuel :=</code> :<code>If Period = 0 then Cash_flow else Cash_flow - Fuel_cost/12</code> In this example, '''Fuel cost '''is applied to multiple slices along new dimensions: * All '''Period '''values except Period 0 * All three '''Finance option '''categories. Select '''Cash_flow_with_fuel '''and click the Results button ([[File:Chapter_4.54-updated.png]]) You will notice "Totals" check boxes next to the row and column index pop-up menus. Checking the box next to '''Period '''will allow you to see totals along that index. :[[File:Chapter_5.25-updated.png]] ==Array-Reducing Functions== A function that reduces one or more indexes of an array is referred to as an [[Array-reducing functions|array reducing function]]. The output of an array reducing function will have fewer dimensions than the input array. For example, the following expression will determine the sum of cash flows over all periods: :<code>Variable Total_cash_flow := Sum(Cash_flow_with_fuel, Period)</code> The input array is indexed by '''Car type''', '''Finance option '''and '''Period'''. The output will be a two- dimensional array indexed by '''Car type '''and '''Finance option'''. In this example the '''Period '''dimension has been reduced. :[[File:Chapter_5.26-updated.png]] * The first argument of the [[Sum]]() function is the identifier of the variable to be operated on. * This is followed by a list of indexes separated by commas. These are the indexes over which the function will operate. In this example you have taken a sum over a single index. Similar examples of [[array-reducing functions]] include [[Max]](), [[Min]](), [[Product]]() and [[Average]](). ==Net Present Value (NPV) analysis== If someone offered you a choice of receiving $100 today or receiving $100 two years from now, which would you choose? If you choose to receive it immediately, you can invest in a low risk bond with an annual return of, say, 6%. In two years the investment will be worth about $112. Clearly these two alternatives do not have equal value. Conversely, you would probably prefer to pay an obligation later rather than sooner. ''Net present value ''([[NPV]]) analysis is a way to compare various scenarios that involve inflows and outflows of money at different time periods. It converts a stream of cash flows to an equivalent scenario where all money is exchanged in a single transaction at the present time. The interest rate that can be achieved in a low risk investment is referred to as the ''discount rate''. For example, given a discount rate of 6%, the NPV of $112 paid two years in the future would be $100. By taking a simple sum of cash flows as in the example above, you have ignored the time value of money. A Net Present Value analysis is more useful in this case. The [[NPV]]() function in Analytica makes this easy. It is another example of an array reducing function. Assume the discount rate is 0.5% per month. Create an objective node titled '''Cash flow NPV'''. (Objective nodes are represented by the hexagon shape on the node palette.) Apply the following definition: :<code>Objective Cash_flow_NPV := NPV(0.5%, Cash_flow_with_fuel, Period)</code> * The first argument of the [[NPV]] function is the discount rate per period. * The second argument is the identifier for the variable containing cash flows. * The third argument is the index containing period values. The analysis is complete! :[[File:Chapter 5.27-updated.png]] ==Summary== In this chapter you have: * Learned [[Expression Syntax|Expression syntax]] * [[Creating an index|Created and defined index ]]variables * Created array variables as tables dimensioned along established indexes * Expanded arrays by adding new indexes * Expanded indexes by adding new index values * Created examples that demonstrate the basic principle of [[Array Abstraction|array abstraction]]: '''The result of an expression is arrayed by the ''union set ''of dimensions from all input variables, and the definition of the expression itself.''' * Used conditional and logical statements within an expression * Established local values in the definition field * Analyzed a multi-dimensional result by pivoting indexes * Reduced array variables using [[subscript]]s * Applied [[array-reducing functions]] to arrays ==See Also== <div style="column-count:2;-moz-column-count:2;-webkit-column-count:2"> * [[Array]] * [[Table]] * [[Creating Arrays (Tables)]] * [[Intelligent Arrays]] * [[Arrays and Indexes]] * [[Indexes and arrays: An introduction]] * [[Creating an index]] * [[Functions that create indexes]] * [[Array-reducing functions]] * [[Array functions]] * [[Array Manipulation Examples and Challenge Problems]] * [[Array Function Example Variables]] * [[Multidimensional array]]s * [[Expression Syntax]] * [[Expressions]] * [[The Expression popup menu]] * [[Class]] * [[Classes of variables and other objects]] * [[Local Values]] * [[Subscript]] * [[Subscript and slice of a subarray]] * [[Identifier]] * [[Modeling Depreciation]] * [[NPV]] * [[Choice menus and Checkboxes in an edit table]] * [[Dynamic Simulation]] * [[Tutorial videos]] * [https://www.youtube.com/watch?v=_8ZaXnEwhoE Intelligent Array Abstraction] (explanatory video on YouTube) * [http://AnalyticaOnline.com/WebinarArchive/2008-01-11-Intro-to-arrays.wmv Intro-to-arrays (Part 1).wmv] (an explanatory video about Analytica arrays and indexes (part 1); requires Windows Media player) * [http://AnalyticaOnline.com/WebinarArchive/2008-01-17-Intro-to-arrays2.wmv Intro-to-arrays (Part 2).wmv] (an explanatory video about Analytica arrays and indexes (part 2); requires Windows Media player) </div> <footer>Tutorial: Create a model/ {{PAGENAME}} / Tutorial: Decision trees</footer>
ADE Server Class Reference
ADE User Guide
CAEngine
CAEngine::AddModule
CAEngine::CloseModel
CAEngine::Command
CAEngine::CreateModel
CAEngine::CreateObject
CAEngine::CurrentModule
CAEngine::DefaultDefTableRenderingStyle
CAEngine::DefaultEvaluationTimeLimit
CAEngine::DefaultRenderingStyle
CAEngine::DeleteObject
CAEngine::ErrorCode
CAEngine::ErrorText
CAEngine::Flags
CAEngine::GetObjectByName
CAEngine::Log
CAEngine::MonitorProcess
CAEngine::OpenModel
CAEngine::OutputBuffer
CAEngine::ReadScript
CAEngine::ResetError
CAEngine::SaveModel
CAEngine::SaveModuleFile
CAEngine::Send
CAEngine::SendCommand
CAEngine::SetCallbackObject
CAIndex
CAIndex::GetNumberByValue
CAIndex::GetValueByNumber
CAIndex::IndexElements
CAIndex::Name
CAIndex::RenderingStyle
CALicense
CALicense::CanUseOptimizer
CALicense::ErrorCode
CALicense::ErrorText
CALicense::MaxLicenseInstances
CALicense::NewCAEngine
CALicense::RlmHostId
CALicense::RlmPath
CALicense::RlmUserId
CALicense::SetApplicationLicenseCode
CAObject
CAObject::ClassType
CAObject::CreateDefTable
CAObject::DefinitionType
CAObject::DefTable
CAObject::Evaluate
CAObject::GetAttribute
CAObject::MethodEvaluationTimeLimit
CAObject::Name
CAObject::PictureToFile
CAObject::PictureToStream
CAObject::RenderingStyle
CAObject::Result
CAObject::ResultTable
CAObject::ResultType
CAObject::SetAttribute
CARenderingStyle
CARenderingStyle::FullPrecision
CARenderingStyle::GeneralExpression
CARenderingStyle::NewLineAsCRLF
CARenderingStyle::NullValue
CARenderingStyle::NumberAsText
CARenderingStyle::ReferenceAsText
CARenderingStyle::SafeArrayLowerBound
CARenderingStyle::StringQuotes
CARenderingStyle::UndefValue
CATable
CATable::AtomicValue
CATable::GetDataByElements
CATable::GetDataByLabels
CATable::GetIndexObject
CATable::GetSafeArray
CATable::GraphHeight
CATable::GraphToFile
CATable::GraphToStream
CATable::GraphWidth
CATable::GraphWithStoredPivot
CATable::IndexName
CATable::IndexNames
CATable::Name
CATable::NumDims
CATable::ObtainTable
CATable::PutSafeArray
CATable::ResultType
CATable::SetDataByElements
CATable::SetDataByLabels
CATable::SetIndexOrder
CATable::Slice
CATable::Subscript
CATable::TableType
CATable::Update
IAdeUICallbacks
IAdeUICallbacks::AskMsgChoice
IAdeUICallbacks::AskMsgComboBox
IAdeUICallbacks::AskMsgNumber
IAdeUICallbacks::AskMsgText
IAdeUICallbacks::FileOpenCompleted
IAdeUICallbacks::GetFilename
IAdeUICallbacks::HideProgressBar
IAdeUICallbacks::MsgBox
IAdeUICallbacks::OpenURL
IAdeUICallbacks::ShowPdfFile
IAdeUICallbacks::ShowProgressBar
Installation of ADE
Introduction to ADE
The ADE Tutorial
TranslateTest
Tutorial: Arrays
User:Karenlee
Using the ADE Server
Working with Models, Modules, and Files in ADE
aa - Afar
ab - Abkhazian
abs - Ambonese Malay
ace - Achinese
ady - Adyghe
ady-cyrl - Adyghe (Cyrillic script)
aeb - Tunisian Arabic
aeb-arab - Tunisian Arabic (Arabic script)
aeb-latn - Tunisian Arabic (Latin script)
af - Afrikaans
ak - Akan
aln - Gheg Albanian
alt - Southern Altai
am - Amharic
ami - Amis
an - Aragonese
ang - Old English
anp - Angika
ar - Arabic
arc - Aramaic
arn - Mapuche
arq - Algerian Arabic
ary - Moroccan Arabic
arz - Egyptian Arabic
as - Assamese
ase - American Sign Language
ast - Asturian
atj - Atikamekw
av - Avaric
avk - Kotava
awa - Awadhi
ay - Aymara
az - Azerbaijani
azb - South Azerbaijani
ba - Bashkir
ban - Balinese
bar - Bavarian
bbc - Batak Toba
bbc-latn - Batak Toba (Latin script)
bcc - Southern Balochi
bcl - Central Bikol
be - Belarusian
be-tarask - Belarusian (Taraškievica orthography)
bg - Bulgarian
bgn - Western Balochi
bh - Bhojpuri
bho - Bhojpuri
bi - Bislama
bjn - Banjar
bm - Bambara
bn - Bangla
bo - Tibetan
bpy - Bishnupriya
bqi - Bakhtiari
br - Breton
brh - Brahui
bs - Bosnian
btm - Batak Mandailing
bto - Iriga Bicolano
bug - Buginese
bxr - Russia Buriat
ca - Catalan
cbk-zam - Chavacano
cdo - Min Dong Chinese
ce - Chechen
ceb - Cebuano
ch - Chamorro
cho - Choctaw
chr - Cherokee
chy - Cheyenne
ckb - Central Kurdish
co - Corsican
cps - Capiznon
cr - Cree
crh - Crimean Turkish
crh-cyrl - Crimean Tatar (Cyrillic script)
crh-latn - Crimean Tatar (Latin script)
cs - Czech
csb - Kashubian
cu - Church Slavic
cv - Chuvash
cy - Welsh
da - Danish
de - German
de-at - Austrian German
de-ch - Swiss High German
de-formal - German (formal address)
din - Dinka
diq - Zazaki
dsb - Lower Sorbian
dtp - Central Dusun
dty - Doteli
dv - Divehi
dz - Dzongkha
ee - Ewe
egl - Emilian
el - Greek
eml - Emiliano-Romagnolo
en - English
en-ca - Canadian English
en-gb - British English
eo - Esperanto
es - Spanish
es-419 - Latin American Spanish
es-formal - español (formal)
et - Estonian
eu - Basque
ext - Extremaduran
fa - Persian
ff - Fulah
fi - Finnish
fit - Tornedalen Finnish
fj - Fijian
fo - Faroese
fr - French
frc - Cajun French
frp - Arpitan
frr - Northern Frisian
fur - Friulian
fy - Western Frisian
ga - Irish
gag - Gagauz
gan - Gan Chinese
gan-hans - Gan (Simplified)
gan-hant - Gan (Traditional)
gcr - Guianan Creole
gd - Scottish Gaelic
gl - Galician
glk - Gilaki
gn - Guarani
gom - Goan Konkani
gom-deva - Goan Konkani (Devanagari script)
gom-latn - Goan Konkani (Latin script)
gor - Gorontalo
got - Gothic
grc - Ancient Greek
gsw - Swiss German
gu - Gujarati
gv - Manx
ha - Hausa
hak - Hakka Chinese
haw - Hawaiian
he - Hebrew
hi - Hindi
hif - Fiji Hindi
hif-latn - Fiji Hindi (Latin script)
hil - Hiligaynon
ho - Hiri Motu
hr - Croatian
hrx - Hunsrik
hsb - Upper Sorbian
ht - Haitian Creole
hu - Hungarian
hu-formal - magyar (formal)
hy - Armenian
hyw - Western Armenian
hz - Herero
ia - Interlingua
id - Indonesian
ie - Interlingue
ig - Igbo
ii - Sichuan Yi
ik - Inupiaq
ike-cans - Eastern Canadian (Aboriginal syllabics)
ike-latn - Eastern Canadian (Latin script)
ilo - Iloko
inh - Ingush
io - Ido
is - Icelandic
it - Italian
iu - Inuktitut
ja - Japanese
jam - Jamaican Creole English
jbo - Lojban
jut - Jutish
jv - Javanese
ka - Georgian
kaa - Kara-Kalpak
kab - Kabyle
kbd - Kabardian
kbd-cyrl - Kabardian (Cyrillic script)
kbp - Kabiye
kg - Kongo
khw - Khowar
ki - Kikuyu
kiu - Kirmanjki
kj - Kuanyama
kjp - Eastern Pwo
kk - Kazakh
kk-arab - Kazakh (Arabic script)
kk-cn - Kazakh (China)
kk-cyrl - Kazakh (Cyrillic script)
kk-kz - Kazakh (Kazakhstan)
kk-latn - Kazakh (Latin script)
kk-tr - Kazakh (Turkey)
kl - Kalaallisut
km - Khmer
kn - Kannada
ko - Korean
ko-kp - Korean (North Korea)
koi - Komi-Permyak
kr - Kanuri
krc - Karachay-Balkar
kri - Krio
krj - Kinaray-a
krl - Karelian
ks - Kashmiri
ks-arab - Kashmiri (Arabic script)
ks-deva - Kashmiri (Devanagari script)
ksh - Colognian
ku - Kurdish
ku-arab - Kurdish (Arabic script)
ku-latn - Kurdish (Latin script)
kum - Kumyk
kv - Komi
kw - Cornish
ky - Kyrgyz
la - Latin
lad - Ladino
lb - Luxembourgish
lbe - Lak
lez - Lezghian
lfn - Lingua Franca Nova
lg - Ganda
li - Limburgish
lij - Ligurian
liv - Livonian
lki - Laki
lld - Ladin
lmo - Lombard
ln - Lingala
lo - Lao
loz - Lozi
lrc - Northern Luri
lt - Lithuanian
ltg - Latgalian
lus - Mizo
luz - Southern Luri
lv - Latvian
lzh - Literary Chinese
lzz - Laz
mai - Maithili
map-bms - Basa Banyumasan
mdf - Moksha
mg - Malagasy
mh - Marshallese
mhr - Eastern Mari
mi - Maori
min - Minangkabau
mk - Macedonian
ml - Malayalam
mn - Mongolian
mni - Manipuri
mnw - Mon
mo - Moldovan
mr - Marathi
mrj - Western Mari
ms - Malay
mt - Maltese
mus - Muscogee
mwl - Mirandese
my - Burmese
myv - Erzya
mzn - Mazanderani
na - Nauru
nah - Nāhuatl
nan - Min Nan Chinese
nap - Neapolitan
nb - Norwegian Bokmål
nds - Low German
nds-nl - Low Saxon
ne - Nepali
new - Newari
ng - Ndonga
niu - Niuean
nl - Dutch
nl-informal - Nederlands (informeel)
nn - Norwegian Nynorsk
no - Norwegian
nov - Novial
nqo - N’Ko
nrm - Norman
nso - Northern Sotho
nv - Navajo
ny - Nyanja
nys - Nyungar
oc - Occitan
olo - Livvi-Karelian
om - Oromo
or - Odia
os - Ossetic
pa - Punjabi
pag - Pangasinan
pam - Pampanga
pap - Papiamento
pcd - Picard
pdc - Pennsylvania German
pdt - Plautdietsch
pfl - Palatine German
pi - Pali
pih - Norfuk / Pitkern
pl - Polish
pms - Piedmontese
pnb - Western Punjabi
pnt - Pontic
prg - Prussian
ps - Pashto
pt - Portuguese
pt-br - Brazilian Portuguese
qqq - Message documentation
qu - Quechua
qug - Chimborazo Highland Quichua
rgn - Romagnol
rif - Riffian
rm - Romansh
rmy - Vlax Romani
rn - Rundi
ro - Romanian
roa-tara - Tarantino
ru - Russian
rue - Rusyn
rup - Aromanian
ruq - Megleno-Romanian
ruq-cyrl - Megleno-Romanian (Cyrillic script)
ruq-latn - Megleno-Romanian (Latin script)
rw - Kinyarwanda
sa - Sanskrit
sah - Sakha
sat - Santali
sc - Sardinian
scn - Sicilian
sco - Scots
sd - Sindhi
sdc - Sassarese Sardinian
sdh - Southern Kurdish
se - Northern Sami
sei - Seri
ses - Koyraboro Senni
sg - Sango
sgs - Samogitian
sh - Serbo-Croatian
shi - Tachelhit
shi-latn - Tachelhit (Latin script)
shi-tfng - Tachelhit (Tifinagh script)
shn - Shan
shy-latn - Shawiya (Latin script)
si - Sinhala
simple - Simple English
sk - Slovak
skr - Saraiki
skr-arab - Saraiki (Arabic script)
sl - Slovenian
sli - Lower Silesian
sm - Samoan
sma - Southern Sami
smn - Inari Sami
sn - Shona
so - Somali
sq - Albanian
sr - Serbian
sr-ec - Serbian (Cyrillic script)
sr-el - Serbian (Latin script)
srn - Sranan Tongo
ss - Swati
st - Southern Sotho
stq - Saterland Frisian
sty - себертатар
su - Sundanese
sv - Swedish
sw - Swahili
szl - Silesian
szy - Sakizaya
ta - Tamil
tay - Tayal
tcy - Tulu
te - Telugu
tet - Tetum
tg - Tajik
tg-cyrl - Tajik (Cyrillic script)
tg-latn - Tajik (Latin script)
th - Thai
ti - Tigrinya
tk - Turkmen
tl - Tagalog
tly - Talysh
tn - Tswana
to - Tongan
tpi - Tok Pisin
tr - Turkish
tru - Turoyo
trv - Taroko
ts - Tsonga
tt - Tatar
tt-cyrl - Tatar (Cyrillic script)
tt-latn - Tatar (Latin script)
tum - Tumbuka
tw - Twi
ty - Tahitian
tyv - Tuvinian
tzm - Central Atlas Tamazight
udm - Udmurt
ug - Uyghur
ug-arab - Uyghur (Arabic script)
ug-latn - Uyghur (Latin script)
uk - Ukrainian
ur - Urdu
uz - Uzbek
uz-cyrl - Uzbek (Cyrillic script)
uz-latn - Uzbek (Latin script)
ve - Venda
vec - Venetian
vep - Veps
vi - Vietnamese
vls - West Flemish
vmf - Main-Franconian
vo - Volapük
vot - Votic
vro - Võro
wa - Walloon
war - Waray
wo - Wolof
wuu - Wu Chinese
xal - Kalmyk
xh - Xhosa
xmf - Mingrelian
xsy - Saisiyat
yi - Yiddish
yo - Yoruba
yue - Cantonese
za - Zhuang
zea - Zeelandic
zgh - Standard Moroccan Tamazight
zh - Chinese
zh-cn - Chinese (China)
zh-hans - Simplified Chinese
zh-hant - Traditional Chinese
zh-hk - Chinese (Hong Kong)
zh-mo - Chinese (Macau)
zh-my - Chinese (Malaysia)
zh-sg - Chinese (Singapore)
zh-tw - Chinese (Taiwan)
zu - Zulu