cpnlinctr
cpnlinctr |
Non-linear expressions of decision variables are obtained by applying the operators +, -, *, div, or functions like ln, exp, abs to decision variables and numeric values. The standard priority rules used by Mosel apply to the evaluation order of the arithmetic operators. Brackets may be used in the definition of non-linear expressions to change this order. The following are examples of valid non-linear expressions:
declarations y: cpvar x1,x2,x3,x4,x5: cpfloatvar end-declarations 0.4*x3*x5 + 0.1*x3*x4 >= 10.7 x1^2 = y exp(x3-x4) 2 ln(x5) = 1 (x1*x2^2) div (x4-x3) = 3
X op v with X:cpnlinexp and v:cpfloatvar and op one of =, ≥, ≤
X op r with X:cpnlinexp and r:real and op one of =, ≥, ≤
X op v with X:cpnlinexp and v:cpvar and op one of =, ≥, ≤
X op l with X:cpnlinexp and l:cplinexp and op one of =, ≥, ≤
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-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.