Initializing help system before first use

'abs' and 'distance' constraints


Type: Programming
Rating: 1 (simple)
Description: Defining absolute value and distance constraints.
File(s): distance.mos


distance.mos
(!****************************************************************
   CP example problems
   ===================
   
   file distance.mos
   `````````````````
   Abs and distance constraints.

   (c) 2008 Artelys S.A. and Fair Isaac Corporation
       Creation: 2005, rev. Mar. 2013
*****************************************************************!)
model "Distance constraints"
 uses "kalis"
 
 setparam("KALIS_DEFAULT_LB", -50); setparam("KALIS_DEFAULT_UB", 50)

 declarations
  x, y, z: cpvar
  Dist: cpctr
 end-declarations  
  
 setname(x,"x")
 setname(y,"y")
 setname(z,"z")

 abs(x) = y
 writeln("Absolute value of x: ", x,y,z)

 y >= 20
 writeln("Bounding y by 20: ", x,y,z)
  
! abs(y-z) <= 3
! Equivalent version of this constraint:
 distance(y,z) <= 3

 writeln("Max distance betw. y and z: ", x,y,z)
 
 Dist:= distance(x,z) = 5
 
 if(cp_post(Dist)) then
  writeln("Distance between x and z: ", x,y,z) 
 else
  writeln("Problem is infeasible")
 end-if
 
 cp_show_prob

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.