FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserNext example

Introductory example: constraint handling

Introductory example: scheduling meetings, stated using disequality constraints; default enumeration.
  • meeting.mos: basic version, stating disequality constraints
  • meeting2.mos: Additional constraints, immediate posting of (unnamed) constraints
  • meeting3.mos: Named constraints posted without control of result
  • meeting4.mos: Explicit posting of constraints with 'cp_post' to retrieve the result
Further explanation of this example: 'Xpress Kalis User Guide', Sections 2.1 A first model and 3.1 Constraint handling

Source Files


   CP example problems
   file meeting.mos
   Introductory example.

   (c) 2008 Artelys S.A. and Fair Isaac Corporation

model "Meeting"
 uses "kalis"
  MEETINGS = {'A','B','C','D'}        ! Set of meetings
  TIME = 1..3                         ! Set of time slots
  plan: array(MEETINGS) of cpvar      ! Time slot per meeting

 forall(m in MEETINGS) setdomain(plan(m), TIME)

! Respect incompatibilities
 plan('A') <> plan('B')
 plan('A') <> plan('D')
 plan('B') <> plan('C')
 plan('B') <> plan('D')  

! Solve the problem
 if not(cp_find_next_sol) then
  writeln("Problem is infeasible")

! Solution printing
 forall(m in MEETINGS)
  writeln("Meeting ", m, ": ", getsol(plan(m)))


Back to examples browserNext example