Initializing help system before first use

Defining, posting and propagating linear constraints


Type: Programming
Rating: 1 (simple)
Description: Posting and propagating linear constraints
File(s): linctr.mos


linctr.mos
(!****************************************************************
   CP example problems
   ===================
   
   file linctr.mos
   ```````````````
   Posting and propagating linear constraints.

   (c) 2008 Artelys S.A. and Fair Isaac Corporation
       Creation: 2005, rev. Mar. 2013
*****************************************************************!)
model "Linear constraints"
 uses "kalis"

 declarations
  N = 3
  R = 1..N
  x: array(R) of cpvar
  c1: cpctr
 end-declarations  

 forall(i in R) do
  0 <= x(i); x(i) <= 50
  setname(x(i), "x"+i)
 end-do

! Automated post+propagation
 x(1) >= x(3) + 5
 writeln(x(1), " ", x(3))
 
! Named constraint (explicit post)
 c1:= x(3) >= x(2) + 10 
 
 if cp_post(c1) then
  writeln("With constraint c1: ", x)
 else exit(1)
 end-if            

! Stop automated propagation
 setparam("kalis_auto_propagate", false)

! Automated post w/o propagation
 x(2) >= 10
 writeln("new bound for x2: ", x) 
 if cp_propagate then
  writeln("after propagation: ", x) 
 end-if

! Minimize the value of x(1) 
 if cp_minimize(x(1)) then
  write("Solution: ")
  forall(i in R) write(getsol(x(i)), " ")
  writeln  
 end-if
end-model

© 2001-2019 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.