| |||||||||

Generic binary and n-ary constraints Description Implementation of user-defined constraints:
- ac2001.mos: Generic binary constraint
- gac2001.mos: Generic n-ary constraints
Further explanation of this example:
'Xpress Kalis Reference Manual'
Source Files ac2001.mos (!**************************************************************** CP example problems =================== file ac2001.mos ``````````````` Generic binary constraints. (c) 2008 Artelys S.A. and Fair Isaac Corporation Creation: 2005, rev. Sep. 2018 *****************************************************************!) model "generic_binary_constraint example" uses "kalis" forward public function truth_value(v1:integer, v2:integer): boolean declarations V1 : cpvar V2 : cpvar c : integer end-declarations c := 4 0 <= V1 ; V1 <= 10 0 <= V2 ; V2 <= 5 ! Define and post the user constraint generic_binary_constraint(V1, V2, "truth_value") ! Search for all solutions and print them out while (cp_find_next_sol) writeln("A solution has been found with V1 = ", getsol(V1), " and V2 = ", getsol(V2) ) ! Implementation of the user constraint public function truth_value(v1:integer, v2:integer): boolean returned := (v1 = v2 mod c) end-function end-model | |||||||||

© Copyright 2021 Fair Isaac Corporation. |