Initializing help system before first use

All-different constraint: solving an assignment problem


Type: Assignment
Rating: 1 (simple)
Description: Assigning time slots to persons subject to some additional bound constraints.
File(s): alldiff.mos


alldiff.mos
(!****************************************************************
   CP example problems
   ===================
   
   file alldiff.mos
   ````````````````
   all_different constraints.

   (c) 2008 Artelys S.A. and Fair Isaac Corporation
       Creation: 2005
*****************************************************************!)
model "all_different example"
 uses "kalis"

 declarations  
  PEOPLE = {"Sebastian", "Frederic", "Jan-Georg",
            "Krzysztof","Maarten","Luca"}  ! Set of speakers  
  x: array(PEOPLE) of cpvar                ! Time slot per person    
 end-declarations

 3 <= x("Sebastian") ; x("Sebastian") <= 6
 3 <= x("Frederic")  ;  x("Frederic") <= 4
 2 <= x("Jan-Georg") ; x("Jan-Georg") <= 5
 2 <= x("Krzysztof") ; x("Krzysztof") <= 4
 3 <= x("Maarten")   ;   x("Maarten") <= 4
 1 <= x("Luca")      ;      x("Luca") <= 6

! A different time slot for every person
 all_different(x)

! Solve the problem
 if not(cp_find_next_sol) then
  writeln("Problem is infeasible")
  exit(1)
 end-if 

! Solution printout 
 writeln(x)

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.