Check if a given entry in a dynamic array has been created.
function exists(x):boolean
Array reference (e.g. t(1))
Return value
true if the entry exists, false otherwise.
The following, a dynamic array of decision variables only has its even elements created, which is checked by displaying the existing variables:
 x: dynamic array(S) of mpvar

forall(i in S| not isodd(i)) create(x(i)) 
forall(i in S| exists(x(i)))
 writeln("x(", i, ") exists")
Further information
1. If an array is declared dynamic (or indexed by a dynamic set) its elements are not created at its declaration. This function indicates if a given element has been created.
2. Under certain conditions, the exists function call is optimized by the compiler when used for filtering an aggregate operator: the loop is only performed for the existing entries instead of enumerating all possible tuples of indices for finding the relevant ones.
Related topics
Section Aggregate operators, create,create.

If you have any comments or suggestions about these pages, please send mail to support@fico.com.

© Copyright 2001-2013 Fair Isaac Corporation. All rights reserved.