Initializing help system before first use

element

Purpose
This constraint states that a variable z is the x th element of an ordered list of integer V, in its ternary form it states that z is the [x,y]-th element of a matrix of integers M
Synopsis
element(x+I) = C
element(V,x{,I}) = C
element(V,x{,I}) = z with x,z cpvar and I integer
z = element(V,x{,I}) with x,z cpvar and I integer
element(M,x,y) = z with x,y,z cpvar
z = element(M,x,y) with x,y,z cpvar
Arguments
a constant integer value
the value variable
first index variable
second index variable
optional constant offset for index
a one-dimensional array of integer values
a matrix (two-dimensional array) of integers
Return value
An element constraint over z, x and y in the ternary form, over x and z in the binary form
Example
The following example shows how to use the element constraint:
model "Element"
 uses "kalis"

 declarations
  RY = 43..52
  RX = 1..2
  D: array(RY) of integer
  D2: array(RX,RY) of integer
  x,y,d_of_y,d_of_x_y: cpvar
 end-declarations

 D :: (43..52)[ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9]

 D2:: (1..2,43..52)[10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
                    20, 21, 22, 23, 24, 25, 26, 27, 28, 29]

 setname(x, "x")
 setname(y, "y")
 setname(d_of_y, "d_of_y")
 setname(d_of_x_y, "d_of_x_y")

 writeln("Original domains: ", x, y, d_of_y, d_of_x_y)

 element(D,y) = d_of_y
 element(D2,x,y) = d_of_x_y

 writeln("After propagation: ", x, y, d_of_y, d_of_x_y)

! Solve the problem
 while (cp_find_next_sol) do
  nbSolutions += 1
  writeln("Solution ", nbSolutions, ": x:", getsol(x),
	  " y:", getsol(y), " d_of_y:", getsol(d_of_y),
	  " d_of_x_y:", getsol(d_of_x_y)) 	
 end-do
 writeln("done!")

end-model



© 2001-2024 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.