Initializing help system before first use

exists

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

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 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

© 2001-2022 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.