distribute
function distribute(vars:array of cpvar, values:set of integer, bound:array(integer) of integer) : cpctr
 function distribute(vars:array of cpvar, values:set of integer, lowerBound:array(integer) of integer, upperBound:array(integer) of integer) : cpctr
 function distribute(vars:set of cpvar,vals:set of integer, lowerBound:array(integer) of integer, upperBound:array(integer) of integer) : cpctr
 function distribute(vars:cpvarlist, vals:set of integer, lowerBound:array(integer) of integer, upperBound:array(integer) of integer) : cpctr
 | 
     vars 
     | 
     Array/set/list of variables
     | 
| 
     values 
     | 
     Set of values represented by their names
     | 
| 
     lowerBound 
     | 
     Array of lower bounds on occurrences
     | 
| 
     upperBound 
     | 
     Array of upper bounds on occurrences
     | 
| 
     bound 
     | 
     Array of occurrence values
     | 
model "Distribute example"
 uses "kalis"
 declarations
  PERS = {"David","Andrew","Leslie","Jason","Oliver","Michael",
          "Jane","Marilyn"}          ! Set of personnel
  LOC = 1..4                         ! Set of locations
  REQ: array(LOC) of integer         ! No. of pers. req. per loc.
  place: array(PERS) of cpvar        ! Workplace for each peson
 end-declarations
! Initialize data
 REQ:: [3, 2, 2, 1]
! Each variable has a lower bound of 1 (Ticket office) and
!  an upper bound of 4 (Cloakroom)
 forall(p in PERS) do
  setname(place(p), "workplace("+p+")")
  1 <= place(p); place(p) <= 4
 end-do
! Creation of a resource constraint of for every location
 forall(d in LOC) occurrence(d, place) = REQ(d)
! Elegant way to declare theses constraints,
! moreover achieving stronger prunning (using global
! cardinality constraint)
 distribute(place, LOC, REQ)
! Solve the problem
 if not cp_find_next_sol then
  writeln("Problem is infeasible")
  exit(1)
 end-if
! Solution printout
 writeln(place)
end-model
 © 2001-2023 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.
 
