Initializing help system before first use

One- and two-dimensional 'element' constraints


Type: Programming
Rating: 1 (simple)
Description: Defining one- and two-dimensional 'element' constraints.
File(s): element.mos


element.mos
(!****************************************************************
   CP example problems
   ===================
   
   file element.mos
   ````````````````
   Element constraints.

   (c) 2008 Artelys S.A. and Fair Isaac Corporation
       Creation: 2005, rev. 2007
*****************************************************************!)
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-2020 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.