Initializing help system before first use

Non-linear constraints over real-valued decision variables


Type: Programming
Rating: 1 (simple)
Description: Non-linear constraints may be defined over discrete (finite domain) or continuous (floating point interval) variables, or combinations of both.
File(s): nlinctr.mos


nlinctr.mos
(!****************************************************************
   CP example problems
   ===================
   
   file nlinctr.mos
   ````````````````
   Definition and use of non-linear constraints.

   *** This model cannot be run with a Community Licence ***  

   (c) 2008 Artelys S.A. and Fair Isaac Corporation
       Creation: 2005, rev. Mar. 2013
*****************************************************************!)

model "Non-linear constraints" 
 uses "kalis"

 parameters
  PREC =  1e-10 
 end-parameters

! Setting default precision of continuous variables 
 setparam("KALIS_DEFAULT_PRECISION_VALUE", PREC)
 
 declarations
  ISET = 1..8
  x: array(ISET) of cpfloatvar
 end-declarations
 
 ! Setting variable names
 forall(i in ISET) x(i).name:= "x"+i

 ! Setting variable bounds
 forall(i in ISET) do
  x(i) >= -100; x(i) <= 100
 end-do

 ! Defining and posting non-linear constraints
 x(1) + x(2)*(x(1)+x(3)) + x(4)*(x(3)+x(5)) + x(6)*(x(5)+x(7)) - 
   (x(8)*((1/8)-x(7))) = 0
 x(2) + x(3)*(x(1)+x(5)) + x(4)*(x(2)+x(6)) + x(5)*x(7) -
   (x(8)*((2/8)-x(6))) = 0
 x(3)*(1 + x(6)) + x(4)*(x(1)+x(7)) + x(2)*x(5) - 
   (x(8)*((3/8)-x(5))) = 0
 x(4) + x(1)*x(5) + x(2)*x(6) + x(3)*x(7) - (x(8)*((4/8)-x(4))) = 0
 x(5) + x(1)*x(6) + x(2)*x(7) - (x(8)*((5/8)-x(3))) = 0
 x(6) + x(1)*x(7) - (x(8)*((6/8)-x(2))) = 0
 x(7) - (x(8)*((7/8)-x(1))) = 0
 sum(i in ISET) x(i) = -1

 ! Set the enumeration strategy
 cp_set_branching(split_domain(KALIS_WIDEST_DOMAIN, KALIS_MIDDLE_VALUE,
                               x, true, 0))

 ! Find one solution
 if cp_find_next_sol then
  writeln("Solution number 1" ) 
  cp_show_sol
  cp_show_stats
 end-if

end-model


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