Reference manual

FICO Xpress Optimization
R

Xpress Kalis
Reference Manual
Release 12.6

Last update 7 July, 2017www.fico.com

Make every decision countTM

This material is the confidential, proprietary, and unpublished property of Fair Isaac Corporation. Receipt or possession of thismaterial does not convey rights to divulge, reproduce, use, or allow others to use it without the specific written authorizationof Fair Isaac Corporation and use must conform strictly to the license agreement.
The information in this document is subject to change without notice. If you find any problems in this documentation, please
report them to us in writing. Neither Fair Isaac Corporation nor its affiliates warrant that this documentation is error-free, nor
are there any other warranties with respect to the documentation except as may be provided in the license agreement.
©2005–2017 Fair Isaac Corporation and Artelys SA. All rights reserved. Permission to use this software and its documentationis governed by the software license agreement between the licensee and Fair Isaac Corporation (or its affiliate). Portions of
the program may contain copyright of various authors and may be licensed under certain third-party licenses identified in thesoftware, documentation, or both.
In no event shall Fair Isaac Corporation or its affiliates be liable to any person for direct, indirect, special, incidental, or
consequential damages, including lost profits, arising out of the use of this software and its documentation, even if Fair Isaac
Corporation or its affiliates have been advised of the possibility of such damage. The rights and allocation of risk between thelicensee and Fair Isaac Corporation (or its affiliates) are governed by the respective identified licenses in the software,
documentation, or both.
Fair Isaac Corporation and its affiliates specifically disclaim any warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose. The software and accompanying documentation, if any,
provided hereunder is provided solely to users licensed under the Fair Isaac Software License Agreement. Fair Isaac
Corporation and its affiliates have no obligation to provide maintenance, support, updates, enhancements, or modifications
except as required to licensed users under the Fair Isaac Software License Agreement.
FICO and Fair Isaac are trademarks or registered trademarks of Fair Isaac Corporation in the United States and may be
trademarks or registered trademarks of Fair Isaac Corporation in other countries. Other product and company names herein
may be trademarks of their respective owners.
Xpress Kalis
Deliverable Version: A
Last Revised: 7 July, 2017
Version 12.6

How to Contact the Xpress Team
Information, Sales and Licensing

Product Support

USA, CANADA AND ALL AMERICASEmail: Support@fico.com(Please include ’Xpress’ in the subject line)

Email: XpressSalesUS@fico.com

Telephone:WORLDWIDE
Email: XpressSalesUK@fico.com
Tel: +44 207 940 8718
Fax: +44 870 420 3601
Xpress Optimization, FICO
FICO HouseInternational Square
Starley Way
Birmingham B37 7GN
UK

NORTH AMERICA
Tel (toll free): +1 (877) 4FI-SUPP
Fax: +1 (402) 496-2224
EUROPE, MIDDLE EAST, AFRICA
Tel: +44 (0) 870-420-3777
UK (toll free): 0800-0152-153
South Africa (toll free): 0800-996-153
Fax: +44 (0) 870-420-3778
ASIA-PACIFIC, LATIN AMERICA, CARIBBEAN
Tel: +1 (415) 446-6185
Brazil (toll free): 0800-891-6146

For the latest news and Xpress software and documentation updates, please visit the Xpress website at
http://www.fico.com/xpress or subscribe to our mailing list.

How to Contact Artelys
Artelys SA
Information and Sales: info-kalis@artelys.com
Licensing and Product Support: support-kalis@artelys.com
Tel: +33 1 44 77 89 00
Fax: +33 1 42 96 22 61
12, rue du Quatre Septembre
75002 Paris Cedex
FranceFor the latest news about Kalis, training course programs, and examples, please visit the Artelys website at
http://www.artelys.com.

Contents
1 Introduction
1.1 Contents of this manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Constraint programming overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 What is Xpress Kalis? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.4 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1
1
1
3
3

I

4

Paradigm

2 Decision variables

5

3 Constraints

7

4 Enumeration and search strategy

95 Scheduling
5.1 Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3 Schedule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

14
14
16
17

6 Linear relaxations
6.1 Automatic relaxations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 User defined relaxations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3 Usage of relaxations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.4 Branching with relaxation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.5 A simple hybrid example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

21
21
22
23
24
24

II

28

Reference Manual

7 Constants
KALIS_FORWARD_CHECKING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_GEN_ARC_CONSISTENCY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SLIM_UNREACHED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SLIM_BY_NODES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SLIM_BY_SOLUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SLIM_BY_DEPTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SLIM_BY_TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SLIM_BY_BACKTRACKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_TLIM_UNREACHED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_TLIM_ABS_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_TLIM_REL_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_INPUT_ORDER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MAX_DEGREE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_LARGEST_MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_LARGEST_MAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

29
31
32
32
32
33
33
33
33
34
34
34
35
35
35
36

i

Contents

KALIS_MAXREGRET_LB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MAXREGRET_UB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RANDOM_VARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SDOMDEG_RATIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SMALLEST_DOMAIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SMALLEST_MAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SMALLEST_MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_WIDEST_DOMAIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MAX_TO_MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MIN_TO_MAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MIDDLE_VALUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_NEAREST_VALUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RANDOM_VALUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_COPYRIGHT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_UNARY_RESOURCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DISCRETE_RESOURCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SMALLEST_ECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SMALLEST_EST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SMALLEST_LCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SMALLEST_LST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_LARGEST_ECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_LARGEST_EST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_LARGEST_LCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_LARGEST_LST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_TASK_INPUT_ORDER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_TASK_RANDOM_ORDER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DISJ_INPUT_ORDER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DISJ_PRIORITY_ORDER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_TIMETABLING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_TASK_INTERVALS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DISJUNCTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_EDGE_FINDING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_INITIAL_SOLUTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_OPTIMAL_SOLUTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RESET_PARAMS_ALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RESET_VAR_BOUNDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RESET_VAR_PRECISION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RESET_OPT_PARAMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RESET_SEARCH_PARAMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_TOPNODE_RELAX_SOLVER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_TREENODE_RELAX_SOLVER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_BILEVEL_RELAX_SOLVER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_LINEAR_CONSTRAINTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_NON_LINEAR_CONSTRAINTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_LOGICAL_CONSTRAINTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DISTANCE_CONSTRAINTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_ALL_CONSTRAINTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MINIMIZE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MAXIMIZE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SOLVE_AS_LP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SOLVE_AS_MIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RELAX_PRESOLVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RELAX_RCOSTS_PROPAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RELAX_RELOAD_BASIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RELAX_GLOBAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

36
36
37
37
37
38
38
38
39
39
39
39
40
40
40
40
41
41
41
42
42
42
42
43
43
43
44
44
44
45
45
45
46
46
46
47
47
48
48
48
49
49
49
49
50
50
50
51
51
51
51
52
52
52
52

ii

Contents

KALIS_RELAX_ALGORITHM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RELAX_OPT_TOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RELAX_MIP_REL_STOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_RELAX_MIP_ABS_STOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_PRIMAL_SIMPLEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DUAL_SIMPLEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_BARRIER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_NETWORK_SIMPLEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

53
53
53
53
54
54
54
55

8 Parameters
KALIS_DEFAULT_LB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DEFAULT_UB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_AUTO_PROPAGATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_OPTIMIZE_WITH_RESTART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_NODES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DEPTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SEARCH_LIMIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_TOLERANCE_LIMIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_BACKTRACKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_COMPUTATION_TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MAX_NODES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MAX_SOLUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MAX_DEPTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MAX_BACKTRACKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MAX_COMPUTATION_TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_MAX_NODES_BETWEEN_SOLUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_OPT_ABS_TOLERANCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_OPT_REL_TOLERANCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_CHECK_SOLUTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DEFAULT_CONTINUOUS_LB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DEFAULT_CONTINUOUS_UB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DEFAULT_PRECISION_VALUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DEFAULT_PRECISION_RELATIVITY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DEFAULT_SCHEDULE_HORIZ_MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DEFAULT_SCHEDULE_HORIZ_MAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_DICHOTOMIC_OBJ_SEARCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_USE_3B_CONSISTENCY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_VERBOSE_LEVEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_AUTO_RELAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_THREADS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_NARY_OBJ_SEARCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KALIS_SCHEDULE_ENABLE_SHAVING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

56
57
57
57
58
58
58
58
59
59
59
59
60
60
60
61
61
61
61
62
62
62
63
63
63
63
64
64
64
64
65
65
65

9 Subroutines
9.1 Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
cplinctr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
and . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
equiv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
implies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
cpnlinctr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ln . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
exp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
distance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
abs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

66
66
67
69
70
71
73
75
77
78
79
81

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Informationiii

Contents

all_different . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
maximum_minimum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
occurrence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
generic_binary_constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
generic_nary_constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
distribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
cumulative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
disjunctive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
producer_consumer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
9.2 Constraint parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
getarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
getpriority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
setpriority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
gettag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
settag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
setfirstbranch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
getactivebranch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
9.3 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
getlb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
getub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
getmiddle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
getsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
getval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
is_fixed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
getdegree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
gettarget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
getrand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
getnext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
getprev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
contains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
is_equal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
is_same . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
settarget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
setdomain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
setlb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
setub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
setval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
setprecision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
cp_show_var . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
9.4 Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
cp_post . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
cp_propagate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
cp_find_next_sol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
cp_reset_search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
cp_maximise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
cp_maximize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
cp_minimise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
cp_minimize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
getsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
cp_show_prob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
cp_show_sol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
cp_show_best_sol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
getname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Informationiv

Contents

setname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
cp_shave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
cp_infeas_analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
cp_save_state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
cp_restore_state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
path_order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
cp_local_optimize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
set_sol_as_target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
cp_reset_params . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
set_reversible_attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
setval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
getval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
setelt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
getelt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
getsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
9.5 Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
assign_var . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
assign_and_forbid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
settle_disjunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
probe_assign_var . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
probe_settle_disjunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
split_domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
task_serialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
cp_set_branching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
cp_show_stats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
bs_group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
group_serializer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
gettag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
9.6 Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
cp_set_solution_callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
cp_set_node_callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
cp_set_branch_callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
9.7 Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
is_fixed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
set_task_attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
setduration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
addpredecessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
setpredecessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
addsuccessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
setsuccessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
cp_show_schedule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
getstart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
getend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
getduration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
getconsumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
getrequirement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
getproduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
getprovision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
is_consuming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
is_requiring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
is_producing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
is_providing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
cp_schedule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
getmakespan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
consumes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Informationv

Contents

requires . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
produces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
provides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
set_resource_attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
setcapacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
setmaxavailability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
setminusage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
getcapacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
setsetuptime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
getsetuptime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
is_fixed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
cp_set_schedule_strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
cp_get_default_schedule_strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
resusage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
getassignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
has_assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
setidletimes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
is_idletime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
cp_close_schedule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
9.8 Linear relaxations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
KALIS_LARGEST_REDUCED_COST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
KALIS_NEAREST_RELAXED_VALUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
cp_get_linrelax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
get_linrelax_solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
fix_to_relaxed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
set_verbose_level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
cp_show_relax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
cp_add_linrelax_solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
cp_remove_linrelax_solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
cp_clear_linrelax_solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
generate_cuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
lp_optimize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
set_linrelax_solver_attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
get_indicator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
get_linrelax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
export_prob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
get_reduced_cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
get_relaxed_value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
set_integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288

Appendix289

A Contacting FICO
289
Product support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Product education . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Product documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Sales and maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Related services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
About FICO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Informationvi

Contents

Bibliography

291

Index

292

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Informationvii

C HAPTER 1

Introduction
1.1

Contents of this manualThis reference manual documents version 12.6 of Xpress Kalis.
This document and the software described in this document are furnished under a license or
non-disclosure agreement, and may be used or copied only within the terms of such a license or
non-disclosure agreement.

1.2

Constraint programming overview
Constraint programming (CP) is a software technology becoming more widespread thanks to
many successes whith effective solving of large, real-life, particularly combinatorial, problems. It
provides a powerful technique for different problems such as scheduling, timetabling, resource
allocation, or network configuration.
Research results from different fields (operations research, artificial intelligence, discrete
mathematics, graph theory) are all involved in the core of Constraint Programming packages.
Constraint Programming allows for representing many problems in a way which is very close to anatural language description, thanks to semantic constraints. Benefits are important: fast
prototyping, compact code, easy modification, and good performance. It allows for specifying
powerful decision support systems.
In order to have a quick overview of this technique, here are the basic elements required for a
problem description:
A constraint satisfaction problem (CSP) is defined by:

A set of decision variables V = {x1 , . . . , xn }For each variable, a set (or a range) of possible values called its domainA set of constraints on these variables.

The arity of a constraint corresponds to the number of variables that it involves. For discretevariables, domain values do not have to be consecutive (for example {1, 4, 6, 8}). For continuous
variables, the domain is modelled as an interval.
An interesting notion is the constraint graph:
A CSP can be represented by a non-oriented graph where the edges symbolize the links between
constraints and variables. The Figure 1.1 shows an example of a constraint graph for thefollowing CSP:

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

1

Introduction

Variables: x, y, z
Constraints: x 6= y, y 6= z, z 6= x

Figure 1.1: Constraint graph corresponding to the CSP

A solution to a CSP is an assignment of a value (belonging to its domain) to every variable,
satisfying all the constraints.
In CP, constraints are used actively to deduce infeasible values and delete them from the domainsof variables. This mechanism is called constraint propagation. It represents the core of Constraint
Programming systems. Each constraint computes impossible values for its variables and informs
other constraints. This process continues as long as new deductions are made.
Constraint propagation is associated with tree search techniques in order to find solutions orprove optimality. Each node and each decision will induce constraint propagation automatically.
Many specific and efficient algorithms will be used in this propagation, but do not need to be
known by the end-user. This allows persons who are familiar with problem modeling to quickly
use such techniques for optimization or generation of solutions.
Solutions of a discrete CSP can be found by a systematic search on the set of possible assignmentsof values to variables. Other interval techniques are applied for continuous variables.
One may wish to find:just one feasible solution, without any choice preference

all the solutions

an optimal solution (or at least a nearly optimal solution) that optimizes a certain objectivefunction defined on a subset of the variables of the problem

Solution search methods can be classified in two categories:

Search methods that explore the space of the partial assignments



Search methods that explore the space of complete assignments, generally in a stochastic
way

The main reason for representing a problem as a CSP is that the formulation of the problem as a
CSP is close to the original one in that: variables of the CSP directly correspond to the problem
entities and the constraints can be expressed in a natural way without any translation to a set of
linear inequalities as in the Mathematical Programming framework. This formulation is thus
clearer, solutions are easier to represent, and search heuristics more direct.

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information2

Introduction

1.3

What is Xpress Kalis?
Xpress Kalis is a Constraint Programming modeler based upon the Artelys Kalis solver. The
software is provided in the form of a Mosel module, kalis. Xpress Mosel must be installed in order
to be able to use Xpress Kalis. The graphical environment Xpress Workbench can be used to workwith Xpress Kalis models. The module kalis extends the Mosel language with new ways ofdefining and solving Constraint Programming (CP) problems.

1.4

Prerequisites
This manual assumes some familiarity with the Mosel syntax. The reader is refered to the ‘Mosel
User Guide’ for an introduction to working with Mosel. The ‘Mosel Language Reference Manual’contains the complete documentation of the Mosel language. The ‘Getting Started’ manualexplains how to work with Mosel models in Xpress Workbench.

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

3

I. Paradigm

C HAPTER 2

Decision variables
Decision variables are represented in Xpress Kalis by the types cpvar and cpfloatvar. They
correspond respectively to finite domain variables taking their values in a given interval, or set of
integers, called a domain and to continuous domain variables represented by real valued
intervals. Conceptually the variables can be represented in the following way:
Decision variables are declared by using the standard Mosel syntax. For instance, the following
code extract shows how to create a finite domain variable my_cpvar, a static array of cpvar
cpvar_array, and a dynamic array of cpfloatvar dyn_cpfloatvar_array:declarations
my_cpvar: cpvar
cpvar_array: array(1..10) of cpvar
dyn_cpfloatvar_array : array(range) of cpfloatvar
end-declarations

Note that entries of dynamic arrays of domain variables (arrays declared as dynamic at theircreation or arrays for which some or all of the index sets are not known at the declaration like
dyn_cpfloatvar_array in the example above) must be created explicitly using the Mosel
procedure create:declarations
dyn_cpfloatvar_array : array(range) of cpfloatvar
end-declarations
forall(i in 3..30) create(dyn_cpvar_array(i))

After its declaration, the second step in the creation of a domain variable consists of defining its
domain with the procedure setdomain.
Domain variables are also used in the definition of constraints and search strategy.

Figure 2.1: Conceptual representation of finite domain variables

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information5

Decision variables

Figure 2.2: Conceptual representation of continuous variables

Xpress Kalis defines a set of functions for accessing and modifying cpvar and cpfloatvar states:

contains

Tests if a value is in the domain of a variable

p. 128cp_show_var

Shows the current domain of the variable

p. 137

getdegree

Returns the degree of a variable

p. 123getlb

Returns the current lower bound of a variable

p. 117

getmiddle

Returns the middle value of a variable

p. 119getnext

Gets the next value in the domain of a finite domain variable

p. 126

getprev

Gets the previous value in the domain of a finite domain variable
p. 127

getrandReturns a random value belonging to the domain of a variable

p. 125getsize

Returns the cardinality of the variable domain

p. 120gettarget

Returns the target value of a variable

p. 124getub

Returns the current upper bound of a variable

p. 118getvalReturns the instantiation value of a variable

p. 121

is_equal

Tests if two variable domains are equalp. 129is_fixed

Tests if the variable passed in argument is instantiatedp. 122

is_sameTests if two decision variables represent the same variable

p. 130setdomain

Sets the domain of a variable

p. 132

setlb

Sets the lower bound of a variable

p. 133

setprecision

Sets the precision relativity and value of a continuous variable

p. 136settarget

Sets the target value of a variable

p. 131

setub

Sets the upper bound of a variable

p. 134

setvalInstantiate the value of a variable

p. 135

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

6

C HAPTER 3

Constraints
Constraints represent logical restrictions on the values that decision variables can simultaneously
take and that must be satisfied. There are various types of constraints that can be stated within
Xpress Kalis:Linear constraint (equation, inequality, disequality), e.g.: x 6= y, x = y, x ≤ y etc.

Non-linear constraint (equation, inequality), e.g.: x = y / z, x ∗ y + 2 ∗ ln(z) = exp(w),x 2 + y 2 ≤ z2 etc.

Symbolic constraint, e.g.: all-different(x, y, z) meaning (x 6= y) ∧ (x 6= z) ∧ (x 6= z)Logical relation, e.g.: x 6= y ⇒ z = 3

User-defined constraints such as generic_binary_constraint(x, y)All constraints are represented by the type cpctr.
abs

Absolute value constraintp. 81

all_different

All different constraint

p. 83

and

Conjunction composite constraint

p. 69

cplinctr

Linear constraints

p. 67

cpnlinctr

Non-linear constraints

p. 75

cumulative

Cumulative constraint

p. 101

cycle

Cycle constraint

p. 85

disjunctive

Disjunctive constraint

p. 103

distance

Distance constraint

p. 79

distribute

Distribute constraint with fixed bounds

p. 99

element

Element constraint

p. 94

equiv

Equivalence composite constraint

p. 71

exp

Exponential of a non-linear expression

p. 78

generic_binary_constraint

Generic Binary constraint

p. 96

generic_nary_constraint

Generic nary constraint

p. 98

implies

Implication composite constraint

p. 73

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

7

ConstraintslnNatural logarithm of a non-linear expression

p. 77

maximum_minimum

Maximum/minimum constraint

p. 90

occurrenceOccurrence constraint

p. 92

or

Disjunction composite constraint

p. 70

producer_consumer

Producer Consumer constraint

p. 105

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

8

C HAPTER 4

Enumeration and search strategy
Since the combination of constraint solving and propagation mechanism is usually not sufficient
to reduce all variable domains to a single value, an enumeration needs to be added to the
problem definition to find feasible solutions or to prove that no such solution exists.
The search process is made by a branch and bound algorithm with depth-first exploration of thesearch tree. At each node, a propagation phase is triggered in order to detect possible
inconsistencies and reduce the search space. If this phase detects an inconsistency, the algorithm
backtracks and removes the effects of the previous decisions. If no inconsistency is detected, abranching process is applied recursively to the child nodes until a solution is found or until all thesearch space has been explored.
The way the branching is done is defined by branching schemes (type cpbranching). Six branching
schemes are predefined in Xpress Kalis:
1. assign_var

This branching scheme may be considered as the standard enumeration scheme in finite
domain Constraint Programming. For a given branching variable it enumerates all values
currently in its domain. A branch is formed by assigning a value to the branching variable,
resulting in a variable number of branches per node (determined by the variable’s domainsize). Since this strategy tends to create a very wide search tree it is used preferably withsmall domains or if variable and value selection strategies are known that quickly lead to(good) feasible solutions.

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

9

Enumeration and search strategy

2. assign_and_forbidThis branching scheme creates a binary search tree by creating two branches for a given
branching variable. The first branch is formed by assigning a value to the branchingvariable, and the second branch, by forbidding this value for this variable.
3. split_domain

The split_domain strategy creates a binary search tree by splitting the domain of the
branching variable into two intervals (all values less than or equal to the branching value inthe first and all values greater than the branching value in the second). This strategy is the
only possible choice for continuous variables and it is also applicable for finite domain
variables. For the latter this strategy may be helpful if the initial domain sizes are relatively
large. The strategy can be configured by choosing which branch to explore first andwhether to stop applying it when domain sizes are reduced to less than a certain limit.
4. probe_assign_var

The probe_assign_var strategy is directly derived from the assign_var strategy which meansthat the branches created are the same. The difference lies in the completeness and theorder in which branches are explored. Some of the possible branches are skipped by limiting
the global number of times that the heuristic (first branch created) may fail and thebranching process is stopped when this counter exceeds a specified value. The picture below
shows the order in which the branches are explored when the domains of all variables are
reduced to two values. This strategy can be useful to apply local search to an already known
solution (combined with the KALIS_NEAREST_VALUE value selection heuristic) or to explore
the neighborhood of a heuristic solution to find quickly a first solution and avoid thethrashing behavior of the chronological backtracking algorithm used during the resolution
process.

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

10Enumeration and search strategy

5. settle_disjunction

The settle_disjunction strategy creates a binary search tree by branching on the two
possibilities defined by a disjunction. Recall that a disjunction can be written as c1 or c2
where c1 and c2 are two constraints, the settle_disjunction strategy will create a branch foreach constraint stating that it must hold. The strategy can be configured by choosing thefirst branch of the disjunction that will be explored during the search process.
6. probe_settle_disjunction

The probe_assign_var strategy is directly derived from the settle_disjunction strategy whichmeans that the branches created by this strategy are the same. The difference lies in thecompleteness and the order in which branches are explored. Some of the possible branches
are skipped by limiting the total number of times that the heuristic (first branch created)
may fail and the branching process is stopped when this counter exceeds a specified value.
The picture below shows the order in which the branches are explored when the domains ofall variables are reduced to two values. This strategy can be useful to apply local search to a
disjunctive scheduling problem for which a solution is already known (combined with thesetfirstbranch and getactivebranch methods).
These predefined branching schemes are used in conjunction with variable (resp. disjunction) andvalue selection heuristics that fully define the way how the search tree will be explored.
Xpress Kalis predefines several variable selection heuristics:

KALIS_SMALLEST_DOMAINKALIS_MAX_DEGREE

KALIS_SDOMDEG_RATIOKALIS_SMALLEST_MAX

KALIS_SMALLEST_MINKALIS_LARGEST_MAX

KALIS_LARGEST_MINKALIS_MAXREGRET_UB

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

11

Enumeration and search strategy



KALIS_MAXREGRET_LBKALIS_INPUT_ORDERKALIS_WIDEST_DOMAIN (continuous variables)... value selection heuristics:

KALIS_MAX_TO_MINKALIS_MIN_TO_MAXKALIS_MIDDLE_VALUEKALIS_RANDOM_VALUE... and disjunction selection heuristics:

KALIS_DISJ_INPUT_ORDERKALIS_DISJ_PRIORITY_ORDER

Xpress Kalis offers several possibilities to define the search strategy:

Use the predefined strategy provided by Xpress Kalis.



Build custom search strategies based on combinations of predefined branching schemes,variable and value selection heuristics.



Define custom heuristics for variable and value selection.



Add an optimization function (cost or objective function) for an enumeration and thus
search for a feasible solution with the best (minimum or maximum) cost (optimal solution).
We refer to this case as optimization, although, in practical applications one is typically onlyinterested in good solutions that are found quickly, without necessarily spending time inproving that, indeed, the best solution is found.

The following example shows a specific problem and branching strategy with the corresponding
search tree:
declarationsx: cpvary: cpvarstrategy : array(1..2) of cpbranchingend-declarations
1 <= x; x <= 3
1 <= y; y <= 3
strategy(1) := split_domain(KALIS_SMALLEST_DOMAIN, KALIS_MIN_TO_MAX, {x})strategy(2) := assign_var(KALIS_SMALLEST_DOMAIN, KALIS_MIN_TO_MAX, {y})cp_set_branching(strategy)

assign_and_forbid

assign_and_forbid branching scheme

p. 172

assign_var

assign_var branching scheme

p. 168bs_group

Create a group of branching schemes

p. 193

cp_set_branching

Sets the strategy to use during the search for a solution

p. 189Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

12

Enumeration and search strategy

Figure 4.1: Example of search tree

cp_show_stats

Shows some statistics about the searchp. 192

gettagGets the tag of a constraint

p. 112group_serializer

Creates a branching scheme Group Serializer

p. 194probe_assign_var

probe_assign_var branching scheme

p. 178probe_settle_disjunction probe_settle_disjunction branching scheme

p. 179settle_disjunction

settle_disjunction branching scheme

p. 176

split_domain

split_domain branching scheme

p. 181

task_serialize

task_serialize branching scheme

p. 185

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

13

C HAPTER 5

Scheduling
Scheduling plays an important role in manufacturing and engineering where it can have a major
impact on the productivity of a process. The goal of scheduling is to optimize the production
process by telling which operation to do, when, with which staff, and using which equipment.
Let’s take the example of constructing a house. This task can be broken down into a set ofsmaller tasks:
Grading and preparation of the siteFoundations

FramingInstallation of windows and doors

RoofingSidingElectricity

Plumbing

Underlayment

Painting

etc...

All these tasks must be carried out in a certain order: for example, laying the foundations cannot
be done before the excavation and grading of the site. Moreover, certain tasks require specificresources (you need a plumber to do plumbing, a concrete mixer to do the carpentry etc.).
Tasks and resources are represented in Xpress Kalis by special purpose types such as cpresource
and cptask.

5.1

Tasks
A cptask is represented by three decision variables of type cpvar:
start representing the starting time of the task

end representing the ending time of the task

duration representing the duration of the task

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

14

Scheduling

These three structural variables are linked by Xpress Kalis with the following constraint:
start + duration = end.


The starting time variable represents two specific parameters of the task:– the Earliest Start Time (EST, represented by the lower bound of the ’start’ variable) and
its Latest Start Time (LST, represented by the upper bound of the ’start’ variable).

The end variable represents two specific parameters of the task:– the Earliest Completion Time (ECT, represented by the lower bound of the ’end’
variable) and its Latest Completion Time (LCT, represented by the upper bound of the’end’ variable).

The duration variable represents two specific parameters of the task:– the minimum task duration (Dmin, represented by the lower bound of the ’duration’variable) and the maximum task duration (Dmax, represented by the upper bound of
the ’duration’ variable).

The picture below illustrates this:Task attributes can be assigned or
retrieved with the following methods:

getstart

getend

getduration



setduration

getname

setname

is_fixed

addpredecessors

setpredecessors

addsuccessors

setsuccessorssetsetuptime

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information15

Scheduling

5.2

Resources
A resource can be of two different types:


Disjunctive when the resource can process only one task at a time
(KALIS_UNARY_RESOURCE).



Cumulative when the resource can process several tasks at the same time
(KALIS_DISCRETE_RESOURCE).

Traditional examples of disjunctive resources are Jobshop scheduling problems. Cumulative
resources are used for the Resource-Constrained Project Scheduling Problem (RCPSP)
Note that a disjunctive resource is semantically equivalent to a cumulative resource with maximal
capacity one and unit resource usage for each task using this resource but this equivalence does
not hold in terms of constraint propagation.
When defining a resource with Xpress Kalis its initial capacity is specified. For a disjunctive
resource the capacity value is always equal to one. The structural capacity of a resource does notvary over time but a maximal temporal capacity can be imposed at any point of time with theprocedure setcapacity.
The following graphic shows an example with three tasks A, B and C executing on a disjunctive
resource and on a cumulative resource with resource usage 3 for task A, 1 for task B, and 1 fortask C.

Tasks require, provide, consume and produce resources:

A task requires a resource if some amount of the resource capacity must be made available
for the execution of the activity. The capacity is renewable, this means the required capacity
becomes available again after the end of the task.

A task provides a resource if some amount of the resource capacity is made available
through the execution of the task. The capacity is renewable, that is, the provided capacity
is available only during the execution of the task.

A task consumes a resource if some amount of the resource capacity must be made available
for the execution of the task and the capacity is non-renewable, that is, the consumed
capacity is no longer available at the end of the task.

A task produces a resource if some amount of the resource capacity is made available
through the execution of the task and the capacity is non-renewable, that is, the produced
capacity is definitively available after the start of the task.

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

16

Scheduling

Task productions, requirements, provisions and productions can be accessed with the following
methods:

consumesrequires

provides

producesgetconsumptiongetrequirementgetprovision

getproduction

is_consuming

is_requiring

is_providing

is_producing

Resources and tasks are declared by using the standard Mosel syntax. For instance, the following
code extract shows how to create a task my_cptask, a static array of resources cpresource_array,and a dynamic array of cptask dyn_cptask_array:declarations
my_cptask: cptask
cpresource_array: array(1..10) of cpresource
dyn_cptask_array: array(range) of cptask
end-declarations

Note that entries of dynamic arrays of tasks or resources (arrays declared as dynamic at theircreation or arrays for which some or all of the index sets are not known at the declaration like
dyn_cptask_array in the example above) must be created explicitly using the Mosel procedure
create:declarations
dyn_cptask_array: array(range) of cptask
end-declarations
forall(i in 3..30) create (dyn_cptask_array(i))

After its declaration, the second step in the creation of a task or resource consists of defining
somes attributes with the procedures set_task_attributes and set_resource_attributes.

5.3

Schedule
Tasks and resources form a schedule. The cp_schedule method allows to optimize a schedule withrespect to any objective variable and implements advanced scheduling techniques specialized in
makespan minimization. The creation of the schedule makespan can be automated by calling thegetmakespan method that ensures automatically its computation.

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information17

Scheduling

A custom scheduling optimization strategy can be specified by using the task_serialize
branching scheme to select the task to be scheduled and value choice heuristics for its start andduration variables.
The task selection method can be any user Mosel method or it may be configured with thepredefined strategies of Xpress Kalis:

KALIS_SMALLEST_ECTKALIS_SMALLEST_ESTKALIS_SMALLEST_LCTKALIS_SMALLEST_LSTKALIS_LARGEST_ECTKALIS_LARGEST_ESTKALIS_LARGEST_LCTKALIS_LARGEST_LST

The picture below illustrates the definition of a task-based branching strategy:

Xpress Kalis defines a set of functions for accessing and modifying cptask and cpresource states:
addpredecessors

Adds a set of predecessors for a task

p. 211

addsuccessors

Adds a set of tasks as successors of a task

p. 213

consumes

Sets the minimal and maximal amount of resource consumed by a task
for a particular resourcep. 233

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information18

Scheduling

cp_close_schedule

Close the schedule.

p. 268cp_get_default_schedule_strategy Gets the default schedule search strategy of cp_schedulep. 258cp_schedule

Optimizes the schedule with respect to an objective variable.

cp_set_schedule_strategy Sets the schedule search strategy for cp_schedulep. 231
p. 257

cp_show_schedule

Shows a textual representation of the current schedulegetassignment

Gets the cpvar representing the assignment of a task for a particular
resource.
p. 262

getcapacity

Get the maximal capacity of a resource for a specific time period.
p. 252getconsumption

Gets the cpvar representing the consumption of a task for a particular
resourcep. 219getduration

Gets the cpvar representing a task duration

p. 218getendGets the cpvar representing a task completion timep. 217getmakespanGets the cpvar representing the makespan of the schedule.

p. 232

getproduction

Gets the cpvar representing the production of a task for a particular
resourcep. 223

getprovision

Gets the cpvar representing the provision of a task for a particular
resourcep. 225getrequirement

Gets the cpvar representing the requirement of a task for a particular
resourcep. 221getsetuptime

Gets the sequence dependent setup times between two tasks

p. 255getstart

Gets the cpvar representing a task start timep. 216has_assignment

Tests whether an assignment decision variable for a task and aparticular resource exists.

p. 264is_consuming

Tests whether a task consumes a specific resourcep. 227

is_fixed

Tests if the variable passed in argument is instantiatedp. 122

is_idletime

Tests if a timestep is an idle timestep for a resource.

p. 267

is_producing

Tests whether a task produces a specific resourcep. 229is_providing

Tests whether a task provides a specific resourcep. 230is_requiring

Tests whether a task requires a specific resourcep. 228produces

Sets the minimal and maximal amount of resource produced by a task
for a particular resourcep. 239providesSets the minimal and maximal amount of resource provided by a task
for a particular resource.
p. 242requires

Sets the minimal and maximal amount of resource required by a task
for a particular resourcep. 236

resusage

Creates a resource usage

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

p. 215p. 25919

Scheduling

set_resource_attributes

Sets some attributes for a resourcep. 245

set_task_attributes

Sets some attributes for a task

p. 209setcapacity

Sets the maximal capacity of a resource between two time bounds.
p. 246setduration

Sets the duration of a task

p. 210setidletimes

Specifies the set of timesteps where a resource is idle.

p. 266setmaxavailability

Sets the maximal capacity of a resource between two time bounds.
p. 248

setminusage

Sets the minimum usage of a resource between two time bounds.
p. 250

setpredecessors

Sets the tasks that must precede a task

p. 212

setsetuptime

Sets sequence dependent setup times between two tasks

p. 254setsuccessors

Sets the set of tasks that must succeed a task

p. 214

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

20

C HAPTER 6

Linear relaxations
Some parts of an optimization problem may be best expressed and solved in the declarative(solver-independent) manner of Mathematical Programming (MP). Other parts benefit fromconstraint propagation and search directions provided by a CP solver. So why not trying to get
the best of both worlds by combining the MP and CP approaches?
Xpress Kalis allows you to benefit from CP and MIP hybridization in a clean and easy way bymeans of linear relaxations of the CP model. Xpress Kalis can build automatically several linear(or mixed integer linear) relaxations of the CP problem and use Xpress Optimizer to solve them.
This process can be fully configured ranging from a complete user definition of the relaxationand choice of when to launch the relaxation to a fully automatic relaxation.
Xpress Kalis uses a double modeling approach by exchanging automatically and in bidirectionalway, informations such as objective bounds, infeasibility, optimal relaxed solutions and reduced
costs between the cp solver and the linear relaxations solver(s) during the search for a solution.
Note: the linear relaxation functionality of Xpress Kalis can only be used if Xpress Optimizer isinstalled and licensed.

6.1

Automatic relaxations
The following constraints can be relaxed automatically with Xpress Kalis :Linear constraints



all-differentoccurrence

distribute

Min/Maxabsolute value

distanceelement



cycle



logical (implies, or ,and ,equiv)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information21

Linear relaxations

To obtain an automatic relaxation of the whole problem, Xpress Kalis takes the intersection of
the relaxations of the constraints of the constraint programming model. Such a relaxation is
obtained by a simple call to the function cp_get_linrelax
Note that this method is parameterized with an integer parameter since Xpress Kalis offers
several relaxations for each constraint. In the present case, 0 means an LP oriented relaxation and1 means a MIP oriented relaxation.

6.2

User defined relaxations
Xpress Kalis allows the user to define his own relaxation for the problem and provides several
operators, functions and methods for this purpose:Overloaded operators for the specification of linear inequalities in a linear relaxation.



The method get_linrelax(ctr:

The set_integer method turns variables in the relaxation into discrete variables (by default
all relaxation variables are considered as continuous).

Variables can be defined either in both, CP model and relaxation, or only in the CP model,
or only in the relaxation (auxiliary variables).

cpctr) returns the automatic relaxation for a constraint.

Auxiliary variables (of the type cpauxvar) are additional variables that are used only in thedefinition of the relaxation and not in the formulation of the CP problem. For example, they canbe used to linearize non-linear constraints or to express choices in the relaxation.
The CP model will not see these variables (no propagation and no branching) except for one
particular kind of auxilliary variables called indicators. These indicator variables are 0-1 integer
variables that are linked to cpvar variables. There is one indicator variable per value in thedomain of a cpvar, and the indicator takes the value 1 if and only if this cpvar is instantiated to
the value associated with the indicator variable. Bounds on indicator variables are automatically
propagated by Xpress Kalis and reduced costs provided by the relaxation are retro-propagated to
the CP variables by the means of reduced costs fixing (a kind of propagation reasoning on
optimality).
Indicator variables are created and retrieved by a call to the get_indicator function.
The following examples show some expressions that can be used in the definition of custom
relaxations:declarations
myrelax: cplinrelax
a1,a2 : cpauxvar
taux: array(1..4) of cpauxvar
x1,x2,x3: cpvarz: cpfloatvarCAlld: cpctrend-declarations! A linear relaxation! Auxiliary variables for relaxation! Array of auxiliary variables! Finite domain variables! CP variable with continuous domain! A CP constraint! Define an ’alldifferent’ constraint
CAlld := all_different({x1,x2,x3})! Build an automatic ’LP’ oriented linear relaxation
myrelax1 := cp_get_linrelax(0)! Setting bounds on the auxiliary variables
setdomain(a2,0,1)
setdomain(a1,0.56,18.67)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

22

Linear relaxations! Adding linear inequalities to the relaxation
myrelax += 3*a1<= 3
myrelax += a1+a2>= 3.1
myrelax += 2*a1-4*a2 = 3
myrelax += a1-x1<= 3.4myrelax += a1+4*a2-z <= 3
myrelax += get_linrelax(CAlld,0)
myrelax +=get_indicator(x1,1) + get_indicator(x2,1) + get_indicator(x3,1) <= 1myrelax += sum(i in 1..4) taux(i) = 4! Set integrality condition for variables in the relaxation
set_integer(myrelax,a2,true)
set_integer(myrelax,x1,true)! Output the resulting relaxation to the screen
cp_show_relax(myrelax)

6.3

Usage of relaxations
Xpress Kalis can create several distinct relaxations of a CP problem and solve them.
The optimal solution of these relaxations provides bounds for the CP branch-and-bound process
and prunes the search tree with reduced costs propagation (optimality reasoning).
To solve a linear relaxation, Xpress Kalis uses relaxation solvers (of the type cplinrelaxsolver)that define for the relaxation:
An objective variable for the relaxation

An optimization sense (either KALIS_MINIMIZE or KALIS_MAXIMIZE)

A configuration defining when and what to do with the relaxation.



A flag indicating whether to solve the relaxation as a pure LP problem or as a MIP.(either
KALIS_SOLVE_AS_LP or KALIS_SOLVE_AS_MIP

Several predefined configurations are implemented within Xpress Kalis:

KALIS_TOPNODE_RELAX_SOLVER: This configuration solves the relaxation only at the top nodeand provides bounds for the objective variable.



KALIS_TREENODE_RELAX_SOLVER: This configuration solves the relaxation at each node of thesearch tree. It provides bounds for the objective variable and performs reduced costs
propagation.



KALIS_BILEVEL_RELAX_SOLVER: This configuration solves the relaxation whenever all thevariables (by default all the discrete variables such as cpvar) of a user defined set are
instantiated. After solving of the relaxation, all the other variables are instantiated to theiroptimal value in the relaxation. The main use of the bi-level configuration is to decompose
the CP model simply and automatically into a master problem and a slave problem.

The user can also take full control over the relaxation solver by the means of callbacks.
A relaxation solver is obtained by specifying three callbacks functions:must_relax: This function with no argument and returning a Boolean must return true
whenever the users wants to solve the relaxation

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

23

Linear relaxations



before_relax: This procedure with no argument is called just before the relaxation is
performed

after_relax(status: integer): This procedure with one argument is called after the relaxation
has been solved. The status parameter indicates whether the relaxation is optimal (0) or
infeasible (1). This callback can be used, for example, to instantiate some variables to theirvalues in the optimal solution of the relaxation.

In addition to the user-configurable relaxations, Xpress Kalis provides a fully automated mode forusing linear relaxations, enabled by the control parameter auto_relax.

6.4

Branching with relaxation
Xpress Kalis defines predefined branching schemes and value and variable selection heuristics
based on the optimal solution of a relaxation:

KALIS_LARGEST_REDUCED_COST variable selection heuristic selects the variable with the largest
reduced cost in the optimal solution of the relaxation used by the specified relaxation solver.



KALIS_NEAREST_RELAXED_VALUE value selection heuristic selects the value in the domain of
the variable that is the nearest (in L1) to the value of this variable in the optimal solution of
the relaxation used by the specified relaxation solver.

Moreover, the fix_to_relaxed method can be called during the tree search process to instantiate
all the continuous variables to their values in the optimal solution of a relaxation.
This can be useful with some specific problem structures and in combination with the
KALIS_BILEVEL_RELAX_SOLVER configuration for the relaxation solver to obtain an automatic
logical benders decomposition of the solving process.

6.5

A simple hybrid example
Consider the following knapsack problem with an additional non linear constraint: all-different
minimize

5 · x1 + 8 · x2 + 4 · x3
3 · x1 + 5 · x2 + 2 · x3 ≥ 30s. t.

all-different(x1 , x2 , x3 )xj ∈ {1, 3, 8, 12} for j = 1, 2, 3
A pure and straightforward CP approach for formulating and solving this problem is shown
below:
model "Knapsack with side constraints"
uses "kalis"declarations
x1,x2,x3: cpvar
benefit : cpvar
end-declarations! Decision variables! The objective to minimize! Enable output printing
setparam("kalis_verbose_level", 1)! Setting name of variables for pretty printing

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information24

Linear relaxations

setname(x1,"x1"); setname(x2,"x2"); setname(x3,"x3")setname(benefit,"benefit")! Set initial domains for variables
setdomain(x1, {1,3,8,12})setdomain(x2, {1,3,8,12})setdomain(x3, {1,3,8,12})! Knapsack constraint
3*x1 + 5*x2 + 2*x3 >= 30! Additional global constraint
all_different({x1,x2,x3})! Objective function
benefit = 5*x1 + 8*x2 + 4*x3
! Initial propagation
res := cp_propagate! Display bounds on objective after constraint propagation
writeln("Constraints propagation objective ", benefit)! Solve the problem
if (cp_minimize(benefit)) thencp_show_sol
end-if! Output optimal solution to screen

end-modelThis model formulation can be augmented by the definition of a linear relaxation.
We start by getting an automatic relaxation of the problem by a call to the function
cp_get_linrelax. The resulting relaxation can be displayed (printed to the standard output) witha call to the procedure cp_show_relax.
From the linear relaxation a linear relaxation solver is built with a call to the get_linrelax_solver
method. Note that the KALIS_TOPNODE_RELAX_SOLVER argument passed to the method indicatesthat we just want to solve the linear relaxation at the top node of the CP search tree.
Having obtained the linear relaxation solver, we need to add it to the search process by a call to
cp_add_linrelax_solver. Of course, Xpress Kalis is not limited to one relaxation so several solvers
can be defined and added to the search process.
The model definition is completed by specifying a ’MIP style’ branching scheme that branches firston the variables with largest reduced cost and tests first the values nearest to the optimal
solution of the relaxation. The invocation ot the search and solution display remain the same asin the CP model.
This is the full hybrid model:
model "Knapsack with side constraints"
uses "kalis"declarations
x1,x2,x3: cpvar
benefit : cpvar
end-declarations! Decision variables! The objective to minimize! Enable output printing
setparam("kalis_verbose_level", 1)! Setting name of variables for pretty printing
setname(x1,"x1"); setname(x2,"x2"); setname(x3,"x3")setname(benefit,"benefit")! Set initial domains for variables

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information25

Linear relaxations

setdomain(x1, {1,3,8,12})setdomain(x2, {1,3,8,12})setdomain(x3, {1,3,8,12})! Knapsack constraint
3*x1 + 5*x2 + 2*x3 >= 30! Additional global constraint
all_different({x1,x2,x3})! Objective function
benefit = 5*x1 + 8*x2 + 4*x3
! Initial propagation
res := cp_propagate! Display bounds on objective after constraint propagation
writeln("Constraints propagation objective ", benefit)

declarations
myrelaxall: cplinrelax
end-declarations! Build an automatic ’LP’ oriented linear relaxation
myrelaxall:= cp_get_linrelax(0)! Output the relaxation to the screen
cp_show_relax(myrelaxall)
mysolver:= get_linrelax_solver(myrelaxall, benefit, KALIS_MINIMIZE,KALIS_SOLVE_AS_MIP, KALIS_TOPNODE_RELAX_SOLVER)! Define the linear relaxation
cp_add_linrelax_solver(mysolver)! Define a ’MIP’ style branching scheme using the solution of the! optimal relaxation
cp_set_branching(assign_var(KALIS_LARGEST_REDUCED_COST(mysolver),KALIS_NEAREST_RELAXED_VALUE(mysolver)))! Solve the problem
if (cp_minimize(benefit)) thencp_show_sol
end-if! Output optimal solution to screen

end-model

You will find below the list of relaxation related functions and procedures defined within Xpress
Kalis:
cp_add_linrelax_solver Add a linear relaxation solver to the linear relaxation solver list p. 277
cp_clear_linrelax_solver Clear the linear relaxation solver list
cp_get_linrelax

Returns an automatic relaxation of the cp problem

p. 279p. 272

cp_remove_linrelax_solver Remove a linear relaxation solver from the linear relaxation solver
list
p. 278cp_show_relax

Pretty printing of a linear relaxation

p. 276

export_prob

Export the linear relaxation in LP format

p. 285

fix_to_relaxedFix the continuous variables to their optimal value in the relaxation
solver passed in argument
p. 274

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

26

Linear relaxations

generate_cuts

Generate and add cuts to the relaxation passed in parameters

p. 280get_indicator

Get an indicator variable for a given variable and a value.

p. 283

get_linrelax

Get the linear relaxation for a constraint

p. 284

get_linrelax_solver

Returns a linear relaxation solver from a linear relaxation, an objective
variables and some configuration parameters
p. 273

get_reduced_cost

Get a reduced cost value from a linear relaxation solver

p. 286

get_relaxed_value

Returns the optimal relaxed value for a variable in a relaxation

p. 287KALIS_LARGEST_REDUCED_COST Get a largest reduced cost variable selector from a linear
relaxation solver

p. 270KALIS_NEAREST_RELAXED_VALUE Get a nearest relaxed value selector from a linear relaxation
solverp. 271
lp_optimize

Launch LP/MIP solver without CP branching.

p. 281

set_integer

Set integrality flag for a variable in a linear relaxation

p. 288

set_linrelax_solver_attribute Parameter setting for a linear relaxation solver.

p. 282

set_verbose_levelSet the verbose level for a specific linear relaxation solver

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

p. 27527

II. Reference Manual

C HAPTER 7

Constants
KALIS_ALL_CONSTRAINTS

Set of all the constraints

p. 50

KALIS_BARRIER

Set the solution algorithm for the relaxation to barrier

p. 54

KALIS_BILEVEL_RELAX_SOLVER Bilevel node relaxation solver configuration

p. 49

KALIS_COPYRIGHT

Xpress Kalis copyright information

p. 40

KALIS_DISCRETE_RESOURCE

Discrete resource

p. 40

KALIS_DISJ_INPUT_ORDER

Input order disjunction selection heuristic

p. 44

KALIS_DISJ_PRIORITY_ORDERKALIS_DISJUNCTIONS

Input order disjunction selection heuristic

Disjunctions propagation type for unary resource constraints

KALIS_DISTANCE_CONSTRAINTS Set of the distance constraints

p. 44
p. 45
p. 50

KALIS_DUAL_SIMPLEX

Set the solution algorithm for the relaxation to dual simplex

p. 54

KALIS_EDGE_FINDING

Tasks Interval + Edge finding propagation type for discrete resource
constraints
p. 45

KALIS_FORWARD_CHECKING

Forward checking propagation type for the all_different constraint
p. 31

KALIS_GEN_ARC_CONSISTENCY Generalized arc consistency propagation type for the all_different
constraint
p. 32
KALIS_INITIAL_SOLUTION

Schedule search strategy choice: heuristic solution

p. 46

KALIS_INPUT_ORDER

Input Order variable selection heuristic

p. 35

KALIS_LARGEST_ECT

Largest Earliest Completion time task selection heuristic

p. 42

KALIS_LARGEST_EST

Largest Earliest Start time task selection heuristic

p. 42

KALIS_LARGEST_LCT

Largest Latest Completion time task selection heuristic

p. 42

KALIS_LARGEST_LST

Largest Latest Start time task selection heuristic

p. 43

KALIS_LARGEST_MAX

Largest maximum variable selection heuristic

p. 36

KALIS_LARGEST_MIN

Largest minimum variable selection heuristic

p. 35

KALIS_LINEAR_CONSTRAINTS Set of linear constraints
KALIS_LOGICAL_CONSTRAINTSKALIS_MAX_DEGREE

Set of logical constraints

Maximum constraint graph degree variable selection heuristic

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

p. 49
p. 50
p. 35

29

Constants

KALIS_MAX_TO_MIN

Maximum to minimum value selection heuristic

p. 39

KALIS_MAXIMIZE

Maximize objective in linear relaxation

p. 51

KALIS_MAXREGRET_LB

Maximum regret on the lower bound variable selection heuristic p. 36

KALIS_MAXREGRET_UB

Maximum regret on the upper bound variable selection heuristic p. 36

KALIS_MIDDLE_VALUE

Middle value selection heuristic

p. 39

KALIS_MIN_TO_MAX

Minimum to maximum value selection heuristic

p. 39

KALIS_MINIMIZE

Minimize objective in linear relaxation

p. 51

KALIS_NEAREST_VALUE

Nearest to target value selection heuristic

p. 39

KALIS_NETWORK_SIMPLEX

Set the solution algorithm for the relaxation to network simplex p. 55

KALIS_NON_LINEAR_CONSTRAINTS

Set of non linear constraints

p. 49

Schedule search strategy choice: improving bound and prove
optimality

p. 46

KALIS_PRIMAL_SIMPLEX

Set the solution algorithm for the relaxation to primal simplex

p. 54

KALIS_RANDOM_VALUE

Random value selection heuristic

p. 40

KALIS_RANDOM_VARIABLE

Random variable selection heuristic

p. 37

KALIS_RELAX_ALGORITHM

Set the solution algorithm for the relaxation

p. 53

KALIS_RELAX_GLOBAL

Set global search flag for the linear relaxation

p. 52

KALIS_OPTIMAL_SOLUTIONKALIS_RELAX_MIP_ABS_STOP Set the MIP absolute tolerance to optimality for the resolution of
the linear relaxation solver
p. 53
KALIS_RELAX_MIP_REL_STOP Set the MIP relative tolerance to optimality for the resolution of thelinear relaxation solver
p. 53
KALIS_RELAX_OPT_TOL

Set the optimality tolerance for the resolution of the linear relaxation
solverp. 53

KALIS_RELAX_PRESOLVE

Use presolve for relaxation

KALIS_RELAX_RCOSTS_PROPAG

Use reduced costs for propagation

KALIS_RELAX_RELOAD_BASIS Use reload basis for relaxation

p. 52
p. 52
p. 52

KALIS_RESET_OPT_PARAMS

Group parameter choice for strategy optimisation

p. 48

KALIS_RESET_PARAMS_ALL

Group parameter choice for all parameters

p. 46

KALIS_RESET_SEARCH_PARAMSKALIS_RESET_VAR_BOUNDSGroup parameter choice for variable bounds

KALIS_RESET_VAR_PRECISIONKALIS_SDOMDEG_RATIOGroup parameter choice for strategy properties

Group parameter choice for variable precisions

p. 48
p. 47
p. 47

Smallest domain size to degree ratio variable selection heuristic. p. 37

KALIS_SLIM_BY_BACKTRACKS Type of limitation on the search treep. 33

KALIS_SLIM_BY_DEPTH

Type of limitation on the search treep. 33

KALIS_SLIM_BY_NODESType of limitation on the search tree

p. 32

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

30

Constants

KALIS_SLIM_BY_SOLUTIONSType of limitation on the search treep. 33

KALIS_SLIM_BY_TIME

Type of limitation on the search treep. 33

KALIS_SLIM_UNREACHED

Type of limitation on the search tree

p. 32

KALIS_SMALLEST_DOMAIN

Smallest domain variable selection heuristic (finite domain andcontinuous variables)

p. 37

KALIS_SMALLEST_ECT

Smallest Earliest Completion time task selection heuristic

p. 41

KALIS_SMALLEST_EST

Smallest Earliest Start time task selection heuristic

p. 41

KALIS_SMALLEST_LCT

Smallest Latest Completion time task selection heuristic

p. 41

KALIS_SMALLEST_LST

Smallest Latest Start time task selection heuristic

p. 42

KALIS_SMALLEST_MAX

Smallest maximum variable selection heuristic

p. 38

KALIS_SMALLEST_MIN

Smallest minimum variable selection heuristic

p. 38

KALIS_SOLVE_AS_LP

Use LP relaxation

p. 51

KALIS_SOLVE_AS_MIP

Use MIP relaxation

p. 51

KALIS_TASK_INPUT_ORDER

Input order task selection heuristic

p. 43

KALIS_TASK_INTERVALS

Task intervals propagation type for resource constraints

p. 45

KALIS_TASK_RANDOM_ORDER

Random order task selection heuristic

p. 43

KALIS_TIMETABLING

Timetabling propagation type for resource constraints

p. 44

KALIS_TLIM_ABS_OPTLimitation on the optimization through absolute tolerance

p. 34

KALIS_TLIM_REL_OPT

Limitation on the optimization through relative tolerance

p. 34

KALIS_TLIM_UNREACHED

No limitation on the optimization due to tolerance limits

p. 34

KALIS_TOPNODE_RELAX_SOLVER Top node relaxation solver configuration

p. 48

KALIS_TREENODE_RELAX_SOLVER Tree node relaxation solver configuration

p. 49

KALIS_UNARY_RESOURCE

Unary resource

p. 40

KALIS_WIDEST_DOMAIN

Widest domain variable selection heuristic (continuous variables) p. 38

KALIS_FORWARD_CHECKING
Description

Forward checking propagation type for the all_different constraint

Type

Integer, read only

Values0

NotesThis constant is passed to the all_different constraint to specify the kind of
propagation used to filter it. When KALIS_FORWARD_CHECKING is used, the filtering
algorithm achieves a very simple, and fast, filtering. Although less powerful than thegeneralized algorithm (KALIS_GEN_ARC_CONSISTENCY) that may lead to a stronger
pruning, the speed of the KALIS_FORWARD_CHECKING filtering allows the search
process to explore more nodes in the same amount of time which makes the algorithm
competitive for simple problems.

See also

all_different KALIS_GEN_ARC_CONSISTENCYFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

31

Constants

KALIS_GEN_ARC_CONSISTENCY
Description

Generalized arc consistency propagation type for the all_different constraint

Type

Integer, read only

Values3

Notes

This constant is passed to the all_different constraint to specify the kind of
propagation used to filter it. When KALIS_GEN_ARC_CONSISTENCY is used, the filtering
algorithm achieves generalized arc-consistency (cf. [R9́4]). Although this algorithm may
filter more values than the KALIS_FORWARD_CHECKING algorithm, this additional
pruning comes at the price of a computational overhead at each node that is notnecessary for simple problems.

See also

all_different KALIS_FORWARD_CHECKING

KALIS_SLIM_UNREACHED
Description

Type of limitation on the search tree

Type

Integer, read only

Values0

NotesThis constant represents the value of the parameter KALIS_SEARCH_LIMIT when nolimitation of the search process has occurred.

See also

KALIS_SLIM_BY_NODES KALIS_SLIM_BY_SOLUTIONS KALIS_SLIM_BY_DEPTH
KALIS_SLIM_BY_TIME KALIS_SLIM_BY_BACKTRACKSKALIS_SLIM_BY_NODES
Description

Type of limitation on the search tree

Type

Integer, read only

Values1

NotesThis constant represents the value of the parameter KALIS_SEARCH_LIMIT when the
maximum number of nodes allowed for the search process has been reached.

See also

KALIS_SLIM_BY_NODES KALIS_SLIM_BY_SOLUTIONS KALIS_SLIM_BY_DEPTH
KALIS_SLIM_BY_TIME KALIS_SLIM_BY_BACKTRACKSFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

32

Constants

KALIS_SLIM_BY_SOLUTIONS
Description

Type of limitation on the search tree

Type

Integer, read only

Values2

NotesThis constant represents the value of the parameter KALIS_SEARCH_LIMIT when the
maximum number of solutions to be found during the search process has been reached.

See also

KALIS_SLIM_BY_NODES KALIS_SLIM_BY_SOLUTIONS KALIS_SLIM_BY_DEPTH
KALIS_SLIM_BY_TIME KALIS_SLIM_BY_BACKTRACKSKALIS_SLIM_BY_DEPTH
Description

Type of limitation on the search tree

Type

Integer, read only

Values3

Notes

This constant represents the value of the parameter KALIS_SEARCH_LIMIT when the
maximum depth of the search tree has been reached.

See also

KALIS_SLIM_BY_NODES KALIS_SLIM_BY_SOLUTIONS KALIS_SLIM_BY_DEPTH
KALIS_SLIM_BY_TIME KALIS_SLIM_BY_BACKTRACKSKALIS_SLIM_BY_TIME
Description

Type of limitation on the search tree

Type

Integer, read only

Values4

Notes

This constant represents the value of the parameter KALIS_SEARCH_LIMIT when the
maximum computation time allowed to the search process has been reached.

See also

KALIS_SLIM_BY_NODES KALIS_SLIM_BY_SOLUTIONS KALIS_SLIM_BY_DEPTH
KALIS_SLIM_BY_TIME KALIS_SLIM_BY_BACKTRACKSKALIS_SLIM_BY_BACKTRACKSDescription

Type of limitation on the search tree

Type

Integer, read only

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

33

Constants

Values5

NotesThis constant represents the value of the parameter KALIS_SEARCH_LIMIT when the
maximum number of backtracks was reached during the search process and the search
process was interrupted.

See also

KALIS_SLIM_BY_NODES KALIS_SLIM_BY_SOLUTIONS KALIS_SLIM_BY_DEPTH
KALIS_SLIM_BY_TIME KALIS_SLIM_BY_BACKTRACKSKALIS_TLIM_UNREACHED
Description

No limitation on the optimization due to tolerance limits

Type

Integer, read only

Values0

NotesThis constant represents the value of the parameter KALIS_TOLERANCE_LIMIT when nolimitation of the optimization process has occurred.

See also

KALIS_TLIM_UNREACHED KALIS_TLIM_ABS_OPT KALIS_TLIM_REL_OPT

KALIS_TLIM_ABS_OPT
Description

Limitation on the optimization through absolute tolerance

Type

Integer, read only

Values1

NotesThis constant represents the value of the parameter KALIS_TOLERANCE_LIMIT when the
search process has been interrupted due to an absolute tolerance limit.

See also

KALIS_TLIM_UNREACHED KALIS_TLIM_ABS_OPT KALIS_TLIM_REL_OPT

KALIS_TLIM_REL_OPT
Description

Limitation on the optimization through relative tolerance

Type

Integer, read only

Values2

NotesThis constant represents the value of the parameter KALIS_TOLERANCE_LIMIT when the
search process has been interrupted due to a relative tolerance limit

See also

KALIS_TLIM_UNREACHED KALIS_TLIM_ABS_OPTFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

34

Constants

KALIS_INPUT_ORDER
Description

Input Order variable selection heuristic

Type

String, read only

Values*a

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the variable selection heuristic. The input order heuristic selects
non-instantiated variables with the smallest index for indexed containers and in theorder of iteration for ordered containers such as lists and arrays.

See also

KALIS_MAX_DEGREE KALIS_LARGEST_MIN KALIS_LARGEST_MAX KALIS_MAXREGRET_LB
KALIS_MAXREGRET_UB KALIS_RANDOM_VARIABLE KALIS_SDOMDEG_RATIOKALIS_SMALLEST_DOMAIN KALIS_SMALLEST_MAX KALIS_SMALLEST_MIN

KALIS_MAX_DEGREE
Description

Maximum constraint graph degree variable selection heuristic

Type

String, read only

Values*b

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the variable selection heuristic. The max degree heuristic selects
non-instantiated variables with the largest degree in the constraint graph (i.e., that are
involved in the maximum number of different constraints).

See also

KALIS_INPUT_ORDER KALIS_LARGEST_MIN KALIS_LARGEST_MAX KALIS_MAXREGRET_LB
KALIS_MAXREGRET_UB KALIS_RANDOM_VARIABLE KALIS_SDOMDEG_RATIOKALIS_SMALLEST_DOMAIN KALIS_SMALLEST_MAX KALIS_SMALLEST_MIN

KALIS_LARGEST_MIN
Description

Largest minimum variable selection heuristic

Type

String, read only

Values*c

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the variable selection heuristic. The largest min heuristic selects
non-instantiated variables with the largest lower bound.

See also

KALIS_INPUT_ORDER KALIS_MAX_DEGREE KALIS_LARGEST_MAX KALIS_MAXREGRET_LB
KALIS_MAXREGRET_UB KALIS_RANDOM_VARIABLE KALIS_SDOMDEG_RATIOKALIS_SMALLEST_DOMAIN KALIS_SMALLEST_MAX KALIS_SMALLEST_MIN

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

35

Constants

KALIS_LARGEST_MAX
Description

Largest maximum variable selection heuristic

Type

String, read only

Values*d

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the variable selection heuristic. The largest maximum heuristic selects
non-instantiated variables with the largest upper bound.

See also

KALIS_INPUT_ORDER KALIS_MAX_DEGREE KALIS_LARGEST_MIN KALIS_MAXREGRET_LB
KALIS_MAXREGRET_UB KALIS_RANDOM_VARIABLE KALIS_SDOMDEG_RATIOKALIS_SMALLEST_DOMAIN KALIS_SMALLEST_MAX KALIS_SMALLEST_MIN

KALIS_MAXREGRET_LB
Description

Maximum regret on the lower bound variable selection heuristic

Type

String, read only

Values*e

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the variable selection heuristic. This variable selection will select the variablemaximizing the distance between its lower bound and its second-smallest value.

See also

KALIS_INPUT_ORDER KALIS_MAX_DEGREE KALIS_LARGEST_MIN KALIS_LARGEST_MAX
KALIS_MAXREGRET_UB KALIS_RANDOM_VARIABLE KALIS_SDOMDEG_RATIOKALIS_SMALLEST_DOMAIN KALIS_SMALLEST_MAX KALIS_SMALLEST_MIN

KALIS_MAXREGRET_UB
Description

Maximum regret on the upper bound variable selection heuristic

Type

String, read only

Values*f

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the variable selection heuristic. This variable selection will select the variablemaximizing the distance between its upper bound and the second-largest value.

See also

KALIS_INPUT_ORDER KALIS_MAX_DEGREE KALIS_LARGEST_MIN KALIS_LARGEST_MAX
KALIS_MAXREGRET_LB KALIS_RANDOM_VARIABLE KALIS_SDOMDEG_RATIOKALIS_SMALLEST_DOMAIN KALIS_SMALLEST_MAX KALIS_SMALLEST_MIN

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

36

Constants

KALIS_RANDOM_VARIABLE
Description

Random variable selection heuristic

Type

String, read only

Values*g

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the variable selection heuristic. The random variable heuristic selects
non-instantiated variables in a random order.

See also

KALIS_INPUT_ORDER KALIS_MAX_DEGREE KALIS_LARGEST_MIN KALIS_LARGEST_MAX
KALIS_MAXREGRET_LB KALIS_MAXREGRET_UB KALIS_SDOMDEG_RATIO KALIS_SMALLEST_DOMAINKALIS_SMALLEST_MAX KALIS_SMALLEST_MIN

KALIS_SDOMDEG_RATIO
Description

Smallest domain size to degree ratio variable selection heuristic.

Type

String, read only

Values*h

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the variable selection heuristic. This heuristic selects the variable having thesmallest domain size to degree ratio. The degree of a variable is defined as the numberof constraints using this variable.

See also

KALIS_INPUT_ORDER KALIS_MAX_DEGREE KALIS_LARGEST_MIN KALIS_LARGEST_MAX
KALIS_MAXREGRET_LB KALIS_MAXREGRET_UB KALIS_RANDOM_VARIABLE
KALIS_SMALLEST_DOMAIN KALIS_SMALLEST_MAX KALIS_SMALLEST_MIN

KALIS_SMALLEST_DOMAIN
Description

Smallest domain variable selection heuristic (finite domain and continuous variables)

Type

String, read only

Values*i

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the variable selection heuristic. The smallest domain heuristic selects non
instantiated variables with the smallest domain size (number of distinct values in thedomain).

See also

KALIS_INPUT_ORDER KALIS_MAX_DEGREE KALIS_LARGEST_MIN KALIS_LARGEST_MAX
KALIS_MAXREGRET_LB KALIS_MAXREGRET_UB KALIS_RANDOM_VARIABLE KALIS_SDOMDEG_RATIOKALIS_SMALLEST_MAX KALIS_SMALLEST_MIN KALIS_WIDEST_DOMAIN

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

37

Constants

KALIS_SMALLEST_MAX
Description

Smallest maximum variable selection heuristic

Type

String, read only

Values*j

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the variable selection heuristic. The smallest maximum heuristic selects non
instantiated variables with the smallest upper bound.

See also

KALIS_INPUT_ORDER KALIS_MAX_DEGREE KALIS_LARGEST_MIN KALIS_LARGEST_MAX
KALIS_MAXREGRET_LB KALIS_MAXREGRET_UB KALIS_RANDOM_VARIABLE KALIS_SDOMDEG_RATIOKALIS_SMALLEST_DOMAIN KALIS_SMALLEST_MIN

KALIS_SMALLEST_MIN
Description

Smallest minimum variable selection heuristic

Type

String, read only

Values*k

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the variable selection heuristic. The smallest mininimum heuristic selects non
instantiated variables with the smallest lower bound.

See also

KALIS_INPUT_ORDER KALIS_MAX_DEGREE KALIS_LARGEST_MIN KALIS_LARGEST_MAX
KALIS_MAXREGRET_LB KALIS_MAXREGRET_UB KALIS_RANDOM_VARIABLE KALIS_SDOMDEG_RATIOKALIS_SMALLEST_DOMAIN KALIS_SMALLEST_MAX

KALIS_WIDEST_DOMAIN
Description

Widest domain variable selection heuristic (continuous variables)

Type

String, read only

Values*l

Notes

Passes this constant to the constructor of branching schemes for continuous decisionvariables (split_domain) to specify the variable selection heuristic. The widest domain
heuristic selects non instantiated variables with the largest value interval.

See also

KALIS_INPUT_ORDER KALIS_MAX_DEGREE KALIS_LARGEST_MIN KALIS_LARGEST_MAX
KALIS_MAXREGRET_LB KALIS_MAXREGRET_UB KALIS_RANDOM_VARIABLE KALIS_SDOMDEG_RATIOKALIS_SMALLEST_DOMAIN KALIS_SMALLEST_MAX KALIS_SMALLEST_MIN

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

38

Constants

KALIS_MAX_TO_MIN
Description

Maximum to minimum value selection heuristic

Type

String, read only

Values+1

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the value selection heuristic. The max to min heuristic selects values indecreasing order.

See also

KALIS_MIN_TO_MAX KALIS_MIDDLE_VALUE KALIS_NEAREST_VALUE KALIS_RANDOM_VALUEKALIS_MIN_TO_MAX
Description

Minimum to maximum value selection heuristic

Type

String, read only

Values+2

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the value selection heuristic. The min to max heuristic selects values inincreasing order.

See also

KALIS_MAX_TO_MIN KALIS_MIDDLE_VALUE KALIS_NEAREST_VALUE KALIS_RANDOM_VALUEKALIS_MIDDLE_VALUE
Description

Middle value selection heuristic

Type

String, read only

Values+3

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the value selection heuristic. The middle value heuristic selects the value in thedomain of a variable that minimizes the distance to the median value of the domain.

See also

KALIS_MAX_TO_MIN KALIS_MIN_TO_MAX KALIS_NEAREST_VALUE KALIS_RANDOM_VALUEKALIS_NEAREST_VALUE
Description

Nearest to target value selection heuristic

Type

String, read only

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

39

Constants

Values+4

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the value selection heuristic. The nearest value heuristic selects the value inthe domain of a variable that minimizes the distance to the target value of the variable.

See also

KALIS_MAX_TO_MIN KALIS_MIN_TO_MAX KALIS_MIDDLE_VALUE KALIS_RANDOM_VALUEKALIS_RANDOM_VALUE
Description

Random value selection heuristic

Type

String, read only

Values+5

Notes

Passes this constant to the constructor of branching schemes (for example assign_var)
to specify the value selection heuristic. The random value heuristic selects a random
value in the domain of a variable.

See also

KALIS_MAX_TO_MIN KALIS_MIN_TO_MAX KALIS_MIDDLE_VALUE KALIS_NEAREST_VALUEKALIS_COPYRIGHT
Description

Xpress Kalis copyright information

Type

String, read only

Values(c) Copyrights Artelys S.A. 2000-2013

KALIS_UNARY_RESOURCE
Description

Unary resource

Type

Integer, read only

Values0

Notes

Passes this constant to the set_resource_attributes subroutine to specify a unary
resource (a resource that can be used only by one task at a time).

See also

KALIS_DISCRETE_RESOURCEKALIS_DISCRETE_RESOURCE
Description

Discrete resource

Type

Integer, read only

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

40

Constants

Values1

Notes

Passes this constant to the set_resource_attributes subroutine to specify a discrete
resource (a resource than can be used by several tasks at the same time).

See also

KALIS_UNARY_RESOURCEKALIS_SMALLEST_ECT
Description

Smallest Earliest Completion time task selection heuristic

Type

String, read only

Values$1

Notes

Passes this constant to the constructor of task_serialize to specify the task selection
heuristic.

See also

KALIS_SMALLEST_ECT KALIS_SMALLEST_EST KALIS_SMALLEST_LCT KALIS_SMALLEST_LST
KALIS_LARGEST_ECT KALIS_LARGEST_EST KALIS_LARGEST_LCT KALIS_LARGEST_LST

KALIS_SMALLEST_EST
Description

Smallest Earliest Start time task selection heuristic

Type

String, read only

Values$2

Notes

Passes this constant to the constructor of task_serialize to specify the task selection
heuristic.

See also

KALIS_SMALLEST_ECT KALIS_SMALLEST_EST KALIS_SMALLEST_LCT KALIS_SMALLEST_LST
KALIS_LARGEST_ECT KALIS_LARGEST_EST KALIS_LARGEST_LCT KALIS_LARGEST_LST

KALIS_SMALLEST_LCT
Description

Smallest Latest Completion time task selection heuristic

Type

String, read only

Values$3

Notes

Passes this constant to the constructor of task_serialize to specify the task selection
heuristic.

See also

KALIS_SMALLEST_ECT KALIS_SMALLEST_EST KALIS_SMALLEST_LCT KALIS_SMALLEST_LST
KALIS_LARGEST_ECT KALIS_LARGEST_EST KALIS_LARGEST_LCT KALIS_LARGEST_LST

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

41

Constants

KALIS_SMALLEST_LST
Description

Smallest Latest Start time task selection heuristic

Type

String, read only

Values$4

Notes

Passes this constant to the constructor of task_serialize to specify the task selection
heuristic.

See also

KALIS_SMALLEST_ECT KALIS_SMALLEST_EST KALIS_SMALLEST_LCT KALIS_SMALLEST_LST
KALIS_LARGEST_ECT KALIS_LARGEST_EST KALIS_LARGEST_LCT KALIS_LARGEST_LST

KALIS_LARGEST_ECT
Description

Largest Earliest Completion time task selection heuristic

Type

String, read only

Values$5

Notes

Passes this constant to the constructor of task_serialize to specify the task selection
heuristic.

See also

KALIS_SMALLEST_ECT KALIS_SMALLEST_EST KALIS_SMALLEST_LCT KALIS_SMALLEST_LST
KALIS_LARGEST_ECT KALIS_LARGEST_EST KALIS_LARGEST_LCT KALIS_LARGEST_LST

KALIS_LARGEST_EST
Description

Largest Earliest Start time task selection heuristic

Type

String, read only

Values$6

Notes

Passes this constant to the constructor of task_serialize to specify the task selection
heuristic.

See also

KALIS_SMALLEST_ECT KALIS_SMALLEST_EST KALIS_SMALLEST_LCT KALIS_SMALLEST_LST
KALIS_LARGEST_ECT KALIS_LARGEST_EST KALIS_LARGEST_LCT KALIS_LARGEST_LST

KALIS_LARGEST_LCT
Description

Largest Latest Completion time task selection heuristic

Type

String, read only

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

42

Constants

Values$7

Notes

Passes this constant to the constructor of task_serialize to specify the task selection
heuristic.

See also

KALIS_SMALLEST_ECT KALIS_SMALLEST_EST KALIS_SMALLEST_LCT KALIS_SMALLEST_LST
KALIS_LARGEST_ECT KALIS_LARGEST_EST KALIS_LARGEST_LCT KALIS_LARGEST_LST

KALIS_LARGEST_LST
Description

Largest Latest Start time task selection heuristic

Type

String, read only

Values$8

Notes

Passes this constant to the constructor of task_serialize to specify the task selection
heuristic.

See also

KALIS_SMALLEST_ECT KALIS_SMALLEST_EST KALIS_SMALLEST_LCT KALIS_SMALLEST_LST
KALIS_LARGEST_ECT KALIS_LARGEST_EST KALIS_LARGEST_LCT KALIS_LARGEST_LST

KALIS_TASK_INPUT_ORDER
Description

Input order task selection heuristic

Type

String, read only

Values$9

Notes

Passes this constant to the constructor of task_serialize to specify the task selection
heuristic.

See also

KALIS_TASK_RANDOM_ORDER KALIS_SMALLEST_ECT KALIS_SMALLEST_EST KALIS_SMALLEST_LCTKALIS_SMALLEST_LST KALIS_LARGEST_ECT KALIS_LARGEST_EST KALIS_LARGEST_LCTKALIS_LARGEST_LST

KALIS_TASK_RANDOM_ORDER
Description

Random order task selection heuristic

Type

String, read only

Values$a

Notes

Passes this constant to the constructor of task_serialize to specify the task selection
heuristic.

See also

KALIS_TASK_INPUT_ORDER KALIS_SMALLEST_ECT KALIS_SMALLEST_EST KALIS_SMALLEST_LCTKALIS_SMALLEST_LST KALIS_LARGEST_ECT KALIS_LARGEST_EST KALIS_LARGEST_LCTKALIS_LARGEST_LST

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

43

Constants

KALIS_DISJ_INPUT_ORDER
Description

Input order disjunction selection heuristic

Type

String, read only

Values%0

Notes

Passes this constant to the constructor of settle_disjunction orprobe_settle_disjunction to specify the disjunction selection heuristic.

See also

KALIS_DISJ_PRIORITY_ORDERKALIS_DISJ_PRIORITY_ORDER
Description

Input order disjunction selection heuristic

Type

String, read only

Values%1

Notes

Passes this constant to the constructor of settle_disjunction orprobe_settle_disjunction to specify the disjunction selection heuristic.

See also

KALIS_DISJ_INPUT_ORDERKALIS_TIMETABLING
Description

Timetabling propagation type for resource constraints

Type

Integer, read only

Values1

NotesThis constant is passed to the set_resource_attributes function to specify the kind of
propagation to be used for filtering the resource constraint. The KALIS_TIMETABLING
filtering algorithm achieves a very simple and fast filtering. Although less powerful than
the algorithms KALIS_DISJUNCTIONS (unary resources only) and KALIS_TASK_INTERVALS
that may lead to a stronger pruning, the speed of the KALIS_TIMETABLING filtering
allows the search process to explore more nodes in the same amount of time whichmakes the algorithm competitive for simple problems and also for very large problems
where the computational overhead of other filtering algorithms is prohibitive.

See also

KALIS_TASK_INTERVALS KALIS_DISJUNCTIONS KALIS_EDGE_FINDING

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

44

Constants

KALIS_TASK_INTERVALS
Description

Task intervals propagation type for resource constraints

Type

Integer, read only

Values2

NotesThis constant is passed to the set_resource_attributes procedure to specify the type of
propagation to be used for filtering the resource constraint. The
KALIS_TASK_INTERVALS filtering algorithm achieves a very strong and relatively slow
filtering. Although more powerful than the simple algorithm (KALIS_TIMETABLING), thecomputational cost of the KALIS_TASK_INTERVALS filtering makes it competitive formedium sized hard problems but is prohibitive for large problems with many tasks per
resource (cf. [CL94a], [CL94b]).

See also

KALIS_TIMETABLING KALIS_DISJUNCTIONS KALIS_EDGE_FINDING

KALIS_DISJUNCTIONS
Description

Disjunctions propagation type for unary resource constraints

Type

Integer, read only

Values4

Notes

This constant is passed to the set_resource_attributes procedure to specify the type of
propagation to be used for filtering the resource constraint for unary resources. WithKALIS_DISJUNCTIONS the resource constraint will be implemented as n*(n-1)/2
disjunctions between pairs of tasks. This algorithm is more powerful than the
KALIS_TIMETABLING algorithm but less powerful than the algorithm
KALIS_TASK_INTERVALS that may lead to a stronger pruning at the cost of additional
computation overhead. This algorithm is generally competitive for small to medium size
problems where the number of tasks using the resource is not overly large.

See also

KALIS_TASK_INTERVALS KALIS_TIMETABLING KALIS_EDGE_FINDING

KALIS_EDGE_FINDING
Description

Tasks Interval + Edge finding propagation type for discrete resource constraints

Type

Integer, read only

Values4

Notes

This constant is passed to the set_resource_attributes procedure to specify the kind of
propagation used to filter the resource constraint. When KALIS_EDGE_FINDING is used,
the resource constraint will add Edge finding propagation rules to the Tasks Interval
propgation scheme. This algorithm is more powerful than KALIS_TASK_INTERVALS
algorithm and may lead to a stronger pruning at the cost of additional computation

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

45

Constants

overhead. This algorithm is generally competitive for small to medium size problems
where the number of tasks using the resource is not too large (cf. [LP96], [MVH08]).
See also

KALIS_TASK_INTERVALS KALIS_TIMETABLING KALIS_DISJUNCTIONSKALIS_INITIAL_SOLUTION
Description

Schedule search strategy choice: heuristic solution

Type

Integer, read only

Values0

NotesThis constant is passed to the cp_set_schedule_strategy subroutine to specify the phaseof the algorithm. KALIS_INITIAL_SOLUTION denotes the first phase of the algorithm and
KALIS_OPTIMAL_SOLUTION selects the second phase of the algorithm.

See also

KALIS_OPTIMAL_SOLUTION cp_schedule

KALIS_OPTIMAL_SOLUTION
Description

Schedule search strategy choice: improving bound and prove optimality

Type

Integer, read only

Values1

NotesThis constant is passed to the cp_set_schedule_strategy subroutine to specify the phaseof the algorithm. KALIS_INITIAL_SOLUTION denotes the first phase of the algorithm and
KALIS_OPTIMAL_SOLUTION selects the second phase of the algorithm.

See also

KALIS_INITIAL_SOLUTION cp_schedule

KALIS_RESET_PARAMS_ALL
Description

Group parameter choice for all parameters

Type

Integer, read only

Values0

NotesThis constant is passed to the cp_reset_params procedure to specify the group of control
parameters. KALIS_RESET_PARAMS_ALL resets all variables and strategy parameters:
 KALIS_DEFAULT_LB
 KALIS_DEFAULT_UB
 KALIS_DEFAULT_CONTINUOUS_LB
 KALIS_DEFAULT_CONTINUOUS_UB KALIS_DEFAULT_PRECISION_VALUE

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information46

Constants

 KALIS_DEFAULT_PRECISION_RELATIVITY
 KALIS_AUTO_PROPAGATE KALIS_OPTIMIZE_WITH_RESTART KALIS_DICHOTOMIC_OBJ_SEARCH KALIS_USE_3B_CONSISTENCY KALIS_VERBOSE_LEVEL KALIS_MAX_NODES KALIS_MAX_SOLUTIONS KALIS_MAX_DEPTH
 KALIS_OPT_ABS_TOLERANCE KALIS_OPT_REL_TOLERANCE KALIS_MAX_BACKTRACKS KALIS_MAX_COMPUTATION_TIME KALIS_MAX_NODES_BETWEEN_SOLUTIONSKALIS_RESET_VAR_BOUNDS
Description

Group parameter choice for variable bounds

Type

Integer, read only

Values1

NotesThis constant is passed to the cp_reset_params procedure to specify the group of control
parameters. KALIS_RESET_VAR_BOUNDS resets bounds of discrete and continuous
variables: KALIS_DEFAULT_LB
 KALIS_DEFAULT_UB
 KALIS_DEFAULT_CONTINUOUS_LB
 KALIS_DEFAULT_CONTINUOUS_UB

KALIS_RESET_VAR_PRECISION
Description

Group parameter choice for variable precisions

Type

Integer, read only

Values2

NotesThis constant is passed to the cp_reset_params function to specify the group of control
parameters. KALIS_RESET_VAR_PRECISION resets the precision for continuous variables: KALIS_DEFAULT_PRECISION_VALUE KALIS_DEFAULT_PRECISION_RELATIVITY

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

47

Constants

KALIS_RESET_OPT_PARAMS
Description

Group parameter choice for strategy optimisation

Type

Integer, read only

Values3

Notes

This constant is passed to the cp_reset_params procedure to specify the group of control
parameters. KALIS_RESET_OPT_PARAMS resets mechanisms of search: KALIS_AUTO_PROPAGATE KALIS_OPTIMIZE_WITH_RESTART KALIS_DICHOTOMIC_OBJ_SEARCH KALIS_USE_3B_CONSISTENCYKALIS_RESET_SEARCH_PARAMS
Description

Group parameter choice for strategy properties

Type

Integer, read only

Values4

Notes

This constant is passed to the cp_reset_params procedure to specify the group of control
parameters. KALIS_RESET_SEARCH_PARAMS resets properties of search : KALIS_VERBOSE_LEVEL KALIS_MAX_NODES KALIS_MAX_SOLUTIONS KALIS_MAX_DEPTH
 KALIS_OPT_ABS_TOLERANCE KALIS_OPT_REL_TOLERANCE KALIS_MAX_BACKTRACKS KALIS_MAX_COMPUTATION_TIME KALIS_MAX_NODES_BETWEEN_SOLUTIONSKALIS_TOPNODE_RELAX_SOLVER
Description

Top node relaxation solver configuration

Type

Integer, read only

Values200

Notes

This constant is passed to the get_linrelax_solver function to specify the predefined
relaxation solver configuration. In this configuration, the relaxation is solved only onceat the top node of the search tree.

See also

KALIS_BILEVEL_RELAX_SOLVER KALIS_TREENODE_RELAX_SOLVER

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information48

Constants

KALIS_TREENODE_RELAX_SOLVER
Description

Tree node relaxation solver configuration

Type

Integer, read only

Values201

Notes

This constant is passed to the get_linrelax_solver function to specify the predefined
relaxation solver configuration. In this configuration, the relaxation is solved at allnodes (except the top node) of the search tree.

See also

KALIS_TOPNODE_RELAX_SOLVER KALIS_BILEVEL_RELAX_SOLVER

KALIS_BILEVEL_RELAX_SOLVER
Description

Bilevel node relaxation solver configuration

Type

Integer, read only

Values202

Notes

This constant is passed to the get_linrelax_solver function to specify the predefined
relaxation solver configuration. In this configuration, the relaxation is solved only whena user defined set of variables are instantiated (by default all the cpfloatvars).

See also

KALIS_TOPNODE_RELAX_SOLVER KALIS_TREENODE_RELAX_SOLVER

KALIS_LINEAR_CONSTRAINTS
Description

Set of linear constraints

Type

Integer, read only

Values0

NotesThis constant is passed to the cp_get_linrelax function to specify the type of
constraints to be relaxed.

See also

KALIS_NON_LINEAR_CONSTRAINTS KALIS_LOGICAL_CONSTRAINTSKALIS_DISTANCE_CONSTRAINTS KALIS_ALL_CONSTRAINTS cp_get_linrelax

KALIS_NON_LINEAR_CONSTRAINTS
Description

Set of non linear constraints

Type

Integer, read only

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

49

Constants

Values1

NotesThis constant is passed to the cp_get_linrelax function to specify the type of
constraints to be relaxed.

See also

KALIS_LINEAR_CONSTRAINTS KALIS_LOGICAL_CONSTRAINTS KALIS_DISTANCE_CONSTRAINTSKALIS_ALL_CONSTRAINTS cp_get_linrelax

KALIS_LOGICAL_CONSTRAINTS
Description

Set of logical constraints

Type

Integer, read only

Values2

NotesThis constant is passed to the cp_get_linrelax function to specify the type of
constraints to be relaxed.

See also

KALIS_LINEAR_CONSTRAINTS KALIS_NON_LINEAR_CONSTRAINTSKALIS_DISTANCE_CONSTRAINTS KALIS_ALL_CONSTRAINTS cp_get_linrelax

KALIS_DISTANCE_CONSTRAINTS
Description

Set of the distance constraints

Type

Integer, read only

Values3

Notes

This constant is passed to the cp_get_linrelax function to specify the type of
constraints to be relaxed.

See also

KALIS_LINEAR_CONSTRAINTS KALIS_NON_LINEAR_CONSTRAINTS KALIS_LOGICAL_CONSTRAINTSKALIS_ALL_CONSTRAINTS cp_get_linrelax

KALIS_ALL_CONSTRAINTS
Description

Set of all the constraints

Type

Integer, read only

Values4

Notes

This constant is passed to the cp_get_linrelax function to specify the type of
constraints to be relaxed.

See also

KALIS_LINEAR_CONSTRAINTS KALIS_NON_LINEAR_CONSTRAINTS KALIS_LOGICAL_CONSTRAINTSKALIS_DISTANCE_CONSTRAINTS cp_get_linrelax

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

50

Constants

KALIS_MINIMIZE
Description

Minimize objective in linear relaxation

Type

Integer, read only

Values100

Notes

This constant is passed to the cp_set_linrelax function to specify the sense of objective.

KALIS_MAXIMIZE
Description

Maximize objective in linear relaxation

Type

Integer, read only

Values101

Notes

This constant is passed to the cp_set_linrelax function to specify the sense of objective.

KALIS_SOLVE_AS_LP
Description

Use LP relaxation

Type

Integer, read only

Values10

NotesThis constant is passed to the get_linrelax_solver function to specify the type of
method use.

KALIS_SOLVE_AS_MIP
Description

Use MIP relaxation

Type

Integer, read only

Values11

Notes

This constant is passed to the get_linrelax_solver function to specify the type of
method use.

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

51

Constants

KALIS_RELAX_PRESOLVE
Description

Use presolve for relaxation

Type

Integer, read only

Values

10001

Notes

This constant is passed to the set_linrelax_solver_attribute procedure to select theparameter to set. Possible settings: 1 — use presolve, 0 — presolve off.

KALIS_RELAX_RCOSTS_PROPAG
Description

Use reduced costs for propagation

Type

Integer, read only

Values

10002

Notes

This constant is passed to the set_linrelax_solver_attribute procedure to select theparameter to set. Possible settings: 1 — use reduced cost information, 0 — do not use
reduced costs.

KALIS_RELAX_RELOAD_BASIS
Description

Use reload basis for relaxation

Type

Integer, read only

Values

10003

Notes

This constant is passed to the set_linrelax_solver_attribute procedure to select theparameter to set. Possible settings: 1 — save/reload basis, 0 — do not load any basis.

KALIS_RELAX_GLOBAL
Description

Set global search flag for the linear relaxation

Type

Integer, read only

Values

10004

Notes

This constant is passed to the set_linrelax_solver_attribute procedure to select theparameter to set. Possible settings: 1 — treat problem as MIP, 0 — treat problem as LP(i.e., ignore any MIP information).

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

52

Constants

KALIS_RELAX_ALGORITHM
Description

Set the solution algorithm for the relaxation

Type

Integer, read only

Values

10005

Notes

This constant is passed to the set_linrelax_solver_attribute procedure to select thesolution algorithm, possible values for this parameter: KALIS_PRIMAL_SIMPLEX,KALIS_DUAL_SIMPLEX, KALIS_BARRIER, KALIS_NETWORK_SIMPLEX

See also

KALIS_PRIMAL_SIMPLEX KALIS_DUAL_SIMPLEX KALIS_BARRIER KALIS_NETWORK_SIMPLEXKALIS_RELAX_OPT_TOL
Description

Set the optimality tolerance for the resolution of the linear relaxation solver

Type

Integer, read only

Values

10010

Notes

This constant is passed to the procedure set_linrelax_solver_attribute as value forthe KALIS_RELAX_OPT_TOL parameter.

See also

KALIS_RELAX_OPT_TOL

KALIS_RELAX_MIP_REL_STOP
Description

Set the MIP relative tolerance to optimality for the resolution of the linear relaxation
solverType

Integer, read only

Values

10011

Notes

This constant is passed to the procedure set_linrelax_solver_attribute as value forthe KALIS_RELAX_MIP_REL_STOP parameter.

See also

KALIS_RELAX_MIP_ABS_STOP

KALIS_RELAX_MIP_ABS_STOP
Description

Set the MIP absolute tolerance to optimality for the resolution of the linear relaxation
solverType

Integer, read only

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

53

Constants

Values

10012

Notes

This constant is passed to the procedure set_linrelax_solver_attribute as value forthe KALIS_RELAX_MIP_ABS_STOP parameter.

See also

KALIS_RELAX_MIP_REL_STOP

KALIS_PRIMAL_SIMPLEX
Description

Set the solution algorithm for the relaxation to primal simplex

Type

Integer, read only

Values

20001

Notes

This constant is passed to the procedure set_linrelax_solver_attribute as value forthe KALIS_RELAX_ALGORITHM parameter.

See also

KALIS_RELAX_ALGORITHM

KALIS_DUAL_SIMPLEX
Description

Set the solution algorithm for the relaxation to dual simplex

Type

Integer, read only

Values

20002

Notes

This constant is passed to the procedure set_linrelax_solver_attribute as value forthe KALIS_RELAX_ALGORITHM parameter.

See also

KALIS_RELAX_ALGORITHM

KALIS_BARRIER
Description

Set the solution algorithm for the relaxation to barrier

Type

Integer, read only

Values

20003

Notes

This constant is passed to the procedure set_linrelax_solver_attribute as value forthe KALIS_RELAX_ALGORITHM parameter.

See also

KALIS_RELAX_ALGORITHM

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

54

Constants

KALIS_NETWORK_SIMPLEX
Description

Set the solution algorithm for the relaxation to network simplex

Type

Integer, read only

Values

20004

Notes

This constant is passed to the procedure set_linrelax_solver_attribute as value forthe KALIS_RELAX_ALGORITHM parameter.

See also

KALIS_RELAX_ALGORITHM

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

55

C HAPTER 8Parameters
KALIS_AUTO_PROPAGATE

Propagates automaticallyp. 57

KALIS_AUTO_RELAX

Use linear relaxation automaticallyp. 64

KALIS_BACKTRACKS

Number of backtracks

p. 59

KALIS_CHECK_SOLUTION

Automated solution checking

p. 62

KALIS_COMPUTATION_TIME

Computation time

p. 59

KALIS_DEFAULT_CONTINUOUS_LB Default lower bound for domains of cpfloatvar

p. 62

KALIS_DEFAULT_CONTINUOUS_UB Default upper bound for domains of cpfloatvar

p. 62

KALIS_DEFAULT_LB

Default lower bound for finite domain variables

p. 57

KALIS_DEFAULT_PRECISION_RELATIVITY Precision relativity for continuous variables

p. 63

KALIS_DEFAULT_PRECISION_VALUE Default precision for continuous variables

p. 63

KALIS_DEFAULT_SCHEDULE_HORIZ_MAX Default maximal time horizon for schedules

p. 63

KALIS_DEFAULT_SCHEDULE_HORIZ_MIN Default minimal time horizon for schedules

p. 63

KALIS_DEFAULT_UB

Default upper bound for finite domain variables

p. 57

KALIS_DEPTH

Depth of tree search

p. 58

KALIS_DICHOTOMIC_OBJ_SEARCH Uses a dichotomic strategy to find the optimal objective valuep. 64
Maximum number of backtracks

p. 60

KALIS_MAX_COMPUTATION_TIME Maximum computation timep. 61

KALIS_MAX_BACKTRACKSKALIS_MAX_DEPTH

Maximum depthp. 60

KALIS_MAX_NODES

Maximum number of nodes

p. 59

KALIS_MAX_NODES_BETWEEN_SOLUTIONS

Number of nodes between two solutions

p. 61

KALIS_MAX_SOLUTIONS

Maximum number of solutions

KALIS_NARY_OBJ_SEARCH

Uses an n-ary search strategy to find the optimal objective value p. 65

KALIS_NODESCounter for number of nodes

p. 58

KALIS_OPT_ABS_TOLERANCE

Absolute optimality tolerance

p. 61

KALIS_OPT_REL_TOLERANCE

Relative optimality tolerance

p. 61

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

p. 60

56

Parameters

KALIS_OPTIMIZE_WITH_RESTART Whether to restart search after each solution

p. 58

KALIS_SCHEDULE_ENABLE_SHAVING Enable shaving during initial step of schedule search

p. 65

KALIS_SEARCH_LIMIT

Search limit reached

p. 58

KALIS_THREADS

Number of threads

p. 65

KALIS_TOLERANCE_LIMIT

Tolerance limit reached

p. 59

KALIS_USE_3B_CONSISTENCY Activates 3B consistency for continuous variables

p. 64

KALIS_VERBOSE_LEVEL

Verbosity level of Xpress Kalis

p. 64

KALIS_DEFAULT_LB
Description

Default lower bound for finite domain variables

Type

Integer, read/write

Values-10000

Notes

Sets the default lower bound for the initial domain of enumerated domain decisionvariables.

See also

KALIS_DEFAULT_UB getlb

default value

KALIS_DEFAULT_UB
Description

Default upper bound for finite domain variables

Type

Integer, read/write

Values+10000

Notes

Sets the default upper bound for the initial domain of enumerated domain decisionvariables.

See also

KALIS_DEFAULT_LB getub

default value

KALIS_AUTO_PROPAGATE
Description

Propagates automaticallyType

Boolean, read/write

Values

true

Notes

Enables propagating constraints instead of posting them or searching for solutions.
Note that domain definition of decision variables is always taken into accountirrespective of whether this control is on or off.

See also

cp_propagate cp_post

default value

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

57

Parameters

KALIS_OPTIMIZE_WITH_RESTART
Description

Decides whether to restart the search after each solution or to continue search from thepresent point with the new bound on the objective.

Type

Boolean, read/write

Valuesfalse

Affects routines

cp_minimize cp_maximize

default value (no restart)

KALIS_NODES
Description

Counter for number of nodes

Type

Integer, read only

Notes

Current number of nodes explored by the branch and bound search. This parameter
does not work with cp_schedule.

See also

KALIS_MAX_NODES KALIS_DEPTH KALIS_BACKTRACKS KALIS_COMPUTATION_TIME

KALIS_DEPTH
Description

Depth of tree search

Type

Integer, read only

Notes

Maximal depth of the search tree reached by the branch and bound search. Thisparameter does not work with cp_schedule.

See also

KALIS_MAX_DEPTH KALIS_NODES KALIS_BACKTRACKS KALIS_COMPUTATION_TIME

KALIS_SEARCH_LIMIT
Description

Search limit reachedType

Integer, read only

Notes

Active search limit on the search process if any

See also

KALIS_SLIM_UNREACHED KALIS_SLIM_BY_NODES KALIS_SLIM_BY_SOLUTIONSKALIS_SLIM_BY_DEPTH KALIS_SLIM_BY_TIME KALIS_SLIM_BY_BACKTRACKSFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

58

Parameters

KALIS_TOLERANCE_LIMIT
Description

Tolerance limit reachedType

Integer, read only

Notes

Active tolerance limit on the search process if any

See also

KALIS_TLIM_UNREACHED KALIS_TLIM_ABS_OPT KALIS_TLIM_REL_OPT
KALIS_OPT_REL_TOLERANCE KALIS_OPT_ABS_TOLERANCEKALIS_BACKTRACKSDescription

Number of backtracks

Type

Integer, read only

Notes

Current number of backtracks that occurred during the branch and bound search.

See also

KALIS_MAX_SOLUTIONS KALIS_MAX_NODES KALIS_MAX_COMPUTATION_TIME KALIS_MAX_DEPTH
KALIS_MAX_BACKTRACKS KALIS_MAX_NODES_BETWEEN_SOLUTIONSKALIS_COMPUTATION_TIME
Description

Computation timeType

Double, read only

Notes

Current computation time (in seconds) of the search process.

See also

KALIS_MAX_SOLUTIONS KALIS_MAX_NODES KALIS_MAX_COMPUTATION_TIME KALIS_MAX_DEPTH
KALIS_MAX_BACKTRACKS KALIS_MAX_NODES_BETWEEN_SOLUTIONSKALIS_MAX_NODES
Description

Maximum number of nodes

Type

Integer, read/write

Values-1

Notes

Limits the number of nodes explored during the branch and bound tree search.

Affects routines

cp_find_next_sol cp_minimize cp_maximize

See also

KALIS_NODES KALIS_MAX_SOLUTIONS KALIS_MAX_COMPUTATION_TIME KALIS_MAX_DEPTH
KALIS_MAX_BACKTRACKS KALIS_MAX_NODES_BETWEEN_SOLUTIONS

default value (no limit)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

59

Parameters

KALIS_MAX_SOLUTIONS
Description

Maximum number of solutions

Type

Integer, read/write

Values-1

Notes

Limits the number of solutions to be found during the branch and bound tree search.

Affects routines

cp_find_next_sol cp_minimize cp_maximize

See also

KALIS_MAX_NODES KALIS_MAX_COMPUTATION_TIME KALIS_MAX_DEPTH KALIS_MAX_BACKTRACKSKALIS_MAX_NODES_BETWEEN_SOLUTIONS

default value (no limit)

KALIS_MAX_DEPTH
Description

Maximum depthTypeInteger, read/write

Values

-1
n>0

Notes

Limits the depth of the search tree during the branch and bound search. This parameter
does not work with cp_schedule.

Affects routines

cp_find_next_sol cp_minimize cp_maximize

See also

KALIS_DEPTH KALIS_MAX_SOLUTIONS KALIS_MAX_NODES KALIS_MAX_COMPUTATION_TIME
KALIS_MAX_BACKTRACKS KALIS_MAX_NODES_BETWEEN_SOLUTIONS

default value (no limit)
maximum depth limited to n levels.

KALIS_MAX_BACKTRACKSDescription

Maximum number of backtracks

Type

Integer, read/write

Values-1

Notes

Limits the number of backtracks that can occur during the search process before
termination

Affects routines

cp_find_next_sol cp_minimize cp_maximize

See also

KALIS_BACKTRACKS KALIS_MAX_SOLUTIONS KALIS_MAX_NODES KALIS_MAX_COMPUTATION_TIME
KALIS_MAX_DEPTH KALIS_MAX_NODES_BETWEEN_SOLUTIONS

default value (no limit)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

60

Parameters

KALIS_MAX_COMPUTATION_TIME
Description

Maximum computation timeType

Double, read/write

Values-1

Notes

Limits the maximum computation time (in seconds) allowed to the branch and boundAffects routines

cp_find_next_sol cp_minimize cp_maximize

See also

KALIS_COMPUTATION_TIME KALIS_MAX_SOLUTIONS KALIS_MAX_NODES KALIS_MAX_DEPTH
KALIS_MAX_BACKTRACKS

default value (no limit)

KALIS_MAX_NODES_BETWEEN_SOLUTIONS
Description

Number of nodes between two solutions

Type

Integer, read/write

Notes

Maximum number of nodes explored between two solutions. With cp_schedule thelimit only applies to the last phase of the solution algorithm.

Affects routines

cp_minimize cp_maximize

See also

KALIS_NODES KALIS_MAX_NODES KALIS_MAX_SOLUTIONS KALIS_MAX_COMPUTATION_TIME
KALIS_MAX_DEPTH KALIS_MAX_BACKTRACKSKALIS_OPT_ABS_TOLERANCE
Description

Absolute optimality tolerance

Type

Integer, read/write

Values0

Notes

Enables the search process to stop when the distance between the current solution andthe overall optimum is ensured to be less than KALIS_OPT_ABS_TOLERANCE.

Affects routines

cp_minimize cp_maximize

See also

KALIS_OPT_REL_TOLERANCE

default value (no tolerance)

KALIS_OPT_REL_TOLERANCE
Description

Relative optimality tolerance

Type

Double, read/write

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

61

Parameters

default value (no tolerance)

Values0.0

Notes

Enables the search process to stop when the relative distance between the current
solution and the overall optimum solution is ensured to be less than
KALIS_OPT_REL_TOLERANCE.

Affects routines

cp_minimize cp_maximize

See also

KALIS_OPT_ABS_TOLERANCEKALIS_CHECK_SOLUTION
Description

Automated solution checking

TypeInteger, read/write

Values

false

Notes

Enables the automated checking that the solution found is really a solution

Affects routines

cp_find_next_sol cp_minimize cp_maximize

default value (no solution checking)

KALIS_DEFAULT_CONTINUOUS_LB
Description

Default lower bound for domains of cpfloatvar

Type

Double, read/write

Values-1000000

Notes

Sets the default lower bound for the initial domain of continuous decision variables

See also

KALIS_DEFAULT_CONTINUOUS_UB getlb

default value

KALIS_DEFAULT_CONTINUOUS_UB
Description

Default upper bound for domains of cpfloatvar

Type

Double, read/write

Values+1000000

Notes

Sets the default upper bound for the initial domain of continuous decision variables

See also

KALIS_DEFAULT_CONTINUOUS_LB getub

default value

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

62

Parameters

KALIS_DEFAULT_PRECISION_VALUE
Description

Default precision for continuous variables

Type

Double, read/write

Values

+1e-6

Notes

Default precision for continuous variables

See also

setprecision

default value

KALIS_DEFAULT_PRECISION_RELATIVITY
Description

Precision relativity for continuous variables

Type

Boolean, read/write

Values

false

Notes

Precision relativity for continuous variables

See also

setprecision

default value

KALIS_DEFAULT_SCHEDULE_HORIZ_MIN
Description

Default minimal time horizon for schedules

Type

Integer, read/write

Values0

Notes

Default minimal time horizon for schedules

See also

KALIS_DEFAULT_SCHEDULE_HORIZ_MAX

default value

KALIS_DEFAULT_SCHEDULE_HORIZ_MAX
Description

Default maximal time horizon for schedules

Type

Integer, read/write

Values

10000

Notes

Default maximal time horizon for schedules

See also

KALIS_DEFAULT_SCHEDULE_HORIZ_MIN

default value

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

63

Parameters

KALIS_DICHOTOMIC_OBJ_SEARCH
Description

Uses a dichotomic strategy to find the optimal objective value

Type

Boolean, read/write

Values

false

Notes

Uses a dichotomic strategy to find the optimal objective value. By default the
optimization algorithm imposes an amelioration constraint stating that the objective
value of the solution to be found must be better than the objective value of the bestsolution already found. With a dichotomic optimization strategy, this constraint is
replaced by a binary search tree over the objective variable domain.

Affects routines

cp_minimize cp_maximize

default value

KALIS_USE_3B_CONSISTENCY
Description

Activates 3B consistency for continuous variables

Type

Boolean, read/write

Values

true

Notes

Activates 3B consistency for continuous variables

Affects routines

cp_propagate

default value

KALIS_VERBOSE_LEVEL
Description

Verbosity level of Xpress Kalis

Type

Integer, read/write

Values

0
1
2
3

Notes

Verbosity level of Xpress Kalis

all output disabled
enable summary output printing
more detailed output
debug output

KALIS_AUTO_RELAX
Description

Indicates whether to use linear relaxation automaticallyType

Boolean, read/write

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

64

Parameters

default value

Values

false

Notes

Enables automatic problem relaxation.

See also

cp_propagate cp_post

KALIS_THREADS
Description

Number of threads

Type

Integer, read/write

Values1

Notes

Sets the number of threads to be used during the search process. This parameter MUST
be set before any variable, task or resource is declared/created.

Affects routines

cp_find_next_sol cp_minimize cp_maximize cp_shedule

KALIS_NARY_OBJ_SEARCH
Description

Uses an n-ary search strategy to find the optimal objective value

Type

Boolean, read/write

Values

false

Notes

Uses an n-ary search strategy to find the optimal objective value. By default the
optimization algorithm imposes an amelioration constraint stating that the objective
value of the solution to be found must be better than the objective value of the bestsolution already found. With an n-ary optimization strategy, this constraint is replacedby n search subtrees over the objective variable domain.

Affects routines

cp_minimize cp_maximize

default value

KALIS_SCHEDULE_ENABLE_SHAVING
Description

Enable shaving during initial step of schedule search

Type

Boolean, read/write

Values

true

Notes

Enable shaving during initial step of schedule search. By default the optimization
algorithm shaves the lower bound (for minimization) or upper bound (formaximization) of the objective variable.

Affects routines

cp_scheduledefault value

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

65

C HAPTER 9

Subroutines
9.1

Constraints
abs

Absolute value constraintp. 81

all_different

All different constraint

p. 83

and

Conjunction composite constraint

p. 69

cplinctr

Linear constraints

p. 67

cpnlinctr

Non-linear constraints

p. 75

cumulative

Cumulative constraint

p. 101

cycle

Cycle constraint

p. 85

disjunctive

Disjunctive constraint

p. 103

distance

Distance constraint

p. 79

distribute

Distribute constraint with fixed bounds

p. 99

element

Element constraint

p. 94

equiv

Equivalence composite constraint

p. 71

exp

Exponential of a non-linear expression

p. 78

generic_binary_constraint

Generic Binary constraint

p. 96

generic_nary_constraint

Generic nary constraint

p. 98

implies

Implication composite constraint

p. 73

ln

Natural logarithm of a non-linear expression

p. 77

maximum_minimum

Maximum/minimum constraint

p. 90

occurrenceOccurrence constraint

p. 92

or

Disjunction composite constraint

p. 70

producer_consumer

Producer Consumer constraint

p. 105

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

66

Subroutines

cplinctr
PurposeLinear constraints are arithmetic constraints over decision variables. Linear constraints aredefined with linear expressions combined by arithmetic operators such as =, 6= , ≤ , and ≥ .
Objects of type cplinexp are linear expressions of decision variables. Typically, these objects result
as intermediate objects in the definition of linear constraints.
Linear expressions of decision variables are obtained by applying the operators +, - and * todecision variables and integer values. The standard priority rules used by Mosel apply to theevaluation order of the arithmetic operators. Brackets may be used in the definition of linear
expressions to change this order. The following are examples of valid linear expressions:declarations
A, B: integerx, y: cpvar
z: array(1..10) of cpfloatvar
end-declarations
A*x*B-x + 2*A*y
B*(x-y)(abs(A) + ceil(2.9) + round(-3.4)) * xsum(i in 1..10) z(i)The following definitions are not valid for objects of type cplinexp:x*yln(2) * xy/3

Synopsisx op I with x:cpvar and I:integer and op one of =, ≥ , ≤ , <>x op y with x,y:cpvar and op one of =, ≥ , ≤ , <>z op R with z:cplinexp and R:real and op one of =, ≥ , ≤ , <>z op x with z:cplinexp and x:cpvar and op one of =, ≥ , ≤ , <>z op w with z,w:cplinexp and op one of =, ≥ , ≤ , <>I op x with I:integer and x:cpvar and op one of =, ≥ , ≤R op z with R:real and z:cplinexp and op one of =, ≥ , ≤ , <>x op z with x:cpvar and z:cplinexp and op one of =, ≥ , ≤ , <>I <>z with I:integer and z:cplinexp
x op R with x:cpfloatvar and R:real and op one of ≥ , ≤Return value
A linear constraint combining the two arguments
ExampleThe following example shows how to state different kinds of linear constraints:
model "Linear constraints"
uses "kalis"declarations
N = 3
R = 1..Nx: array(R) of cpvar
c1: cpctr
end-declarations
forall(i in R) do
0 <= x(i); x(i) <= 50

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

67

Subroutines

setname(x(i), "x"+i)
end-do! Automated post+propagationx(1) >= x(3) + 5
writeln(x(1), " ", x(3))! Named constraint (explicit post)
c1:= x(3) >= x(2) + 10
if cp_post(c1) thenwriteln("With constraint c1: ", x)else exit(1)end-if! Stop automated propagation
setparam("kalis_auto_propagate", false)! Automated post w/o propagationx(2) >= 10
writeln("new bound for x2: ", x)if cp_propagate thenwriteln("after propagation: ", x)
end-if! Minimize the value of x(1)if cp_minimize(x(1)) thenwrite("Solution: ")forall(i in R) write(getsol(x(i)), " ")writeln
end-ifend-model
Related topics
getvalFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

68Subroutines

andPurposeThis composite constraint states a conjunction between two constraints C1 and C2 (C1 ∧ C2). The
satisfaction of the resulting constraint is given by the following truth table:
C1
C2
C1 and C2-------------------------false false
false
false true
false
true
false
false
true
true
true

Synopsis
C1 and C2Arguments
C1
C2

the left member constraint of the conjunction
the right member constraint of the conjunction

Return value
A conjunction constraint over C1 and C2
ExampleThe following example shows how to use the conjunction constraint
model "Logical constraints"
uses "kalis"! Default bounds for all variables
setparam("KALIS_DEFAULT_LB", 0); setparam("KALIS_DEFAULT_UB", 1)
declarations
a,b: cpvar
end-declarations
setname(a,"a")setname(b,"b")writeln(a,b)(a >= 1) and (b >= 1) or (a <= 0) and (b >= 1)
while (cp_find_next_sol)
writeln("a:", getsol(a), " b:", getsol(b))
end-model
Related topics
implies and or

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information69

Subroutines

or
PurposeThis composite constraint states a disjunction between two constraints C1 and C2 (C1 ∨ C2). The
satisfaction of the resulting constraint is given by the following truth table:
C1
C2
C1 or C2-------------------------false false
false
false true
true
true
false
true
true
true
true

Synopsis
C1 or C2
Arguments
C1
C2

the left member constraint of the disjunction
the right member constraint of the disjunction

Return value
A disjunction constraint over C1 and C2
ExampleThe following example shows how to use the disjunction constraint
model "Logical constraints"
uses "kalis"! Default bounds for all variables
setparam("KALIS_DEFAULT_LB", 0); setparam("KALIS_DEFAULT_UB", 1)
declarations
a,b: cpvar
end-declarations
setname(a,"a")setname(b,"b")writeln(a,b)(a >= 1) and (b >= 1) or (a <= 0) and (b >= 1)
while (cp_find_next_sol)
writeln("a:", getsol(a), " b:", getsol(b))
end-model
Related topics
implies and or

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information70Subroutines

equiv
PurposeThis composite constraint states an equivalence between two constraints C1 and C2 (C1 ⇔ C2),
which are not individually posted. The satisfaction of the resulting constraint is given by thefollowing truth table:
C1
C2
C1 equiv C2-------------------------false false
true
false true
false
true
false
false
true
true
true

Synopsisfunction equiv(C1:cpctr,C2:cpctr) :Arguments
C1
C2

cpctr

the left member constraint of the equivalence
the right member constraint of the equivalence

Return value
An equivalence constraint over C1 and C2
ExampleThe following example shows how to use the equivalence constraint
model "Logical constraints"
uses "kalis"! Default bounds for all variables
setparam("KALIS_DEFAULT_LB", 0); setparam("KALIS_DEFAULT_UB", 5)
declarations
A, B, C, D, E: cpctr
x,y,z,b: cpvar
end-declarations
setname(b, "b"); setname(x, "x")setname(y, "y"); setname(z, "z")b <= 1! Definition of constraints (without posting)
A:= x >= y + 5 + z + b
B:= b = 1
C:= all_different({x, y, z})! Cannot be used with ’equiv’
D:= y <= z
E:= distance(y,z) <= 2writeln("Original domains: ", b, " ", x, " ", y, " ", z)! If x, y and z are all different then b equals 1 (C=>B),! if b equals 1 then x, y and z are all different (B=>C).
implies(C, B)
implies(B, C)! E<=>B: b equals 1 if and only if |y-z| <= 2

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

71

Subroutines

equiv(E, B)! A<=>D: x >= y + 5 + z + b if and only if y <= zequiv(A, D)
writeln("With constraints: ", b, " ", x, " ", y, " ", z)while (cp_find_next_sol)
writeln("Solution: ", b, " ", x, " ", y, " ", z)
end-model
Related topics
implies and or

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information72

Subroutines

implies
PurposeThis composite constraint states an implication between two constraints C1 and C2 (C1 ⇒ C2),
which are not individually posted. The satisfaction of the resulting constraint is given by thefollowing truth table:
C1
C2
C1 implies C2-------------------------false false
true
false true
true
true
false
false
true
true
true

Synopsisfunction implies(C1:cpctr, C2:cpctr) :Arguments
C1
C2

cpctr

the left member constraint of the implication
the right member constraint of the implication

Return value
An implication constraint over C1 and C2
ExampleThe following example shows how to use the implication constraint
model "Logical constraints"
uses "kalis"! Default bounds for all variables
setparam("KALIS_DEFAULT_LB", 0); setparam("KALIS_DEFAULT_UB", 5)
declarations
A, B, C, D, E: cpctr
x,y,z,b: cpvar
end-declarations
setname(b, "b"); setname(x, "x")setname(y, "y"); setname(z, "z")b <= 1! Definition of constraints (without posting)
A:= x >= y + 5 + z + b
B:= b = 1
C:= all_different({x, y, z})! Cannot be used with ’equiv’
D:= y <= z
E:= distance(y,z) <= 2writeln("Original domains: ", b, " ", x, " ", y, " ", z)! If x, y and z are all different then b equals 1 (C=>B),! if b equals 1 then x, y and z are all different (B=>C).
implies(C, B)
implies(B, C)! E<=>B: b equals 1 if and only if |y-z| <= 2

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information73

Subroutines

equiv(E, B)! A<=>D: x >= y + 5 + z + b if and only if y <= zequiv(A, D)
writeln("With constraints: ", b, " ", x, " ", y, " ", z)while (cp_find_next_sol)
writeln("Solution: ", b, " ", x, " ", y, " ", z)
end-model
Related topics
equiv and or

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

74

Subroutines

cpnlinctr
PurposeNon-linear constraints are arithmetic constraints over decision variables. Non-linear constraints
are defined with non-linear expressions combined by arithmetic operators such as =, ≤ , and ≥ .
Non-linear expressions of decision variables have the type cpnlinexp. Typically, these objects
result as intermediate objects in the definition of non-linear constraints.
Non-linear expressions of decision variables are obtained by applying the operators +, -, *, div, orfunctions 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.7x1^2 = yexp(x3-x4) 2
ln(x5) = 1(x1*x2^2) div (x4-x3) = 3

Synopsis
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 =, ≥ , ≤Return value
A non-linear constraint combining the two arguments
ExampleThe following example shows how to state different kinds of non-linear constraints:
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-doFair Isaac Corporation and Artelys SA Confidential and Proprietary Information75

Subroutines! 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) thenwriteln("Solution number 1" )cp_show_sol
cp_show_stats
end-ifend-model
Related topics
getvalFair Isaac Corporation and Artelys SA Confidential and Proprietary Information76Subroutinesln
PurposeNatural logarithm of a non-linear expression
Synopsisfunction ln(x:cpnlinexp) : cpnlinexp
function ln(x:cplinexp) : cpnlinexp
function ln(x:cpfloatvar) : cpnlinexp
function ln(x:cpvar) : cpnlinexp
Argumentx

Non-linear expression

Return value
A natural logarithm constraint over a non-linear expression x: y = lnx
Related topics
exp abs

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

77Subroutines

exp
PurposeExponential of a non-linear expression
Synopsisfunction exp(x:cpnlinexp) : cpnlinexp
function exp(x:cplinexp) : cpnlinexp
function exp(x:cpfloatvar) : cpnlinexp
function exp(x:cpvar) : cpnlinexp
Argumentx

Non-linear expression

Return value
An exponential constraint over a non-linear expression x: y = ex
Related topics
ln absFair Isaac Corporation and Artelys SA Confidential and Proprietary Information78

Subroutines

distance
PurposeThis constraint specifies the distance between two variables.
Synopsisfunction distance(x:cpvar, y:cpvar) :Argument
x,y

0cpabsfinite domain variables

Return value
An absolute value constraint over x and y corresponding to the expressed distance constraint:|x − y|ExampleThe following example shows how to use the distance constraint
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) <= 3writeln("Max distance betw. y and z: ", x,y,z)Dist:= distance(x,z) = 5
if(cp_post(Dist)) thenwriteln("Distance between x and z: ", x,y,z)
else
writeln("Problem is infeasible")
end-ifcp_show_prob
end-model

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

79

Subroutines

Related topics
abs

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

80Subroutines

abs
PurposeThis constraint states that a variable y equals the absolute value of another variable x
Synopsisabs(x) = y with x,y:cpvar
abs(x) op I with x:cpvar and I:integer and op one of =, ≥ , ≤ , <>x = abs(y) with x,y:cpvar
I op abs(x) with I:integer and x:cpvar and op one of =, ≥ , ≤ , <>ArgumentsxyI

absolute value variable (of type cpvar, cpfloatvar, cplinexp, cpnlinexp)
value variable (of the same type as x)
integer value

Return value
An absolute value constraint over the arguments
ExampleThe following example shows how to use the absolute value constraint
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) <= 3writeln("Max distance betw. y and z: ", x,y,z)Dist:= distance(x,z) = 5
if(cp_post(Dist)) thenwriteln("Distance between x and z: ", x,y,z)
else
writeln("Problem is infeasible")
end-ifFair Isaac Corporation and Artelys SA Confidential and Proprietary Information81

Subroutines

cp_show_prob
end-model
Related topics
distance

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

82

Subroutines

all_different
PurposeThe all_different constraint states that all variables in this constraint must be pairwise different:
Synopsisfunction all_different(vars:set of cpvar, propagation: integer) : cpctr
function all_different(vars:set of cpvar) : cpctr
function all_different(vars:array(range) of cpvar, propagation:integer) :function all_different(vars:array(range) of cpvar) : cpctr
function all_different(vars:cpvarlist, propagation:integer) : cpctr
function all_different(vars:cpvarlist) : cpctr
Arguments
vars
propagation

cpctr

the list of variables
Propagation type selected using a constant KALIS_FORWARD_CHECKING,KALIS_GEN_ARC_CONSISTENCY

Return value
An all different constraint over vars
ExampleConsider the following simple problem where one must determine the arrival positions of a set ofsix runners:Dominique, Ignace, Naren, Olivier, Philippe and Pascal.
The constraints are the following:
1. All runners have different positions
2. Olivier is not last
3. Dominique, Pascal, and Ignace are before Naren and Olivier
4. Dominique is better than third
5. Philippe is among the first four
6. Ignace is neither second nor third
7. Pascal is three places higher than Naren
8. Neither Ignace nor Dominique are in fourth position
This problem can be modeled as follows. We create one variable per runner, whose value will be
his arrival position. The initial domains of the variables will be the available arrival positions (1-6).
Since we admit there are no ties, the positions are all pairwise different.
model "all_different example"
uses "kalis"declarations
PEOPLE = {"Sebastian", "Frederic", "Jan-Georg","Krzysztof","Maarten","Luca"} ! Set of speakers
x: array(PEOPLE) of cpvar! Time slot per person
end-declarations
3 <= x("Sebastian") ; x("Sebastian") <= 6
3 <= x("Frederic") ; x("Frederic") <= 4
2 <= x("Jan-Georg") ; x("Jan-Georg") <= 5
2 <= x("Krzysztof") ; x("Krzysztof") <= 4
3 <= x("Maarten");x("Maarten") <= 4
1 <= x("Luca");
x("Luca") <= 6

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

83Subroutines! A different time slot for every person
all_different(x)! Solve the problem
if not(cp_find_next_sol) thenwriteln("Problem is infeasible")exit(1)
end-if! Solution printout
writeln(x)end-model
Related topics
distribute KALIS_GEN_ARC_CONSISTENCY KALIS_FORWARD_CHECKING

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

84

Subroutines

cycle
PurposeThe cycle constraint ensures that the graph implicitly represented by a set of variables (= nodes)
and their domains (= possible successors of a node) contains no sub-tours, that is, tours visiting
only a subset of the nodes. The constraint can take an optional second set of variables Preds,
representing the inverse relation of the Succ function and ensure the following equivalences:succi = j ⇔ predj = i for all i and j. Another optional parameter of the cycle constraint allows totake into account an accumulated quantity along the tour
P such as distance, time or weight. Moreformally, it ensures the following constraint: quantity = i,j distmatrixij for all arcs i → jbelonging to the tour.
Synopsisfunction cycle(succ:array of cpvar) : cpctr
function cycle(succ:array of cpvar, pred:array of cpvar) : cpctr
function cycle(succ:array of cpvar, dist:cpvar, distmatrix:array(range,range) ofinteger) : cpctr
function cycle(succ:array of cpvar, pred:array of cpvar, dist:cpvar,
distmatrix:array(range,range) of integer) : cpctr
Arguments
succ
pred
dist
distmatrix

the list of successors variables
the list of predecessors variables
the accumulated quantity variablea (nodes × nodes) matrix of integers representing the quantity to add to theaccumulated quantity variable when an edge (i,j) belongs to the tour.

Return value
A cycle constraint
ExampleTo illustrate the cycle constraint we show an implementation of the Traveling Salesman Problem(TSP). The objective of the Traveling Salesman Problem (TSP) is to find the shortest tour through agiven set of cities that visits each city exactly once (a Hamiltonian tour). More formally, given a
set of n points and a distance between every pair of points, a solution to the TSP is a path of Nedges, with identical first and last vertices, containing all n points and with minimal total length.
This problem can be modeled as follows: a solution is represented by a function Succ associatingwith each node its immediate successor. We use an array of N variables ’succ(i)’ (one for each cityi ∈ {0, . . . , N − 1}) to represent the next city visited after city number i where the domain of thevariables succ(i) is set to {0, . . . , N − 1} − {i}.
model "TSP"uses "kalis"parameters
S = 14 ! Number of cities to visit
end-parameters
declarations
TC : array(0..3*S) of integer
end-declarations! TSP DATA
TC :: [
1 , 1647,

9610,

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

85

Subroutines

2 , 1647,
3 , 2009,
4 , 2239,
5 , 2523,
6 , 2200,
7 , 2047,
8 , 1720,
9 , 1630,
10, 1405,
11, 1653,
12, 2152,
13, 1941,
14, 2009,

9444,
9254,
9337,
9724,
9605,
9702,
9629,
9738,
9812,
9738,
9559,
9713,
9455]

forward procedure print_solution
setparam("KALIS_DEFAULT_LB", 0)
setparam("KALIS_DEFAULT_UB", S-1)
declarations
CITIES = 0..S-1
succ: array(CITIES) of cpvar
prev: array(CITIES) of cpvar
end-declarations! Set of cities! Array of successor variables! Array of predecessor variables

setparam("KALIS_DEFAULT_UB", 10000)
declarations
dist_matrix: array(CITIES,CITIES) of integer ! Distance matrix
totaldist: cpvar! Total distance of the tour
succpred: cpvarlist! Variable list for branchingend-declarations! Setting the variable names
forall(p in CITIES) do
setname(succ(p),"succ("+p+")")
setname(prev(p),"prev("+p+")")
end-do! Add succesors and predecessors to succpred list for branching
forall(p in CITIES) succpred += succ(p)forall(p in CITIES) succpred += prev(p)! Build the distance matrix
forall(p1,p2 in CITIES | p1<>p2)
dist_matrix(p1,p2) := round(sqrt((TC(3*p2+1) - TC(3*p1+1)) *(TC(3*p2+1) - TC(3*p1+1)) + (TC(3*p2+2) - TC(3*p1+2)) *(TC(3*p2+2) - TC(3*p1+2))))! Set the name of the distance variable
setname(totaldist, "total_distance")! Posting the cycle constraint
cycle(succ, prev, totaldist, dist_matrix)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

86Subroutines! Print all solutions foundcp_set_solution_callback("print_solution")! Set the branching strategy
cp_set_branching(assign_and_forbid("bestregret", "bestneighbor",
succpred))
setparam("KALIS_MAX_COMPUTATION_TIME", 5)! Find the optimal tour
if (cp_minimize(totaldist)) thenif getparam("KALIS_SEARCH_LIMIT")=KALIS_SLIM_BY_TIME thenwriteln("Search time limit reached")
else
writeln("Done!")end-ifend-if!--------------------------------------------------------------! **** Solution printing ****
procedure print_solution
writeln("TOUR LENGTH = ", getsol(totaldist))
thispos:=getsol(succ(0))
nextpos:=getsol(succ(thispos))write(" Tour: ", thispos)
while (nextpos <> getsol(succ(0))) dowrite(" -> ", nextpos)
thispos:=nextpos
nextpos:=getsol(succ(thispos))
end-dowriteln
end-procedure!--------------------------------------------------------------! **** Variable choice ****
function bestregret(Vars: cpvarlist): integer! Get the number of elements of "Vars"
listsize:= getsize(Vars)
minindex := 0
mindist := 0
! Set on uninstantiated variables
forall(i in 1..listsize) do
if not is_fixed(getvar(Vars,i)) thenif (i <= S) thenbestn := getlb(getvar(Vars,i))v:=bestnmval:=dist_matrix(i-1,v)
while (v < getub(getvar(Vars,i))) do
v:=getnext(getvar(Vars,i),v)
if dist_matrix(i-1,v)<=mval thenmval:=dist_matrix(i-1,v)
bestn:=v

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

87Subroutines

end-ifend-dosbestn := getlb(getvar(Vars,i))
mval2:= 10000000
v:=sbestn
if (dist_matrix(i-1,v)<=mval2 and v <> bestn) thenmval2:=dist_matrix(i-1,v)
sbestn:=v
end-ifwhile (v < getub(getvar(Vars,i))) do
v:=getnext(getvar(Vars,i),v)
if (dist_matrix(i-1,v)<=mval2 and v <> bestn) thenmval2:=dist_matrix(i-1,v)
sbestn:=v
end-ifend-doelse
bestn := getlb(getvar(Vars,i))v:=bestnmval:=dist_matrix(v,i-S-1)
while (v < getub(getvar(Vars,i))) do
v:=getnext(getvar(Vars,i),v)
if dist_matrix(v,i-S-1)<=mval thenmval:=dist_matrix(v,i-S-1)
bestn:=v
end-ifend-dosbestn := getlb(getvar(Vars,i))
mval2:= 10000000
v:=sbestn
if (dist_matrix(v,i-S-1)<=mval2 and v <> bestn) thenmval2:=dist_matrix(v,i-S-1)
sbestn:=v
end-ifwhile (v < getub(getvar(Vars,i))) do
v:=getnext(getvar(Vars,i),v)
if (dist_matrix(v,i-S-1)<=mval2 and v <> bestn) thenmval2:=dist_matrix(v,i-S-1)
sbestn:=v
end-ifend-doend-ifdsize := getsize(getvar(Vars,i))rank := integer(10000/ dsize +(mval2 - mval))
if (mindist<= rank) thenmindist := rankminindex := i
end-ifend-ifend-doFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

88Subroutines

returned := minindex
end-function!--------------------------------------------------------------! **** Value choice: choose value resulting in smallest distancefunction bestneighbor(x: cpvar): integer
issucc := false
idx := -1
forall (i in CITIES)
if (is_same(succ(i),x)) thenidx:= iissucc := true
end-ifforall (i in CITIES)
if (is_same(prev(i),x)) thenidx:= i
end-if
if issucc thenreturned:= getlb(x)v:=getlb(x)mval:=dist_matrix(idx,v)
while (v < getub(x)) do
v:=getnext(x,v)
if dist_matrix(idx,v)<=mval thenmval:=dist_matrix(idx,v)
returned:=v
end-ifend-doelse
returned:= getlb(x)v:=getlb(x)mval:=dist_matrix(v,idx)
while (v < getub(x)) do
v:=getnext(x,v)
if dist_matrix(v,idx)<=mval thenmval:=dist_matrix(v,idx)
returned:=v
end-ifend-doend-ifend-function
end-model
Related topics
distribute all_different

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information89

Subroutines

maximum_minimum
PurposeThe maximum (resp) minimum constraint states that a variable z is the maximum (resp) minimumof a list of variables vars
Synopsisminimum(vars) = z or maximum(vars) = z
z = minimum(vars) or z = maximum(vars)
Arguments
vars
zlist of decision variables: {set of cpvar | array(range) of cpvar | cpvarlist}
decision variable for the maximum/minimum: cpvar

Return value
A maximum/minimum constraint over z and vars
ExampleThe following example shows how to use the maximum/minimum constraints:
model "Min and Max"
uses "kalis"declarations
R = 1..5
x: array(R) of cpvar
v, w, y: cpvar
L: cpvarlist
MaxCtr: cpctr
end-declarations
setname(v,"v")setname(w,"w")setname(y,"y")forall(i in R) do
setname(x(i),"x"+i+"")setdomain(x(i), 0, 2*i + round(5*random + 0.5))
end-dowriteln("Initial domains:\n ", x, "", v)

! Minimum constraint with automated postingv = minimum(x)writeln("With minimum constraint:\n ", x, "", v)

x(1) = 2
writeln("Fixing x(1) to 2: ", v)! Maximum constraint with explicit posting
MaxCtr:= w = maximum({x(2), x(3), x(5)})
if cp_post(MaxCtr) thenwriteln("With maximum constraint:\n ", x, "else exit(1)end-ifFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

", w)

90

Subroutines

w <= 7
writeln("Bounding w by 7:\n ", x, "", w)

! Maximum constraint on list of variables
L += x(2); L += x(3); L += x(4)y = maximum(L)writeln("With 2nd maximum constraint:\n ", x, "if (cp_find_next_sol) thenwriteln("A solution:\n ", x, "end-ifend-model", v, "

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information", y)", w, "", y)91

Subroutines

occurrence
PurposeConstrains the number of occurrences of a specific value or a set of values among a list/set ofdecision variables
Synopsis
occurrence(value,vars) op target with target:integer and op one of =, ≥ , ≤target op occurrence(value,vars) with target:integer and op one of =, ≥ , ≤occurrence(value,vars) op occvar with occvar:cpvar and op one of =, ≥ , ≤occvar op occurrence(value,vars) with occvar:cpvar and op one of =, ≥ , ≤occurrence(varset:set of cpvar, values:set of integer, minocc:integer, maxocc:integer)
Arguments
targetoccvarvalue
vars
varsetvaluesminoccmaxoccthe (fixed) target occurrence count for the specified value
the variable occurrence count for the specified value
the integer value whose occurences in the variable list should be constrained
the list of decision variables: {set of cpvar | array of cpvar | cpvarlist}a set of decision variables
a set of values
minimum number of occurrencesmaximum number of occurrences

Return value
An occurrence constraint over the given arguments
ExampleThe following example shows how to use the occurence constraint:model "Cardinality"
uses "kalis"
setparam("KALIS_DEFAULT_LB", 0)declarations
R = 1..6
S = 1..10
x: array(R) of cpvar
y: array(S) of cpvar
a,b,c: cpvar
Card: cpctr
Vlist: cpvarlist
end-declarations
forall(i in R) setname(x(i), "x"+i)
forall(i in 1..3) x(i) = 1
forall(i in 4..6) x(i) <= 10
setname(c, "c")c <= 15
writeln("Initial domains:\n ", x, "", c)

! Explicit posting of an occurrence constraint
Card:= occurrence(1, x) = c

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

92

Subroutines

if cp_post(Card) thenwriteln("With occurrence constraint:\n ", x, "else exit(1)end-ifc = 6
writeln("Fixing occurrence to 6:\n ", x, "

", c)

", c)

forall(i in S) do
setname(y(i), "y"+i)i <= y(i); y(i) <= i*2
end-dosetname(a, "a"); setname(b,"b")writeln("Initial domains:\n ", y, "", a, "", b)

! Occurrence constraint on an array of variables
occurrence(4, y) <= 2
! Occurrence constraint on a list of variables
Vlist += y(1); Vlist += y(2); Vlist += y(4)occurrence(2, Vlist) = 0! Occurrence constraint on a set of variables
occurrence(9, {y(6), y(7), y(9)}) >= 3
! Occurrences bounded by variables
occurrence(5, y) >= aoccurrence(8, {y(4), y(5), y(6), y(7), y(8)}) <= bwriteln("With all constraints:\n ", y, " ", a, " ", b)if cp_find_next_sol thenwriteln("A solution:\n ", y, "end-if", a, "", b)

end-model
Related topics
distribute

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

93

Subroutines

element
PurposeThis constraint states that a variable z is the xth element of an ordered list of integer V, in its
ternary form it states that z is the [x,y]-th element of a matrix of integers M
Synopsis
element(x+I) = C
element(V,x{,I}) = C
element(V,x{,I}) = z with x,z cpvar and I integerz = element(V,x{,I}) with x,z cpvar and I integerelement(M,x,y) = z with x,y,z cpvar
z = element(M,x,y) with x,y,z cpvar
Arguments
C
z
x
y
I
V
M

a constant integer value
the value variable
first index variablesecond index variableoptional constant offset for index
a one-dimensional array of integer values
a matrix (two-dimensional array) of integers

Return value
An element constraint over z, x and y in the ternary form, over x and z in the binary form
ExampleThe following example shows how to use the element constraint:model "Element"
uses "kalis"declarations
RY = 43..52
RX = 1..2
D: array(RY) of integer
D2: array(RX,RY) of integer
x,y,d_of_y,d_of_x_y: cpvar
end-declarations
D :: (43..52)[ 0,

1,

2,

3,

4,

5,

6,

7,

8,

9]

D2:: (1..2,43..52)[10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29]setname(x, "x")setname(y, "y")setname(d_of_y, "d_of_y")
setname(d_of_x_y, "d_of_x_y")
writeln("Original domains: ", x, y, d_of_y, d_of_x_y)
element(D,y) = d_of_yelement(D2,x,y) = d_of_x_y

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

94

Subroutines

writeln("After propagation: ", x, y, d_of_y, d_of_x_y)! Solve the problem
while (cp_find_next_sol) do
nbSolutions += 1
writeln("Solution ", nbSolutions, ": x:", getsol(x)," y:", getsol(y), " d_of_y:", getsol(d_of_y)," d_of_x_y:", getsol(d_of_x_y))
end-dowriteln("done!")end-model

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information95

Subroutines

generic_binary_constraint
PurposeThis constraint can be used to propagate a user-defined constraint over two variables (itspropagation is based on the AC2001 algorithm (cf. [BR01]).
Synopsisfunction generic_binary_constraint(v1:cpvar,v2:cpvar, fctname:string) :Arguments
v1
v2
fctnamecpctr

the first decision variable
the second decision variablename of the function specifying the user-defined constraint, such a function
necessarily takes two cpvar as arguments and returns a Boolean.

Return value
A binary constraint over ’v1’ and ’v2’
ExampleThe following example shows how to use the generic_binary_constraint constraint to solve theclassical Euler Knight Tour problem:
model "Euler Knight Moves"uses "kalis"parameters
S = 8
end-parameters
N:= S * S
setparam("KALIS_DEFAULT_LB", 0)
setparam("KALIS_DEFAULT_UB", N-1)
declarations
PATH = 1..N
pos: array(PATH) of cpvar
end-declarations! No. of rows/columns! Total number of cells! Cells on the board! Position p in tour

! Setting names of decision variables
forall(i in PATH) setname(pos(i), "Position"+i)! Fix the start position
pos(1) = 0! Each cell is visited once
all_different(pos, KALIS_GEN_ARC_CONSISTENCY)! The knight’s path obeys the chess rules for valid knight moves
forall(i in 1..N-1)
generic_binary_constraint(pos(i), pos(i+1), "valid_knight_move")generic_binary_constraint(pos(N), pos(1), "valid_knight_move")! Setting enumeration parameters
cp_set_branching(probe_assign_var(KALIS_SMALLEST_MIN,
KALIS_MAX_TO_MIN, pos, 14))

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information96

Subroutines! Search for up to NBSOL solutions
solct:= 0
if not cp_find_next_sol thenwriteln("No solution")else
writeln(pos)end-if! **** Test whether the move from a to b is admissible ****
function valid_knight_move(a:integer, b:integer): boolean
declarations
xa,ya,xb,yb,delta_x,delta_y: integer
end-declarations
xa := a div S
ya := a mod S
xb := b div S
yb := b mod S
delta_x := abs(xa-xb)
delta_y := abs(ya-yb)
returned := (delta_x<=2) and (delta_y<=2) and (delta_x+delta_y=3)
end-function
end-model

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

97

Subroutines

generic_nary_constraint
PurposeThis constraint can be used to propagate a user-defined constraint over n variables (itspropagation is based on the GAC2001 algorithm (cf. [BR01]).
Synopsisfunction generic_nary_constraint(vars:arrray of cpvar, fctname:string,userparam:integer) : cpctr
function generic_nary_constraint(vars:cpvarlist, fctname:string, userparam:integer) :cpctr
function generic_nary_constraint(vars:arrray of cpvar, fctname:string, propagation:
integer, userparam:integer) : cpctr
function generic_nary_constraint(vars:cpvarlist, fctname:string, propagation:
integer, userparam:integer) : cpctr
function generic_nary_constraint(vars:set of cpvar, fctname:string, userparam:integer): cpctrfunction generic_nary_constraint(vars:set of cpvar, fctname:string, propagation:
integer, userparam:integer) : cpctr
Arguments
vars
fctnameuserparam
propagation

a set, array, or cpvarlist of decision variables
name of the function specifying the user-defined constraint, such a function
necessarily takes a cpvarlist/cptuple and an integer (the value of userparam) asarguments and returns a Boolean.
a user parameterthe level of propagation to achieve

Return value
An n-ary constraint over a set of variables

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information98Subroutines

distribute
PurposeA distribute constraint also known as GCC (Global Cardinality Constraint) over a set of variables isdefined by three arrays called values, lowerBound, and upperBound. The constraint is satisfied if,
and only if, the number of variables of the given set, which are assigned to values[i], is greaterthan or equal to lowerBound[i], and less than or equal to upperBound[i] for all i, and if novariable of the given set is assigned to a value which does not belong to values. The constraint isequivalent, from a modelization point of view, to posting two instances of occurrence constraints
for each value. But this is absolutely not equivalent from a propagation point of view: distributeacquires a far better propagation, using the Regin algorithm.
Synopsisfunction distribute(vars:array of cpvar, values:set of integer, bound:array(integer)of integer) : cpctr
function distribute(vars:array of cpvar, values:set of integer,
lowerBound:array(integer) of integer, upperBound:array(integer) of integer) :cpctr
function distribute(vars:set of cpvar,vals:set of integer, lowerBound:array(integer)of integer, upperBound:array(integer) of integer) : cpctr
function distribute(vars:cpvarlist, vals:set of integer, lowerBound:array(integer) ofinteger, upperBound:array(integer) of integer) : cpctr
Arguments
vars
valueslowerBoundupperBoundbound

Array/set/list of variables
Set of values represented by their names
Array of lower bounds on occurrences
Array of upper bounds on occurrences
Array of occurrence values

Return value
A distribute constraint
ExampleA simple planning problem for personnel in a theater. Suppose that a movie theatre director has
to decide in which location each of his employees should be posted. There are eight employees:
Andrew, David, Jane, Jason, Leslie, Michael, Marilyn and Oliver. There are four locations: theticket office, the first entrance, the second entrance and the coat check. These locations require
three, two, two, and one person respectively. This constraint will be modeled by one distributeconstraint:model "Distribute example"
uses "kalis"declarations
PERS = {"David","Andrew","Leslie","Jason","Oliver","Michael","Jane","Marilyn"}! Set of personnel
LOC = 1..4
! Set of locations
REQ: array(LOC) of integer! No. of pers. req. per loc.
place: array(PERS) of cpvar! Workplace for each peson
end-declarations! Initialize data
REQ:: [3, 2, 2, 1]

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information99

Subroutines! Each variable has a lower bound of 1 (Ticket office) and! an upper bound of 4 (Cloakroom)
forall(p in PERS) do
setname(place(p), "workplace("+p+")")
1 <= place(p); place(p) <= 4
end-do! Creation of a resource constraint of for every location
forall(d in LOC) occurrence(d, place) = REQ(d)! Elegant way to declare theses constraints,! moreover achieving stronger prunning (using global! cardinality constraint)
distribute(place, LOC, REQ)
! Solve the problem
if not(cp_find_next_sol) thenwriteln("Problem is infeasible")exit(1)
end-if! Solution printout
writeln(place)end-model
Related topics
occurrence all_different

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

100Subroutines

cumulative
PurposeThis constraint states that the tasks requiring a resource do not exceed the resource capacity. The
primary use of this constraint is to express resource constraints.
Synopsisfunction cumulative(starts: array(integer) of cpvar, durations:array(integer) of
cpvar, ends: array(integer) of cpvar, usages: array(integer) of cpvar, sizes:
array(integer) of cpvar, C: integer) : cpctr
function cumulative(starts: array(integer) of cpvar, durations:array(integer) of
cpvar, ends: array(integer) of cpvar, usages: array(integer) of cpvar, sizes:
array(integer) of cpvar, C: array(integer) of integer) : cpctr
Arguments
startsends
durationsusagessizes
CArray of variables representing the start times of the tasks
Array of variables representing the completion times of the tasks
Array of variables representing the durations of the tasks
Array of variables representing the resource consumptions of the tasks
Array of variables representing the sizes of the tasks
integer representing the initial capacity of the resource (constant over time orcapacity value for each time period)

Return value
A cumulative constraint ensuring that the maximal resource capacity is never exceded. Moreformally the constraint ensures thatstartsj + durationsj = endsj for all j in Tasks
usagesj · durationsj = sizesj for all j in Tasks
Pj∈Tasks|t∈[UB(startj )..LB(endj )] usagesj ≤ Ct for all times t in the planning period
ExampleThe following example shows how to use the cumulative constraint to express resource
constraints for five tasks using the same resource:
model "Cumulative scheduling"uses "kalis"declarations
TASKS = 1..5
obj : cpvar
starts, ends, durations, usages, sizes : array(TASKS) of cpvar
end-declarations
C := 2
HORIZON := 10! Resource capacity! Time horizon! Setting up the variables representing task properties
forall (t in TASKS) do
starts(t).name:= "T"+t+".start"ends(t).name:= "T"+t+".end"
durations(t).name:= "T"+t+".duration"
sizes(t).name:= "T"+t+".size"
usages(t).name:= "T"+t+".use"

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

101Subroutines

0 <= starts(t); starts(t) <= HORIZON
0 <= ends(t); ends(t) <= HORIZONt <= durations(t); durations(t) <= t+1
1 <= sizes(t); sizes(t) <= 100
1 <= usages(t); usages(t) <= 1
obj >= ends(t)end-do! Cumulative resource constraint
cumulative(starts, durations, ends, usages, sizes, C)! Define the branching strategy
cp_set_branching(assign_var(KALIS_SMALLEST_MIN,KALIS_MIN_TO_MAX))! Solve the problem
if cp_minimize(obj) thencp_show_sol
write("Resource use profile: ")forall(t in TASKS, time in 0..HORIZON)
if (starts(t).sol <= time) and (ends(t).sol > time) thenrload(time) += usages(t).sol
end-ifforall(time in 0..HORIZON) write(rload(time))
writelnelsewriteln("No solution found")end-ifend-model
Related topics
disjunctive settle_disjunction or

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

102

Subroutines

disjunctive
PurposeThis constraint states that the given tasks are not overlapping chronologically.
Synopsisprocedure disjunctive(starts: set of cpvar, durations:array(cpvar) of integer,
disj:set of cpctr, resource:integer)
procedure disjunctive(starts: array(integer) of cpvar, durations:array(integer) of
cpvar, ends: array(integer) of cpvar)
Arguments
startsdurations
ends
disj
resource

Array of variables representing the start times of the tasks
Array of integers representing the durations of the tasks
Array of variables representing the completion times of the tasks
Empty array that will be filled with the list of disjunctions that will be created bythis constraint
Resource flag (argument currently unused)

Return value
A disjunctive constraint ensuring that the tasks defined by ’starts’ and ’durations’ are notoverlapping chronologically.
ExampleThe following example shows how to use the disjunctive constraint to express resource
constraints in a small disjunctive scheduling problem:
model "Disjunctive scheduling with settle_disjunction"
uses "kalis"declarations
NBTASKS = 5
TASKS = 1..NBTASKS
DUR: array(TASKS) of integer
DURs: array(set of cpvar) of integer
DUE: array(TASKS) of integer
WEIGHT: array(TASKS) of integer
start: array(TASKS) of cpvar
tmp: array(TASKS) of cpvar
tardiness: array(TASKS) of cpvar
twt: cpvar
zeroVar: cpvar
Strategy: array(range) of cpbranching
Disj: set of cpctr
end-declarations! Set of tasks! Task durations! Durations! Due dates! Weights of tasks! Start times! Aux. variable! Tardiness! Objective variable! 0-valued variable! Branching strategy! Disjunctions

DUR :: [21,53,95,55,34]
DUE :: [66,101,232,125,150]
WEIGHT :: [1,1,1,1,1]
setname(twt, "Total weighted tardiness")
zeroVar = 0
setname(zeroVar, "zeroVar")! Setting up the decision variables

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

103Subroutines

forall (t in TASKS) do
start(t) >= 0
setname(start(t), "Start("+t+")")
DURs(start(t)):= DUR(t)tmp(t) = start(t) + DUR(t) - DUE(t)setname(tardiness(t), "Tard("+t+")")
tardiness(t) = maximum({tmp(t), zeroVar})
end-dotwt = sum(t in TASKS) (WEIGHT(t) * tardiness(t))! Create the disjunctive constraints
disjunctive(union(t in TASKS) {start(t)}, DURs, Disj, 1)! Define the search strategy
Strategy(1):= settle_disjunction
Strategy(2):= split_domain(KALIS_LARGEST_MIN,KALIS_MIN_TO_MAX)
cp_set_branching(Strategy)
setparam("KALIS_DICHOTOMIC_OBJ_SEARCH",true)
if not(cp_minimize(twt)) thenwriteln("Problem is inconsistent")exit(0)end-ifforall (t in TASKS)
writeln("[", getsol(start(t)), "==>",
getsol(start(t)) + DUR(t), "]:\t ",getsol(tardiness(t)), " (", getsol(tmp(t)), ")")
writeln("Total weighted tardiness: ", getsol(twt))
end-model
Related topics
or settle_disjunction

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

104Subroutines

producer_consumer
PurposeA Producer Consumer Scheduling constraint. More formally the constraint ensures that:
productionsj · durationsj = prodsizesj for all j in Tasks
consumptionsj · durationsj = consosizesj for all j in Tasks
P
j∈R|t∈[UB(startj )..LB(endj )] (productionsj − consumptionsj ) ≤ Ct for all t in Times
Synopsisfunction producer_consumer(starts:array(range) of cpvar, ends:array(range) of cpvar,
durations:array(range) of cpvar, productions:array(range) of cpvar,
prod_sizes:array(range) of cpvar, consumptions:array(range) of cpvar,
conso_sizes:array(range) of cpvar, C:array(range) of integer) : cpctr
Arguments
startsends
durationsproductions
prod_sizes
consumptions
conso_sizes
Carray of starting times
array of ending times
array of durations
array of tasks’ requirements
array of tasks’ productions
array of tasks’ provisions
array of tasks’ consumptions
initial resource capacity array indexed by time

ExampleThe following example shows how to use the producer_consumer constraint for the problem ofplanning the construction of a house (an example of resource-constrained project scheduling).
model "Cumulative Scheduling"uses "kalis"
setparam("KALIS_DEFAULT_LB",0)
setparam("KALIS_DEFAULT_UB",100)
declarations! Task indices
Masonry = 1; Carpentry= 2; Roofing= 3; Windows= 4
Facade = 5; Garden= 6; Plumbing= 7; Ceiling= 8
Painting= 9; MovingIn =10; InitialPayment=11; SecondPayment=12
BUILDTASKS = 1..10
PAYMENTS = 11..12
TASKS = BUILDTASKS+PAYMENTS
TNAMES: array(TASKS) of string
obj:cpvar! Objective variable
starts: array(TASKS) of cpvar! Start times variables
ends: array(TASKS) of cpvar! Completion times
durations: array(TASKS) of cpvar! Durations of tasks
consos: dynamic array(TASKS) of cpvar ! Res. consumptions
sizes: dynamic array(TASKS) of cpvar ! Consumption sizes
prods: dynamic array(TASKS) of cpvar ! Res. production
sizep: dynamic array(TASKS) of cpvar ! Production sizes

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

105Subroutines

Strategy : cpbranchingend-declarations! Branching strategy

TNAMES:: (1..12)["Masonry", "Carpentry", "Roofing", "Windows","Facade", "Garden", "Plumbing", "Ceiling", "Painting","MovingIn", "InitialPayment", "SecondPayment"]! Setting the names of the variables
forall(j in TASKS) do
starts(j).name := TNAMES(j)+".start"ends(j).name := TNAMES(j)+".end"
durations(j).name := TNAMES(j)+".duration"
end-do! Creating consumption variables
forall(j in BUILDTASKS) do
create(sizes(j))
sizes(j).name := TNAMES(j)+".size"
create(consos(j))
consos(j).name := TNAMES(j)+".conso"
end-do! Setting durations of building tasks
durations(Masonry) =7; durations(Carpentry)=3; durations(Roofing) =1
durations(Windows) =1; durations(Facade)=2; durations(Garden) =1
durations(Plumbing)=8; durations(Ceiling) =3; durations(Painting)=2
durations(MovingIn)=1! Precedence constraints among building tasks
starts(Carpentry) >= ends(Masonry)
starts(Roofing)>= ends(Carpentry)
starts(Windows)>= ends(Roofing)starts(Facade)>= ends(Roofing)starts(Garden)>= ends(Roofing)starts(Plumbing) >= ends(Masonry)
starts(Ceiling)>= ends(Masonry)
starts(Painting) >= ends(Ceiling)
starts(MovingIn) >= ends(Windows)
starts(MovingIn) >= ends(Facade)starts(MovingIn) >= ends(Garden)
starts(MovingIn) >= ends(Painting)! Setting task consumptions
consos(Masonry) = 7; consos(Carpentry) = 3; consos(Roofing) = 1
consos(Windows) = 1; consos(Facade)= 2; consos(Garden)= 1
consos(Plumbing) = 8; consos(Ceiling)= 3; consos(Painting) = 2
consos(MovingIn) = 1! Production (amount) of payment tasks
forall(j in PAYMENTS) do
create(prods(j))
prods(j).name := TNAMES(j)+".prod"
create(sizep(j))
sizep(j).name := TNAMES(j)+".sizep"
end-doFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

106Subroutines! Payment data
prods(InitialPayment)= 20; prods(SecondPayment)= 9
durations(InitialPayment) = 1; durations(SecondPayment) = 1
starts(InitialPayment)= 0; starts(SecondPayment)= 15! Objective: makespan of the scheduleobj = maximum({ ends(Masonry) , ends(Carpentry), ends(Roofing),ends(Windows), ends(Facade), ends(Garden), ends(Plumbing),ends(Ceiling), ends(Painting), ends(MovingIn)})! Posting the producer_consumer constraint
producer_consumer(starts,ends,durations,prods,sizep,consos,sizes)! Setting the search strategy
Strategy:= assign_var(KALIS_SMALLEST_MIN, KALIS_MIN_TO_MAX, starts)
cp_set_branching(Strategy)! Find the optimal solution
if cp_minimize(obj) thenwriteln("Minimum makespan: ", obj.sol)
forall(j in BUILDTASKS)
writeln(TNAMES(j), ": ", starts(j).sol, " - ", ends(j).sol)
else
writeln("No solution found")end-ifend-model
Related topics
cumulative

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information107Subroutines

9.2

Constraint parameters
getactivebranch

Gets the active branch of a disjunction

p. 115getarity

Returns the number of variables in the constraint

p. 109getpriority

Returns the priority of a constraint

p. 110gettagGets the tag of a constraint

p. 112

setfirstbranch

Sets the first branch of a disjunction to be activated

p. 114

setpriority

Sets the priority of a constraint

p. 111settagSets the tag of a constraint

p. 113

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

108

Subroutines

getarity
PurposeReturns the number of decision variables involved in the constraint; this function can be used, forinstance, to design advanced search heuristics
Synopsisfunction getarity(ctr:cpctr) :Argument
ctr

integerthe constraint to explore

Return value
The number of variables involved in ctr
ExampleThe following example shows how to get the arity of a constraint
getarity(x + y = 3)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

109Subroutines

getpriority
PurposeReturns the priority of a disjunction passed in argument; this feature is intended for advanced use
in dynamically prioritizing the disjunction for solving (highest priority constraints are handled
first)
Synopsisfunction getpriority(ctr:cpctr) :Argument
ctr

integer

The constraint to explore (disjunction only)

Return value
The associated priority
ExampleThe following example shows how to get the priority of a constraint
getpriority((x + y = 3) or (x + y = 1))
Related topics
setpriority

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

110Subroutines

setpriority
PurposeSets the priority of a constraint passed in argument
Synopsisprocedure setpriority(ctr:cpctr, priority:integer)
Arguments
ctr
priority

the constraint (disjunction only)a user-defined integer (the higher it will be, the quicker the disjunction will be
activated)

ExampleThe following example shows how to set the priority of a constraint:
setpriority((x + y = 3) or (x + y = 1),2)
Related topics
getpriority

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

111

Subroutines

gettagPurposeGets the tag (user-defined integer information) of a constraint
Synopsisfunction gettag(ctr:cpctr) :Argument
ctr

integerthe constraint

Return value
The tag that has been previously associated to it
ExampleThe following example shows how to get the tag of a constraint ctr
writeln(gettag(ctr))
Related topics
settagFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

112

Subroutines

settagPurposeSets the tag (user-defined integer information) of a constraint
Synopsisprocedure settag(ctr:cpctr,tag:integer)
Arguments
ctr
tag

the constraint
the tag

ExampleThe following example shows how to set the tag of a constraint to ’32’
settag(ctr,32)
Related topics
gettagFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

113

Subroutines

setfirstbranch
PurposeThis procedure enables the user to specify the first constraint of a disjunction to be activated;
thus, it is possible to create dynamical heuristics for disjunctions.
Synopsisprocedure setfirstbranch(disj:cpctr, firstbranch:integer)
Arguments
disj
firstbranch

the involved constraint (only a disjunction)
0 to activate the first part and 1 else

Related topics
disjunctive or getactivebranch

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

114

Subroutines

getactivebranch
PurposeThis function enables the user to know which part of a disjunction is active; if the first constraintof the disjunction is satisfied, it returns zero, else it returns one.
Synopsisfunction getactivebranch(disj:cpctr) :Argument
disj

integerthe involved constraint (only a disjunction)

Return value
Zero if the first part of the disjunction is satisfied, one otherwise.
ExampleThe following code shows how to retrieve the active branch information from the disjunction
disj:
b:=getactivebranch(disj)
Related topics
disjunctive or setfirstbranch

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

115

Subroutines

9.3

Variables
contains

Tests if a value is in the domain of a variable

p. 128cp_show_var

Shows the current domain of the variable

p. 137

getdegree

Returns the degree of a variable

p. 123getlb

Returns the current lower bound of a variable

p. 117

getmiddle

Returns the middle value of a variable

p. 119getnext

Gets the next value in the domain of a finite domain variable

p. 126

getprev

Gets the previous value in the domain of a finite domain variable
p. 127

getrandReturns a random value belonging to the domain of a variable

p. 125getsize

Returns the cardinality of the variable domain

p. 120gettarget

Returns the target value of a variable

p. 124getub

Returns the current upper bound of a variable

p. 118getvalReturns the instantiation value of a variable

p. 121

is_equal

Tests if two variable domains are equalp. 129is_fixed

Tests if the variable passed in argument is instantiatedp. 122

is_sameTests if two decision variables represent the same variable

p. 130setdomain

Sets the domain of a variable

p. 132

setlb

Sets the lower bound of a variable

p. 133

setprecision

Sets the precision relativity and value of a continuous variable

p. 136settarget

Sets the target value of a variable

p. 131

setub

Sets the upper bound of a variable

p. 134

setvalInstantiate the value of a variable

p. 135

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

116Subroutines

getlb
PurposeThis function returns the current lower bound of the domain of the variable passed in theargument.
Synopsisfunction getlb(x:cpvar) : integerfunction getlb(x:cpfloatvar) : real
Argumentx

the decision variable

Return value
The current lower bound of variable x
ExampleThe following example shows how to get the lower bound of a cpvar x
val:=getlb(x)Related topics
default_lb getub getmiddle getsize getval is_fixed getdegree gettarget getrand getnext
getprev contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

117

Subroutines

getub
PurposeThis function returns the current upper bound of the domain of the variable passed in theargument.
Synopsisfunction getub(x:cpvar) : integerfunction getub(x:cpfloatvar) : real
Argumentx

the decision variable

Return value
The current upper bound of x
ExampleThe following example shows how to get the upper bound of a cpvar x
val:=getub(x)Related topics
default_ub getlb getmiddle getsize getval is_fixed getdegree gettarget getrand getnext
getprev contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

118

Subroutines

getmiddle
PurposeThis function returns the value nearest to the middle of the domain of the variable passed in theargument. It can be useful for specific search strategies.
Synopsisfunction getmiddle(x:cpvar) : integerfunction getmiddle(x:cpfloatvar) : real
Argumentx

the decision variable

Return value
The middle value of a variable
ExampleThe following example shows how to get the middle value of a cpvar x’
val:=getmiddle(x)Related topics
getlb getub getsize getval is_fixed getdegree gettarget getrand getnext getprev contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

119Subroutines

getsize
PurposeThis function returns the cardinality (number of distinct values) of the domain of the variable
passed in argument in the case of cpvar and the size of the domain interval representation of thedomain in the case of a cpfloatvar.
Synopsisfunction getsize(x:cpvar) : integerfunction getsize(x:cpfloatvar) : integer
Argumentx

the decision variable

Return value
The cardinality / size of the interval representation of the domain of x
ExampleThe following example shows how to get the size of the domain of a cpvar x
sz:=getsize(x)Related topics
getlb getub getmiddle getval is_fixed getdegree gettarget getrand getnext getprev contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information120

Subroutines

getvalPurposeThis function returns the instantiation value of a variable passed in argument. Note that thevariable must be instantiated before calling this function, else it will return its lower bound.
Synopsisfunction getval(x:cpvar) :Argumentx

integerthe decision variable

Return value
The instantiation value of x (or by default its lower bound)
ExampleThe following example shows how to get the instantiation value of a cpvar X
val:=getval(X)Related topics
getlb getub getmiddle getsize is_fixed getdegree gettarget getrand getnext getprev contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

121Subroutines

is_fixed
PurposeReturns true if the variable passed in argument has a domain reduced to a singleton.
Synopsisfunction is_fixed(var:cpvar) : booleanfunction is_fixed(var:cpfloatvar) : boolean
Argumentvar

the decision variable

Return value
true if var has been instantiated
ExampleThe following example shows how to see if a cpvar var is instantiated
if is_fixed(var) thenwrite(’value of var is ’, getval(var))
end-ifRelated topics
getlb getub getmiddle getsize getsol getval getdegree gettarget getrand getnext getprev
contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

122Subroutines

getdegree
PurposeReturns the degree in the constraint graph of the decision variable passed in argument (i.e., thenumber of constraints that involve it); this can be used for advanced search heuristics.
Synopsisfunction getdegree(x:cpvar) : integerfunction getdegree(x:cpfloatvar) : integer
Argumentx

the decision variable

Return value
The degree of x
ExampleThe following example shows how to get the degree of a cpvar x
d:=getdegree(x)Related topics
getlb getub getmiddle getsize getval is_fixed gettarget getrand getnext getprev contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

123Subroutines

gettarget
PurposeReturns the target value (preferred value for instantiation) for the variable passed in argument
Synopsisfunction gettarget(var:cpvar) : integerfunction gettarget(var:cpfloatvar) : real
Argumentvar

the decision variable

Return value
The target value of var
ExampleThe following example shows how to get the target value of a cpvar ’x’
tval := gettarget(x)Related topics
settarget getlb getub getmiddle getsize getval is_fixed getdegree getrand getnext getprev
contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

124

Subroutines

getrandPurposeReturns a value at random (uniform distribution) in the domain of the variable passed inargument.
Synopsisfunction getrand(x:cpvar) : integerfunction getrand(x:cpfloatvar) : real
Argumentx

the decision variable

Return value
A random value in the domain of x
ExampleThe following example shows how to get a random value in the domain a cpvar x
r:=getrand(x)Related topics
getlb getub getmiddle getsize getval is_fixed getdegree gettarget getnext getprev contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

125Subroutines

getnext
PurposeReturns the value nearest to and greater than val in the domain of a variable passed inargument. This function is useful to enumerate the values of the domain of a variable from thelowest to the highest value; note that if ’val’ is larger than the upper bound of the domain of x,
the upper bound will be returned.
Synopsisfunction getnext(x:cpvar,val:integer) :Argumentsxval

integerthe decision variable
a value in the domain of the variable

Return value
The next value in the domain of x
ExampleThe following example shows how to enumerate in increasing order the values in the domain of
a cpvar x
curVal := getlb(x)while (curVal < getub(x)) do
curVal := getnext(x, curVal)
writeln("curVal= ", curVal)
end-doRelated topics
getlb getub getmiddle getsize getval is_fixed getdegree gettarget getrand getprev contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information126Subroutines

getprev
PurposeReturns the value nearest to and lower than ’val’ in the domain of a variable passed in argument.
This function is useful to enumerate the values of the domain of a variable from the highest to
the lowest value; note that if ’val’ is below the lower bound of x domain, the lower bound will be
returned.
Synopsisfunction getprev(x:cpvar,val:integer) :Argumentsxval

integerthe decision variable
a value in the domain of the variable

Return value
The previous value in the domain of x
ExampleThe following example shows how to enumerate in decreasing order the values in the domain of
a cpvar x
curVal := getub(x)while (curVal > getlb(x)) do
curVal := getprev(x, curVal)
writeln("curVal= ",curVal)
end-doRelated topics
getlb getub getmiddle getsize getval is_fixed getdegree gettarget getrand getnext contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

127Subroutines

contains
PurposeReturns true if the value ’val’ belongs to the domain of the variable passed in argument
Synopsisfunction contains(x:cpvar,val:integer) : booleanfunction contains(x:cpfloatvar,val:real) : boolean
Argumentsxval

the decision variable
the value

Return value
true if x can be instantiated to val
ExampleThe following example shows how to test if a value belongs to the domain of a cpvar x
if contains(x,3) thenwrite("x can be instantiated to three!")
end-ifRelated topics
getlb getub getmiddle getsize getval is_fixed getdegree gettarget getrand getnext getprev

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

128

Subroutines

is_equal
PurposeReturns true if the domains of the two variables passed in argument contain exactly the samevaluesSynopsisfunction is_equal(var1:cpvar,var2:cpvar) : booleanfunction is_equal(var1:cpfloatvar,var2:cpfloatvar) :Arguments
var1
var2

booleanthe first decision variable
the second decision variable

Return value
true if the domain of var1 equals the domain of var2, else false
ExampleThe following example shows how to test whether the domains of two cpvar var1 and var2 areequal
if is_equal(var1,var2) thenwrite("the domains of var1 and var2 are the same!")end-ifRelated topics
is_sameFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

129Subroutines

is_same
PurposeReturns true if two decision variables passed in argument represent the same variable; thisfunction is mainly used by advanced users to specify branching heuristics (see example below).
Synopsisfunction is_same(var1:cpvar,var2:cpvar) : booleanfunction is_same(var1:cpfloatvar,var2:cpfloatvar) :Arguments
var1
var2

booleanthe first decision variable
the second decision variable

Return value
true if var1 and var2 represent the same variable
ExampleThe following example shows how to test whether two cpvar represent the same variable
if is_same(var1,var2) thenwrite("var1 and var2 represent the same variable!")end-ifRelated topics
is_equal

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information130Subroutines

settarget
PurposeSets the target value (preferred instantiation value) for the variable passed in argument.
Synopsisprocedure settarget(x:cpvar,value:integer)
procedure settarget(x:cpfloatvar,value:real)
Argumentsxvalue

the decision variable
the target value

ExampleThe following example shows how to set the target value of a cpvar x to three:settarget(x,3)
Related topics
getlb getub getmiddle getsize getval is_fixed getdegree gettarget getrand getnext getprev

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

131Subroutines

setdomain
PurposeSets the domain of the variable to the set of integers passed in argument.
Synopsisprocedure setdomain(x:cpvar, domain:set of integers)
procedure setdomain(x:cpvar, lowerBound:integer, upperBound:integer)
procedure setdomain(x:cpfloatvar, lowerBound:real, upperBound:real)procedure setdomain(x:cpauxvar, lowerBound:real, upperBound:real)
Argumentsx
domainlowerBoundupperBoundthe decision variable
Set of integers representing the target domain.
lower bound of the interval
upper bound of the interval

ExampleThe following example shows how to set the domain of a cpvar x to the set of integers {1,3,5,7,9}setdomain(x,{1,3,5,7,9})
Related topics
getlb getub getmiddle getsize getval is_fixed getdegree gettarget getrand getnext getprev

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information132

Subroutines

setlb
PurposeSets the lower bound of the variable to the value passed in argument. This procedure can be usedduring the CP search.
Synopsisprocedure setlb(x:cpvar, value:integer)
procedure setlb(x:cpfloatvar, value:real)
Argumentsxvalue

the decision variablevalue representing the lower bound

ExampleThe following example shows how to set the lower bound of a cpvar x to the integer value 1.
setlb(x,1)
Related topics
setval setub getlb getub getmiddle getsize getval is_fixed getdegree gettarget getrand
getnext getprev

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

133Subroutines

setub
PurposeSets the upper bound of the variable to the value passed in argument. This procedure can beused during the CP search.
Synopsisprocedure setub(x:cpvar, value:integer)
procedure setub(x:cpfloatvar, value:real)
Argumentsxvalue

the decision variablevalue representing the upper bound.

ExampleThe following example shows how to set the upper bound of a cpvar x to the integer value 1.
setub(x,1)
Related topics
setval setlb getlb getub getmiddle getsize getval is_fixed getdegree gettarget getrand
getnext getprev

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

134

Subroutines

setvalPurposeSets the value of the variable to the value passed in argument. This procedure can be used during
the CP search.
Synopsisprocedure setval(x:cpvar, value:integer)
procedure setval(x:cpfloatvar, value:real)
Argumentsxvalue

the decision variableinstantiation value

ExampleThe following example shows how to instantiate the value of a cpvar x to the integer value 1.
setval(x,1)
Related topics
setlb setub getlb getub getmiddle getsize getval is_fixed getdegree gettarget getrand
getnext getprev

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

135

Subroutines

setprecision
PurposeSets the precision relativity and value of a cpfloatvar
Synopsisprocedure setprecision(x:cpfloatvar, relativity:boolean, precision:real)procedure setprecision(x:cpfloatvar, precision:real)
Argumentsx
relativity
precision

the variable
relativity of precision
precision value

ExampleThe following picture illustrates the concept of precision for a cpfloatvar

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

136Subroutines

cp_show_var
PurposeThis procedure prints the current domain of the variable passed in argument
Synopsisprocedure cp_show_var(var:cpvar)
procedure cp_show_var(var:cpfloatvar)
Argumentvar

the decision variable to show

Related topics
cp_show_prob cp_show_stats

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

137

Subroutines

9.4

Problem
cp_find_next_sol

Finds the next solution of the problem

p. 141

cp_infeas_analysis

Compute a minimal conflict set for an inconsistent problem

p. 154cp_local_optimize

Optimize an integer objective variable with local optimization.

p. 158cp_maximise

Alias for cp_maximize

p. 143cp_maximize

Maximizes a variable

p. 144

cp_minimise

Alias for cp_minimize

p. 145

cp_minimize

Minimizes a variable

p. 146

cp_postPosts a constraint to the problem

p. 139cp_propagate

Propagates the constraints

p. 140cp_reset_params

Reset parameters to their default value.

p. 160cp_reset_search

Resets the search process

p. 142

cp_restore_state

Restore a solver state from the stack

p. 156cp_save_state

Save a marker in the stack

p. 155cp_shave

Shave the variables of the problem

p. 153cp_show_best_sol

Pretty printing of the best solution found.

p. 150cp_show_prob

Pretty printing of the problem

p. 148cp_show_sol

Pretty printing of the last solution.

p. 149geteltRetrieve the value of a reversible array element.

p. 165getnameGets the name of a variable / task / resourcep. 151getsize

Returns the size of a reversible array.

p. 166

getsolReturns the solution value of a variable

p. 147

getvalRetrieve the value of a reversible number.

p. 163

path_order

Return a path-order branching schemep. 157

set_reversible_attributes

Sets the attributes of a reversible number or array.

p. 161

set_sol_as_target

Set last solution found as target values.

p. 159setelt

Set the value of an element of an array of reversibles.

p. 164setnameSets the name of a variable / task / resourcep. 152

setval

Set the value of a reversible number.

p. 162

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information138

Subroutines

cp_postPurposeThis function posts the constraint ctr to the problem. Note that posting a constraint does not
imply that the involved variables will be instantiated.
Synopsisfunction cp_post(ctr:cpctr) :Argument
ctr

booleanthe constraint to post

Return value
Returns true if the constraint is compatible with already posted constraints, else false.
ExampleThe following example shows how to post the constraint x = y + 1 where x and y are two decisionvariables of the problem
cp_post(x = y + 1)
Related topics
cp_propagate KALIS_AUTO_PROPAGATE cp_post

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

139

Subroutines

cp_propagate
PurposeThis function reaches a fixed point during constraint propagation. The constraint deduction rules
are applied successively until no more deductions are possible. Note that propagating a
constraint does not imply that the involved variables will be instantiated.
Synopsisfunction cp_propagate :booleanReturn value
Returns false if the propagation reaches a contradiction (infeasible problem), else returns true
Related topics
cp_post auto_propagate

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

140

Subroutines

cp_find_next_sol
PurposeFinds the next solution of the problem
Synopsisfunction cp_find_next_sol :booleanReturn value
Returns true if an additional solution can be found, else false
ExampleThe following code shows how to scan all the solutions of a predefined problem containing b, x,y and z as decision variables:
while (cp_find_next_sol)
writeln("b:", b, " x:", x, " y:", y, " z:", z)
Related topics
cp_reset_search cp_minimize cp_maximize cp_set_branching

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

141

Subroutines

cp_reset_search
PurposeThis procedure resets the search process: it finalizes the tree search and returns to the first nodeof the tree. While it is not called, the branch and bound stays at a node in the tree search and the
problem cannot be modified. It needs to be called only if tree search was not finished.
Synopsisprocedure cp_reset_search

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

142Subroutines

cp_maximise
PurposeAlias for cp_maximize. See cp_maximize for description.
Synopsisfunction cp_maximise(obj:cpvar) : booleanfunction cp_maximise(obj:cpfloatvar) : boolean
Related topics
cp_maximize

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

143

Subroutines

cp_maximize
PurposeThis function starts the search for an optimal solution of the problem that maximizes a specificvariable. Upon termination of the search (when no limitation has been set on the search process),the last solution found (if any exists) is proven optimal.
Synopsisfunction cp_maximize(obj:cpvar) :function cp_maximize : boolean
Argument
obj

booleanthe decision variable to maximize

Return value
true if a solution has been found, false if the problem is inconsistent (no solution exists)
ExampleThe following code shows how to use this function to maximize the Benefit objective
optimizeProcess := cp_maximize(Benefit)
Related topics
cp_minimize cp_find_next_sol

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

144

Subroutines

cp_minimise
PurposeAlias for cp_minimize. See cp_maximize for description.
Synopsisfunction cp_minimise(obj:cpvar) : booleanfunction cp_minimise(obj:cpfloatvar) : boolean
Related topics
cp_minimize

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

145

Subroutines

cp_minimize
PurposeThis function starts the search for an optimal solution of the problem that minimizes a specificvariable. Upon termination of the function (when no limitation has been set on the search
process), the last solution found (if any exists) is proven optimal.
Synopsisfunction cp_minimize(obj:cpvar) : booleanfunction cp_minimize(obj:cpfloatvar) : boolean
Argument
obj

the decision variable to minimize

Return value
true if a solution has been found, false if the problem is inconsistent (no solution exists)
ExampleThe following code shows how to use this function to minimize the objective Cost:
optimizeProcess := cp_minimize(Cost)
Related topics
cp_maximize getsol cp_find_next_sol

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

146

Subroutines

getsolPurposeThis function returns the solution value of a variable or linear expression passed in argument.
Note that the variable must be instantiated before calling this function, else it will return its
lower bound.
Synopsisfunction getsol(x:cpvar) : integerfunction getsol(x:cpfloatvar) : realfunction getsol(l:cplinexp) : integer
Argumentsxla decision variable
a linear expression

Return value
The instantiation value of x (or by default its lower bound), respectively the evaluation of thelinear expression
ExampleThe following example shows how to get the solution value of a cpvar x
val:= getsol(x)Related topics
getlb getub is_fixed getsize

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

147

Subroutines

cp_show_prob
PurposeThis procedure prints an overview of the current state of the problem (variables and constraints)
Synopsisprocedure cp_show_prob
Related topics
cp_show_var cp_show_stats

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

148

Subroutines

cp_show_sol
PurposeThis procedure prints an overview of the last solution found.
Synopsisprocedure cp_show_sol
Related topics
cp_show_var cp_show_stats

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

149

Subroutines

cp_show_best_sol
PurposeThis procedure prints an overview of the best solution found if the problem has an objective, orof the last solution found otherwise.
Synopsisprocedure cp_show_best_sol
Related topics
cp_show_sol cp_show_var cp_show_stats

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

150

Subroutines

getname
PurposeGets the name of a variable / task / resource passed in argument. The name of the modelingobject is used by problem and variable printing routines
Synopsisprocedure getname(var:cpvar)
procedure getname(fvar:cpfloatvar)
procedure getname(task:cptask)
procedure getname(resource:cpresource)
Arguments
var
fvar
resourcetask

a finite domain variable
the floating decision variable
a resourcea taskExampleThe following example shows how to print out the name of a cpvar x
writeln(getname(x))
Related topics
setname cp_show_prob cp_show_var cp_show_schedule

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

151

Subroutines

setname
PurposeSets the name of a variable / task / resource passed in argument, the name of the variable / task /resource is used by problem and variable printing routines
Synopsisprocedure setname(var:cpvar,name:string)procedure setname(fvar:cpfloatvar,name:string)procedure setname(task:cptask,name:string)procedure setname(resource:cpresource,name:string)Arguments
var
fvar
task
resource
namea finite domaina continuous variablea taska resource
the name to set

ExampleThe following example shows how to set the name of a cpvar x to ’AMOUNT’
setname(x,"AMOUNT")
Related topics
getname cp_show_prob cp_show_var cp_show_schedule

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

152

Subroutines

cp_shave
PurposeShaving consists in tentatively setting variables to a value in their domain. If the assignment fails(considering the complete constraint set), then this value can be removed from the domain,
possibly eliminating many inconsistent values before starting search.
Synopsisfunction cp_shave:booleanReturn value
false if problem is proven to be inconsistent, true otherwise
ExampleThe following example shows how to apply shaving to the variables of a problem:
res := cp_shave
Related topics
cp_propagate

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

153

Subroutines

cp_infeas_analysis
PurposeThis method computes a minimal conflict set for an inconsistent problem. A minimal conflict set isa minimal size set of constraints that causes a contradiction (infeasibility).
Synopsisprocedure cp_infeas_analysis
ExampleThe following example shows how to compute a minimal conflict set:...
! definition of constraints...
cp_save_state
if (not cp_propagate) thencp_restore_state
writeln("Problem is infeasible")
cp_infeas_analysis
exit(0)end-ifcp_restore_state...
! problem solving
Related topics
cp_save_state cp_restore_state

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

154

Subroutines

cp_save_state
PurposeSave a marker in the CP solver stack to enable restoration of the domains of decision variables at
a later stage, e.g., for performing infeasibility analysis.
Synopsisprocedure cp_save_state
ExampleThe following example shows how to save the state of a constraint system:...
! definition of constraints...
cp_save_state
if (not cp_propagate) thencp_restore_state
writeln("Problem is infeasible")
cp_infeas_analysis
exit(0)end-ifcp_restore_state...
! problem solving
Related topics
cp_restore_state

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

155

Subroutines

cp_restore_state
PurposeRestore the state of the CP solver at a previously saved state marker. Note: this function only
restores the domains of decision variables, constraints that have been posted after saving thestate marker are not removed.
Synopsisprocedure cp_restore_state
ExampleThe following example shows how to restore the state of a constraint system:...
! definition of constraints...
cp_save_state
if (not cp_propagate) thencp_restore_state
writeln("Problem is infeasible")
cp_infeas_analysis
exit(0)end-ifcp_restore_state...
! problem solving
Related topics
cp_save_state

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

156

Subroutines

path_orderPurposeThe path-heuristic is specifically designed to work in conjunction with the cycle constraint. It
selects the first unassigned ’succ’ variable in the order of the current subpath implied by thecurrent values of the successors variables. When the subpath is empty (no ’succ’ variables are
currently instantiated) the path order-heuristic selects a node at random.
Synopsisfunction path_order(succ:array of cpvar, nodeSelection:string) :Arguments
succ
nodeSelection

cpbranching

The list of successors variables
The value selection heuristic

Related topics
cycle

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

157

Subroutines

cp_local_optimize
PurposeThis function starts the search for a near-optimal solution of the problem that optimizes a specificobjective variable.
Synopsisfunction cp_local_optimize(obj:cpvar, minimize: integer) : booleanfunction cp_local_optimize(obj:cpfloatvar, minimize: integer) : boolean
Arguments
obj
minimizethe objective variable
0 for minimization or 1 for maximization

Related topics
cp_minimize cp_maximize

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

158

Subroutines

set_sol_as_target
PurposeSet the target values of all the variables to their value in the last solution found.
Synopsisprocedure set_sol_as_target
Related topics
gettarget settarget KALIS_NEAREST_VALUE

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

159

Subroutines

cp_reset_params
PurposeReset parameters to their default value.
Synopsisprocedure cp_reset_params(parameterSet:integer)
Argument
parameterSet

the set of parameters to reset (KALIS_RESET_PARAMS_ALL,
KALIS_RESET_VAR_BOUNDS, KALIS_RESET_VAR_PRECISION,KALIS_RESET_OPT_PARAMS, KALIS_RESET_SEARCH_PARAMS)

ExampleThe following example shows how to use the cp_reset_params function to reset all parameters of
Xpress Kalis:
cp_reset_params(KALIS_RESET_PARAMS_ALL)
Related topics
setparam

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

160

Subroutines

set_reversible_attributes
PurposeSets the attributes of a reversible number or array.
Synopsisprocedure set_reversible_attributes(revarray:cpreversiblearray, first:integer,
last:integer, initValue:integer)
procedure set_reversible_attributes(rev:cpreversible, initValue:real)
Arguments
revarray
first
last
rev
initValue

a reversible arraythe smallest index number
the highest index number
a reversible number
the initialization value

ExampleThe following example shows how to set the attributes of a reversible array :declarations
reva: cpreversiblearray
end-declarations! Create a reversible array of 10 elements initialized with value 0
set_reversible_attributes(reva, 1, 10, 0)! Return the number of elements in the reversible arraywriteln("Array contains ", getsize(reva), " elements")! Get the 5’th element of the arraywriteln("The 5’th element of reva is ", getelt(reva,5))
Related topics
setval getval getsize getelt setelt

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

161

Subroutines

setvalPurposeSets the value of a reversible number. If this procedure is used during the CP search, the reversible
will be restored to its previous value on backtracking beyond the state where this value has beenset.
Synopsisprocedure setval(k:cpreversible, value:real)
Argumentskvalue

a reversible number,instantiation value.

ExampleThe following example shows how to set the current value of a reversible rev to the integer value
10.
setval(rev, 10)
Related topics
set_reversible_attributes getval

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

162

Subroutines

getvalPurposeRetrieves the value of a reversible number at the current state of the constraint system.
Synopsisfunction getval(k:cpreversible):Argumentkreal)

a reversible number.

Return value
The current value of the reversible.
ExampleThe following example saves the state of the constrain system, changes the value of the reversible
rev, then restores the previous state of th constraint system and displays the restored value of thereversible number.
set_reversible_attributes(rev, 20.54)! Save current state of constraint systemcp_save_statesetval(rev, 5)
writeln("Value of the reversible is ", getval(rev))! Restore the saved system state
cp_restore_state
writeln("After state restoration reversible is ", rev)
Related topics
set_reversible_attributes setval

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

163

Subroutines

seteltPurposeSets the value of an element of an array of reversibles. If this procedure is used during the CP
search, the reversible will be restored to its previous value on backtracking beyond the state
where this value has been set.
Synopsisprocedure setelt(ra:cpreversiblearray, ind:Arguments
ra
ind
value

integer, value:integer)

an array of reversibles,
the index of an array element,
new value for the reversible.

ExampleThe following example saves the state of the constraint system, changes the value of an element
the reversible array reva, then restores the previous state of the constraint system and displays
the restored value of the reversible number.
set_reversible_attributes(reva, 1, 10, 0)! Save current state of constraint systemcp_save_state
setelt(reva, 4, -10)
writeln("The 4’th element of ’reva’ is ", setelt(reva, 4))! Revert to the saved system state
cp_restore_state
writeln("After state restoration reversible array is: ", reva)
Related topics
set_reversible_attributes getelt getsize

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

164

Subroutines

geteltPurposeRetrieves the value of the specified element of an array of reversible numbers at the current stateof the constraint system.
Synopsisfunction getelt(ra:cpreversiblearray, ind:integer):Argumentsraindinteger)an array of reversibles,
the index of an array element.

Return value
The current value of the specified entry of the array.
ExampleSee setelt.
Related topics
set_reversible_attributes setelt getsize

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

165

Subroutines

getsize
PurposeThis function returns the size (= number of elements) of a reversible array.
Synopsisfunction getsize(ra:cpreversiblearray):
Argumentrainteger

the array of reversibles

Return value
The size of the array of reversibles.
ExampleThe following example shows how to get the size of the array reva.
set_reversible_attributes(reva, 1, 10, 0)
writlen("Size of array ’reva’: ", reva.size)
Related topics
set_reversible_attributes getelt setelt

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

166

Subroutines

9.5

Searchassign_and_forbid

assign_and_forbid branching scheme

p. 172

assign_var

assign_var branching scheme

p. 168bs_group

Create a group of branching schemes

p. 193

cp_set_branching

Sets the strategy to use during the search for a solution

p. 189cp_show_stats

Shows some statistics about the searchp. 192

gettagGets the tag associated with a branching scheme group

p. 195group_serializer

Creates a branching scheme Group Serializer

p. 194probe_assign_var

probe_assign_var branching scheme

p. 178probe_settle_disjunction probe_settle_disjunction branching scheme

p. 179settle_disjunction

settle_disjunction branching scheme

p. 176

split_domain

split_domain branching scheme

p. 181

task_serialize

task_serialize branching scheme

p. 185

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

167

Subroutines

assign_var
PurposeCreates an assign_var (Constraint programming style) branching scheme; in this scheme, a
discrete value is assigned to the branching variable at each branch.

Synopsisfunction assign_var(varsel:string,valsel:string,variables:set of cpvar) : cpbranching
function assign_var(varsel:string,valsel:string,variables:array(range) of cpvar) :cpbranching
function assign_var(varsel:string,valsel:string,variables:cpvarlist) : cpbranching
function assign_var(varsel:string,valsel:string) : cpbranching
Arguments
varselvalselvariablesname of the variable selectorname of the value selector
list of variables to branch on

Return value
assign_var branching scheme with default value and variable selector
ExampleThe following example shows how to use an assign_var branching scheme during the search
processmodel "User branching"uses "kalis"parameters
ALG=1
end-parameters
forward function varchoice(Vars: cpvarlist): integer
forward function varchoice2(Vars: cpvarlist): integer
forward function valchoice(x: cpvar): integer
forward function valchoice2(x: cpvar): integer
setparam("KALIS_DEFAULT_LB", 0);
setparam("KALIS_DEFAULT_UB", 20)
declarations
R = 1..10
y: array(R) of cpvar
C: array(R) of integer
Strategy: array(range) of cpbranchingend-declarations

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

168

Subroutines

C:: [4, 7, 2, 6, 9, 0,-1, 3, 8,-2]
all_different(y)forall(i in R | isodd(i)) y(i) >= y(i+1) + 1
y(4) + y(1) = 13; y(8) <= 15; y(7) <> 5
! Definition of user branching strategies:
Strategy(1):= assign_and_forbid("varchoice2", "valchoice", y)Strategy(2):= assign_var("varchoice", "valchoice", y)Strategy(3):= split_domain("varchoice", "valchoice2", y, true, 2)Strategy(4):= split_domain("varchoice2", "valchoice", y, false, 5)! Select a branching strategy
cp_set_branching(Strategy(ALG))
if cp_find_next_sol thenforall(i in R) write(getsol(y(i)), " ")writeln
end-if!--------------------------------------------------------------! **** Variable choice ****
! **** Choose variable with largest degree + smallest domainfunction varchoice(Vars: cpvarlist): integer
declarations
Vset,Iset: set of integer
end-declarations! Get the number of elements of "Vars"
listsize:= getsize(Vars)! Set on uninstantiated variables
forall(i in 1..listsize)
if not is_fixed(getvar(Vars,i)) then Vset+= {i}; end-if
if Vset={} thenreturned:= 0else! Get the variables with max. degree
dmax:= max(i in Vset) getdegree(getvar(Vars,i))
forall(i in Vset)
if getdegree(getvar(Vars,i)) = dmax then Iset+= {i}; end-if
dsize:= MAX_INT! Choose var. with smallest domain among those indexed by ’Iset’
forall(i in Iset)
if getsize(getvar(Vars,i)) < dsize thenreturned:= idsize:= getsize(getvar(Vars,i))
end-ifend-ifwriteln(returned)
end-function

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

169

Subroutines! **** Choose variable y(i) with smallest value of C(i)function varchoice2(Vars: cpvarlist): integer
declarations
Vset,Iset: set of integer
VarInd: array(Iset) of integer
end-declarations! Set on uninstantiated variables
listsize:= getsize(Vars)
forall(i in 1..listsize)
if not is_fixed(getvar(Vars,i)) then Vset+= {i}; end-if
if getsize(Vset)=0 thenreturned:= 0else! Establish a correspondence of indices between ’Vars’ and ’y’
forall(i in R)
forall(j in Vset)
if is_same(getvar(Vars,j), y(i)) then
VarInd(i):= j
Vset -= {j}break 1
end-if! Choose the variable
imin:= min(i in Iset) i; cmin:= C(imin)
forall(i in Iset)
if C(i) < cmin thenimin:= i; cmin:= C(i)end-ifreturned:= VarInd(imin)
end-ifwriteln(imin, " ", returned)
end-function!--------------------------------------------------------------! *** Value choice ****
! **** Choose the next value one third larger than lower bound! (Strategy may be used with any branching scheme since it! makes sure that the chosen value lies in the domain)function valchoice(x: cpvar): integer! returned:= getlb(x)returned:= getnext(x, getlb(x) + round((getub(x)-getlb(x))/3))
writeln("Value: ", returned, " ", contains(x,returned)," x: ", x)
end-function! **** Split the domain into lower third and upper two thirds! (Strategy to be used only with ’split_domain’ branching since! the chosen value may not be in the domain)function valchoice2(x: cpvar): integer
returned:= getlb(x) + round((getub(x)-getlb(x))/3)
writeln("Value: ", returned, " x: ", x)
end-function
end-model

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

170

Subroutines

Related topics
assign_and_forbid settle_disjunction probe_assign_var split_domain

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

171

Subroutines

assign_and_forbid
PurposeCreates an assign_and_forbid (MIP style) branching scheme; that will assign a value to thebranching variable on one branch and forbid that value on the other branch.

Synopsisfunction assign_and_forbid(varsel:string,valsel:string,variables:set of cpvar) :cpbranching
function assign_and_forbid(varsel:string,valsel:string,variables:array(range) of
cpvar) : cpbranching
function assign_and_forbid(varsel:string,valsel:string,variables:cpvarlist) :cpbranching
function assign_and_forbid(varsel:string,valsel:string) : cpbranching
Arguments
varselvalselvariablesname of the variable selectorname of the value selector
list of variables to branch on

Return value
assign_and_forbid branching scheme with value selector ’valsel’ and variable selector ’varsel’working on all specified variables
ExampleThe following example shows how to use an assign_var branching scheme during the search
processmodel "User branching"uses "kalis"parameters
ALG=1
end-parameters
forward function varchoice(Vars: cpvarlist): integer
forward function varchoice2(Vars: cpvarlist): integer
forward function valchoice(x: cpvar): integer
forward function valchoice2(x: cpvar): integer
setparam("KALIS_DEFAULT_LB", 0);
setparam("KALIS_DEFAULT_UB", 20)
declarations
R = 1..10

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

172

Subroutines

y: array(R) of cpvar
C: array(R) of integer
Strategy: array(range) of cpbranchingend-declarations
C:: [4, 7, 2, 6, 9, 0,-1, 3, 8,-2]
all_different(y)forall(i in R | isodd(i)) y(i) >= y(i+1) + 1
y(4) + y(1) = 13; y(8) <= 15; y(7) <> 5
! Definition of user branching strategies:
Strategy(1):= assign_and_forbid("varchoice2", "valchoice", y)Strategy(2):= assign_var("varchoice", "valchoice", y)Strategy(3):= split_domain("varchoice", "valchoice2", y, true, 2)Strategy(4):= split_domain("varchoice2", "valchoice", y, false, 5)! Select a branching strategy
cp_set_branching(Strategy(ALG))
if cp_find_next_sol thenforall(i in R) write(getsol(y(i)), " ")writeln
end-if!--------------------------------------------------------------! **** Variable choice ****
! **** Choose variable with largest degree + smallest domainfunction varchoice(Vars: cpvarlist): integer
declarations
Vset,Iset: set of integer
end-declarations! Get the number of elements of "Vars"
listsize:= getsize(Vars)! Set on uninstantiated variables
forall(i in 1..listsize)
if not is_fixed(getvar(Vars,i)) then Vset+= {i}; end-if
if Vset={} thenreturned:= 0else! Get the variables with max. degree
dmax:= max(i in Vset) getdegree(getvar(Vars,i))
forall(i in Vset)
if getdegree(getvar(Vars,i)) = dmax then Iset+= {i}; end-if
dsize:= MAX_INT! Choose var. with smallest domain among those indexed by ’Iset’
forall(i in Iset)
if getsize(getvar(Vars,i)) < dsize thenreturned:= idsize:= getsize(getvar(Vars,i))
end-ifFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

173

Subroutines

end-ifwriteln(returned)
end-function! **** Choose variable y(i) with smallest value of C(i)function varchoice2(Vars: cpvarlist): integer
declarations
Vset,Iset: set of integer
VarInd: array(Iset) of integer
end-declarations! Set on uninstantiated variables
listsize:= getsize(Vars)
forall(i in 1..listsize)
if not is_fixed(getvar(Vars,i)) then Vset+= {i}; end-if
if getsize(Vset)=0 thenreturned:= 0else! Establish a correspondence of indices between ’Vars’ and ’y’
forall(i in R)
forall(j in Vset)
if is_same(getvar(Vars,j), y(i)) then
VarInd(i):= j
Vset -= {j}break 1
end-if! Choose the variable
imin:= min(i in Iset) i; cmin:= C(imin)
forall(i in Iset)
if C(i) < cmin thenimin:= i; cmin:= C(i)end-ifreturned:= VarInd(imin)
end-ifwriteln(imin, " ", returned)
end-function!--------------------------------------------------------------! *** Value choice ****
! **** Choose the next value one third larger than lower bound! (Strategy may be used with any branching scheme since it! makes sure that the chosen value lies in the domain)function valchoice(x: cpvar): integer! returned:= getlb(x)returned:= getnext(x, getlb(x) + round((getub(x)-getlb(x))/3))
writeln("Value: ", returned, " ", contains(x,returned)," x: ", x)
end-function! **** Split the domain into lower third and upper two thirds! (Strategy to be used only with ’split_domain’ branching since! the chosen value may not be in the domain)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

174

Subroutinesfunction valchoice2(x: cpvar): integer
returned:= getlb(x) + round((getub(x)-getlb(x))/3)
writeln("Value: ", returned, " x: ", x)
end-function
end-model
Related topics
assign_var settle_disjunction probe_assign_var split_domain

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

175Subroutines

settle_disjunction
PurposeCreates a settle_disjunction branching scheme that resolves the status of all the disjunctions
passed in argument. The branching consists in choosing one branch of the disjunction andposting the constraint stated by this branch. The branches are tested from left to right

Synopsisfunction settle_disjunction(constraints:set of cpctr) : cpbranching
function settle_disjunction(constraints:array(range) of cpctr) : cpbranching
function settle_disjunction(constraints:set of cpctr) : cpbranching
function settle_disjunction(constraints:array(range) of cpctr) : cpbranching
function settle_disjunction : cpbranching
function settle_disjunction : cpbranching
Argument
constraints

the disjunctions

Return value
The resulting settle_disjunction branching scheme
ExampleThe following example shows how to use the settle_disjunction branching scheme to solve a small
disjunctive scheduling problem: The problem is to find a schedule for a set of tasks on one
machine. The machine can process only one task at the time and the goal is to minimize the total
weighted tardiness of the schedule.
model "Disjunctive scheduling with settle_disjunction"
uses "kalis"declarations
NBTASKS = 5
TASKS = 1..NBTASKS
DUR: array(TASKS) of integer
DUE: array(TASKS) of integer
WEIGHT: array(TASKS) of integer
start: array(TASKS) of cpvar
tmp: array(TASKS) of cpvar
tardiness: array(TASKS) of cpvar
twt: cpvar
zeroVar: cpvar
Strategy: array(range) of cpbranching
Disj: set of cpctr
end-declarations! Set of tasks! Task durations! Due dates! Weights of tasks! Start times! Aux. variable! Tardiness! Objective variable! 0-valued variable! Branching strategy! Disjunctions

DUR :: [21,53,95,55,34]

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

176

Subroutines

DUE :: [66,101,232,125,150]
WEIGHT :: [1,1,1,1,1]
setname(twt, "Total weighted tardiness")
zeroVar = 0
setname(zeroVar, "zeroVar")
forall (t in TASKS) do
start(t) >= 0
setname(start(t), "Start("+t+")")
tmp(t) = start(t) + DUR(t) - DUE(t)setname(tardiness(t), "Tard("+t+")")
tardiness(t) = maximum({tmp(t),zeroVar})
end-dotwt = sum(t in TASKS) (WEIGHT(t) * tardiness(t))! Create the disjunctive constraints
forall(t in 1..NBTASKS-1, s in t+1..NBTASKS)(start(t) + DUR(t) <= start(s)) or(start(s) + DUR(s) <= start(t))! Define the branching strategy
Strategy(1):= settle_disjunction
Strategy(2):= split_domain(KALIS_LARGEST_MIN,KALIS_MIN_TO_MAX)
cp_set_branching(Strategy)! Solve the problem
if not(cp_minimize(twt)) thenwriteln("Problem is inconsistent")exit(0)end-ifforall (t in TASKS)
writeln("[", getsol(start(t)), "==>",
getsol(start(t)) + DUR(t), "]:\t ",getsol(tardiness(t)), " (", getsol(tmp(t)), ")")
writeln("Total weighted tardiness: ", getsol(twt))
end-model
Related topics
assign_var assign_and_forbid probe_assign_var split_domain

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

177

Subroutines

probe_assign_var
PurposeCreates a probe_assign_var branching scheme, in which probing and assignment are applied
simultaneously

Synopsisfunction probe_assign_var(varsel:string,valsel:string,variables:set of cpvar,
probelevel:integer) : cpbranching
function probe_assign_var(varsel:string, valsel:string, variables:array(range) of
cpvar, probelevel:integer) : cpbranching
function probe_assign_var(varsel:string, valsel:string,variables:cpvarlist,
probelevel:integer) : cpbranching
function probe_assign_var(varsel:string, valsel:string, probelevel:integer) :cpbranching
function probe_assign_var(varsel:string,valsel:string) : cpbranching
Arguments
varselvalselvariables
probelevel

the variable selector name (pre-defined constant or user-defined function name)the value selector (pre-defined constant or user-defined function name)list of variables to branch on
maximal probing level

Return value
The resulting probe_assign_var branching scheme
Related topics
assign_var assign_and_forbid settle_disjunction split_domain

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

178

Subroutines

probe_settle_disjunction
PurposeCreates a probe_settle_disjunction branching scheme that resolves the status of all the
disjunctions passed in argument. The branching consists in choosing one branch of the disjunction
and posting the constraint stated by this branch. The branches are tested from left to right

Synopsisfunction probe_settle_disjunction(disjunctions:set of cpctr, probeLevel:integer) :cpbranching
function probe_settle_disjunction(disj_selector:string, disjunctions:set of cpctr,
probeLevel:integer) : cpbranching
function probe_settle_disjunction(disj_selector:string, disjunctions:array(range) of
cpctr, probeLevel:integer) : cpbranching
function probe_settle_disjunction(disjunctions:array(range) of cpctr,
probeLevel:integer) : cpbranching
function probe_settle_disjunction(disj_selector:string, probeLevel:integer) :cpbranching
function probe_settle_disjunction(probeLevel:integer) : cpbranching
Arguments
disj_selector
disjunctions
probeLevel

the disjunction selector name (pre-defined constant or user-defined function
name)the set or array of disjunctions
maximal probing level

Return value
The resulting probe_settle_disjunction branching scheme
ExampleThe following example shows how to use the probe_settle_disjunction branching scheme to solvea small disjunctive scheduling problem:The problem consists of finding a schedule for some tasks
on one machine. The machine can process only one task at the time and the goal is to minimize
the total weighted tardiness of the schedule. Note that the result may be (and will be in this case)suboptimal as the search tree is not fully explored.
model "Disjunctive scheduling with probe_settle_disjunction"
uses "kalis"declarations
NBTASKS = 5
TASKS = 1..NBTASKS
DUR: array(TASKS) of integer
DUE: array(TASKS) of integer
WEIGHT: array(TASKS) of integer

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information! Set of tasks! Task durations! Due dates! Weights of tasks

179

Subroutines

start: array(TASKS) of cpvar
tmp: array(TASKS) of cpvar
tardiness: array(TASKS) of cpvar
twt: cpvar
zeroVar: cpvar
Strategy: array(range) of cpbranching
Disj: set of cpctr
end-declarations! Start times! Aux. variable! Tardiness! Objective variable! 0-valued variable! Branching strategy! Disjunctions

DUR :: [21,53,95,55,34]
DUE :: [66,101,232,125,150]
WEIGHT :: [1,1,1,1,1]
setname(twt, "Total weighted tardiness")
zeroVar = 0
setname(zeroVar, "zeroVar")
forall(t in TASKS) do
start(t) >= 0
start(t).name:= "Start("+t+")"tmp(t) = start(t) + DUR(t) - DUE(t)tardiness(t).name:= "Tard("+t+")"tardiness(t) = maximum({tmp(t),zeroVar})
end-dotwt = sum(t in TASKS) (WEIGHT(t) * tardiness(t))! Create the disjunctive constraints
forall(t in 1..NBTASKS-1, s in t+1..NBTASKS)(start(t) + DUR(t) <= start(s)) or(start(s) + DUR(s) <= start(t))! Define the branching strategy
Strategy(1):= probe_settle_disjunction(1)Strategy(2):= split_domain(KALIS_LARGEST_MIN,KALIS_MIN_TO_MAX)
cp_set_branching(Strategy)! Solve the problem
if not(cp_minimize(twt)) thenwriteln("problem is inconsistent")exit(0)end-ifforall (t in TASKS)
writeln("[", start(t).sol, "==>",
start(t).sol + DUR(t), "]:\t ",tardiness(t).sol, " (", tmp(t).sol, ")")
writeln("Total weighted tardiness: ", twt.sol)
end-model
Related topics
settle_disjunction probe_assign_var split_domain

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

180

Subroutines

split_domain
PurposeCreates a split_domain branching scheme. This will split the domain of every branching variable X
in two parts, one branch with the case X ≤ alpha and the other branch X >alpha where alpha is avalue in the domain of X.

Synopsisfunction split_domain(varsel:string, valsel:string, variables:set of cpvar,
leqfirst:boolean, stopsplit: integer) : cpbranching
function split_domain(varsel:string, valsel:string, variables:array(range) of cpvar,
leqfirst:boolean, stopsplit: integer) : cpbranching
function split_domain(varsel:string, valsel:string, variables:cpvarlist,
leqfirst:boolean, stopsplit: integer) : cpbranching
function split_domain(varsel:string, valsel:string, leqfirst:boolean, stopsplit:
integer) : cpbranching
function split_domain(varsel:string, valsel:string) : cpbranching
function split_domain(varsel:string, valsel:string, variables:array(range) of cpvar,
leqfirst:boolean, stopsplit: integer, probeLevel:integer) : cpbranching
function split_domain(varsel:string, valsel:string, variables:set of cpfloatvar,
leqfirst:boolean, stopsplit: integer) : cpbranching
function split_domain(varsel:string, valsel:string, variables:array(range) of
cpfloatvar, leqfirst:boolean, stopsplit: integer) : cpbranching
Arguments
varselvalselvariables
leqfirst
stopsplit

the variable selector name (pre-defined constant or user-defined function name)the value selector (pre-defined constant or user-defined function name)list of variables to branch on
Explore the case ≤ first if truestop branching if the size of the domain of the variable is less than stopsplit

Return value
split_domain branching scheme
ExampleThe following example shows how to use a split_domain branching scheme during the searchmodel "User branching"uses "kalis"parameters
ALG=1
end-parameters
forward function varchoice(Vars: cpvarlist): integer
forward function varchoice2(Vars: cpvarlist): integer

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

181

Subroutines

forward function valchoice(x: cpvar): integer
forward function valchoice2(x: cpvar): integer
setparam("KALIS_DEFAULT_LB", 0);
setparam("KALIS_DEFAULT_UB", 20)
declarations
R = 1..10
y: array(R) of cpvar
C: array(R) of integer
Strategy: array(range) of cpbranchingend-declarations
C:: [4, 7, 2, 6, 9, 0,-1, 3, 8,-2]
all_different(y)forall(i in R | isodd(i)) y(i) >= y(i+1) + 1
y(4) + y(1) = 13; y(8) <= 15; y(7) <> 5
! Definition of user branching strategies:
Strategy(1):= assign_and_forbid("varchoice2", "valchoice", y)Strategy(2):= assign_var("varchoice", "valchoice", y)Strategy(3):= split_domain("varchoice", "valchoice2", y, true, 2)Strategy(4):= split_domain("varchoice2", "valchoice", y, false, 5)! Select a branching strategy
cp_set_branching(Strategy(ALG))
if cp_find_next_sol thenforall(i in R) write(getsol(y(i)), " ")writeln
end-if!--------------------------------------------------------------! **** Variable choice ****
! **** Choose variable with largest degree + smallest domainfunction varchoice(Vars: cpvarlist): integer
declarations
Vset,Iset: set of integer
end-declarations! Get the number of elements of "Vars"
listsize:= getsize(Vars)! Set on uninstantiated variables
forall(i in 1..listsize)
if not is_fixed(getvar(Vars,i)) then Vset+= {i}; end-if
if Vset={} thenreturned:= 0else! Get the variables with max. degree
dmax:= max(i in Vset) getdegree(getvar(Vars,i))
forall(i in Vset)
if getdegree(getvar(Vars,i)) = dmax then Iset+= {i}; end-if

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

182

Subroutines

dsize:= MAX_INT! Choose var. with smallest domain among those indexed by ’Iset’
forall(i in Iset)
if getsize(getvar(Vars,i)) < dsize thenreturned:= idsize:= getsize(getvar(Vars,i))
end-ifend-ifwriteln(returned)
end-function! **** Choose variable y(i) with smallest value of C(i)function varchoice2(Vars: cpvarlist): integer
declarations
Vset,Iset: set of integer
VarInd: array(Iset) of integer
end-declarations! Set on uninstantiated variables
listsize:= getsize(Vars)
forall(i in 1..listsize)
if not is_fixed(getvar(Vars,i)) then Vset+= {i}; end-if
if getsize(Vset)=0 thenreturned:= 0else! Establish a correspondence of indices between ’Vars’ and ’y’
forall(i in R)
forall(j in Vset)
if is_same(getvar(Vars,j), y(i)) then
VarInd(i):= j
Vset -= {j}break 1
end-if! Choose the variable
imin:= min(i in Iset) i; cmin:= C(imin)
forall(i in Iset)
if C(i) < cmin thenimin:= i; cmin:= C(i)end-ifreturned:= VarInd(imin)
end-ifwriteln(imin, " ", returned)
end-function!--------------------------------------------------------------! *** Value choice ****
! **** Choose the next value one third larger than lower bound! (Strategy may be used with any branching scheme since it! makes sure that the chosen value lies in the domain)function valchoice(x: cpvar): integer! returned:= getlb(x)Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

183

Subroutines

returned:= getnext(x, getlb(x) + round((getub(x)-getlb(x))/3))
writeln("Value: ", returned, " ", contains(x,returned)," x: ", x)
end-function! **** Split the domain into lower third and upper two thirds! (Strategy to be used only with ’split_domain’ branching since! the chosen value may not be in the domain)function valchoice2(x: cpvar): integer
returned:= getlb(x) + round((getub(x)-getlb(x))/3)
writeln("Value: ", returned, " x: ", x)
end-function
end-model
Related topics
assign_var assign_and_forbid probe_assign_var settle_disjunction

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

184

Subroutines

task_serialize
PurposeCreates a Task Serializer branching scheme that serializes the tasks passed in argument. The
branching consists in choosing one task to schedule. Then a branch is created for each possible
duration for this task. Once the duration is determined a branch is created for each posssible
starting values for this task. When the start and the duration are fixed, the task is scheduled andthe process is repeated until all the tasks are serialized.

Synopsisfunction task_serialize(taskSelector:string, durationHeuristic:string,
startHeuristic:string, tasks:set of cptask) : cpbranching
function task_serialize(taskSelector:string, durationHeuristic:string,
startHeuristic:string, tasks:array of cptask) : cpbranching
function task_serialize(taskSelector:string, durationHeuristic:string,
startHeuristic:string, tasks:array of cptask, limit:integer) : cpbranching
function task_serialize(taskSelector:string, durationHeuristic:string,
startHeuristic:string, tasks:array of cptask, limit:integer) : cpbranching
function task_serialize(taskSelector:string, durationHeuristic:string,
startHeuristic:string, tasks:array of cptask, limit:integer) : cpbranching
function task_serialize(taskSelector:string, durationHeuristic:string,
startHeuristic:string, tasks:array of cptask, limit:integer) : cpbranching

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

185

Subroutines

Arguments
taskSelector
durationHeuristic
startHeuristic
tasks
limit

the task selector
the task duration assignment heuristic
the task start time assignment heuristic
the set of tasks to be serialized.
discrepancy limit: value 0 means strictly following the branching scheme,
positive values indicate the permissible number of deviations from thebranching scheme.

Return value
The resulting Task Serializer branching scheme
ExampleThe following example shows how to use the task_serialize branching scheme to solve a small
cumulative scheduling problem:*****************************************************************!)
model "Tasks serialization example"
uses "kalis"declarations
Masonry, Carpentry, Roofing, Windows, Facade, Garden, Plumbing,Ceiling, Painting, MovingIn : cptask! Declaration of tasks
taskset : set of cptask
money_available : cpresource! Resource declaration
end-declarations
forward function selectNextTask(tasks: cptasklist) : integer! ’money_available’ is a cumulative resource with max. amount of 29$
set_resource_attributes(money_available,KALIS_DISCRETE_RESOURCE,29)! Limit resource availability to 20$ in the time interval [0,14]
setcapacity( money_available, 0, 14, 20 )! Setting the task durations and predecessor sets
set_task_attributes(Masonry , 7 )set_task_attributes(Carpentry, 3, {Masonry} )set_task_attributes(Roofing , 1, {Carpentry} )set_task_attributes(Windows , 1, {Roofing} )
set_task_attributes(Facade, 2, {Roofing} )
set_task_attributes(Garden, 1, {Roofing} )
set_task_attributes(Plumbing , 8, {Masonry} )set_task_attributes(Ceiling , 3, {Masonry} )set_task_attributes(Painting , 2, {Ceiling} )
set_task_attributes(MovingIn , 1, {Windows,Facade,Garden,Painting})! Setting the resource consumptions
consumes(Masonry , 7, money_available )consumes(Carpentry, 3, money_available )consumes(Roofing , 1, money_available )consumes(Windows , 1, money_available )consumes(Facade, 2, money_available )consumes(Garden, 1, money_available )consumes(Plumbing , 8, money_available )Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

186

Subroutines

consumes(Ceiling , 3, money_available )consumes(Painting , 2, money_available )consumes(MovingIn , 1, money_available )! Set of tasks to scheduletaskset := {Masonry, Carpentry, Roofing, Windows, Facade, Garden,
Plumbing, Ceiling, Painting, MovingIn}! Set the custom branching strategy using task_serialize:! - the task serialization process will use the function!
"selectNextTask" to look for the next task to fix! - it will use the "KALIS_MAX_TO_MIN" value selection heuristic!
to set the tasks duration variable! - and the "KALIS_MIN_TO_MAX" value selection heuristic to set!
the start of the task
cp_set_branching(task_serialize("selectNextTask",
KALIS_MAX_TO_MIN, KALIS_MIN_TO_MAX, taskset))! Find the optimal schedule (minimizing the makespan)
if (0 <> cp_schedule(getmakespan)) thencp_show_sol
else
writeln("No solution found")end-if!------------------------------------------------------------! **** Function to select the next task to schedulefunction selectNextTask(tasks: cptasklist) : integer
write("selectNextTask : ")declarations
Vset,Iset: set of integer
end-declarations! Get the number of elements of "tasks"
listsize:= getsize(tasks)! Set of uninstantiated variables
forall(i in 1..listsize)
if not is_fixed(getstart(gettask(tasks,i))) or
not is_fixed(getduration(gettask(tasks,i))) thenVset+= {i};end-ifif Vset={} thenreturned:= 0else! Get the variables with max. degree
dmax:= max(i in Vset) getsize(getduration(gettask(tasks,i)))forall(i in Vset)
if getsize(getduration(gettask(tasks,i))) = dmax then
Iset+= {i}; end-if
dsize:= MAX_INT! Choose var. with smallest domain among those indexed by ’Iset’
forall(i in Iset)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

187

Subroutines

if getsize(getstart(gettask(tasks,i))) < dsize thenreturned:= idsize:= getsize(getstart(gettask(tasks,i)))
end-ifend-ifif (returned <> 0) thenwriteln(gettask(tasks,returned))
end-ifend-function
end-model
Related topics
assign_var assign_and_forbid probe_assign_var split_domain

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

188

Subroutines

cp_set_branching
PurposeSets the branching strategy to use during the search for a solution; please refer to the ’Paradigm’
section of this reference manual for further details.
Synopsisprocedure cp_set_branchingprocedure cp_set_branching(Strategy:cpbranching)procedure cp_set_branching(Strategy:array(range) of cpbranching)Argument
Strategya branching strategy (single cpbranching or cpbranching array)

ExampleThe following example shows how to set the search strategy:
model "User branching"uses "kalis"parameters
ALG=1
end-parameters
forward function varchoice(Vars: cpvarlist): integer
forward function varchoice2(Vars: cpvarlist): integer
forward function valchoice(x: cpvar): integer
forward function valchoice2(x: cpvar): integer
setparam("KALIS_DEFAULT_LB", 0);
setparam("KALIS_DEFAULT_UB", 20)
declarations
R = 1..10
y: array(R) of cpvar
C: array(R) of integer
Strategy: array(range) of cpbranchingend-declarations
C:: [4, 7, 2, 6, 9, 0,-1, 3, 8,-2]
all_different(y)forall(i in R | isodd(i)) y(i) >= y(i+1) + 1
y(4) + y(1) = 13; y(8) <= 15; y(7) <> 5
! Definition of user branching strategies:
Strategy(1):= assign_and_forbid("varchoice2", "valchoice", y)Strategy(2):= assign_var("varchoice", "valchoice", y)Strategy(3):= split_domain("varchoice", "valchoice2", y, true, 2)Strategy(4):= split_domain("varchoice2", "valchoice", y, false, 5)! Select a branching strategy
cp_set_branching(Strategy(ALG))
if cp_find_next_sol thenforall(i in R) write(getsol(y(i)), " ")Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

189

Subroutines

writeln
end-if!--------------------------------------------------------------! **** Variable choice ****
! **** Choose variable with largest degree + smallest domainfunction varchoice(Vars: cpvarlist): integer
declarations
Vset,Iset: set of integer
end-declarations! Get the number of elements of "Vars"
listsize:= getsize(Vars)! Set on uninstantiated variables
forall(i in 1..listsize)
if not is_fixed(getvar(Vars,i)) then Vset+= {i}; end-if
if Vset={} thenreturned:= 0else! Get the variables with max. degree
dmax:= max(i in Vset) getdegree(getvar(Vars,i))
forall(i in Vset)
if getdegree(getvar(Vars,i)) = dmax then Iset+= {i}; end-if
dsize:= MAX_INT! Choose var. with smallest domain among those indexed by ’Iset’
forall(i in Iset)
if getsize(getvar(Vars,i)) < dsize thenreturned:= idsize:= getsize(getvar(Vars,i))
end-ifend-ifwriteln(returned)
end-function! **** Choose variable y(i) with smallest value of C(i)function varchoice2(Vars: cpvarlist): integer
declarations
Vset,Iset: set of integer
VarInd: array(Iset) of integer
end-declarations! Set on uninstantiated variables
listsize:= getsize(Vars)
forall(i in 1..listsize)
if not is_fixed(getvar(Vars,i)) then Vset+= {i}; end-if
if getsize(Vset)=0 thenreturned:= 0else! Establish a correspondence of indices between ’Vars’ and ’y’
forall(i in R)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

190

Subroutines

forall(j in Vset)
if is_same(getvar(Vars,j), y(i)) then
VarInd(i):= j
Vset -= {j}break 1
end-if! Choose the variable
imin:= min(i in Iset) i; cmin:= C(imin)
forall(i in Iset)
if C(i) < cmin thenimin:= i; cmin:= C(i)end-ifreturned:= VarInd(imin)
end-ifwriteln(imin, " ", returned)
end-function!--------------------------------------------------------------! *** Value choice ****
! **** Choose the next value one third larger than lower bound! (Strategy may be used with any branching scheme since it! makes sure that the chosen value lies in the domain)function valchoice(x: cpvar): integer! returned:= getlb(x)returned:= getnext(x, getlb(x) + round((getub(x)-getlb(x))/3))
writeln("Value: ", returned, " ", contains(x,returned)," x: ", x)
end-function! **** Split the domain into lower third and upper two thirds! (Strategy to be used only with ’split_domain’ branching since! the chosen value may not be in the domain)function valchoice2(x: cpvar): integer
returned:= getlb(x) + round((getub(x)-getlb(x))/3)
writeln("Value: ", returned, " x: ", x)
end-function
end-model
Related topics
settle_disjunction assign_var assign_and_forbid split_domain Chapter 4

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

191

Subroutines

cp_show_stats
PurposeThis procedure prints some statistics about the search process (time elapsed, number of nodes,
depth, number of backtracks)
Synopsisprocedure cp_show_stats
Related topics
cp_show_prob cp_show_var

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

192

Subroutines

bs_group
PurposeCreate a group of branching schemes. A group of branching schemes is an ordered list of
branching schemes. It is used as input to the bs_group_serializer branching scheme. A user ’tag’
information can be associated with a group in order to link this group to a specific user structure.

Synopsisfunction bs_group(branchings:
function bs_group(branchings:
Arguments
branchingstag

set of cpbranching, tag:integer) : cpbsgrouparray of cpbranching, tag:integer) : cpbsgroupthe branching schemes forming the group
tag associated with the branching scheme group (use and interpretation entirely
up to the user)

Related topics
group_serializer

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

193

Subroutinesgroup_serializer
PurposeA branching scheme Group Serializer is a branching scheme of branching schemes. That means, it
can be seen as a meta-branching scheme. The search can be decomposed into clusters ofbranching schemes that will be explored based upon a specific dynamic group selection heuristic.
When a specific group is selected, the ordered branching scheme list of this group will be treatedsequentially. Once all the branching schemes of the group have been treated, another branching
scheme group is selected with the group selection heuristic.
For example, the task_serializer branching scheme is a particular kind of group serializer heuristic
tailored for task based search tree exploration. In this case a group corresponds to a task and thelist of branching schemes is the following :1. start time variable
2. duration variable.

Synopsisfunction group_serializer(groups:
cpbranching
function group_serializer(groups:
integer) : cpbranching
Argumentsgroupsgroupselectorprobe

set of cpbsgroup, groupSelector:

string) :set of cpbsgroup, groupSelector:

string, probe:

the set of branching scheme groups
the group selection heuristic
the probe level

Related topics
bs_group

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

194

Subroutines

gettagPurposeGet the tag associated with the branching scheme group passed in argument. The tag is definedby the user when creating the group (see bs_group).
Synopsisfunction gettag(group:
Argumentgroup

cpbsgroup) :integerthe set of branching scheme groups

Related topics
group_serializer bs_group

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

195

Subroutines

9.6

Callbacks
cp_set_branch_callback

Sets the branch callback procedure

p. 203

cp_set_node_callback

Sets the node callback procedure

p. 200cp_set_solution_callback Sets the solution callback procedure

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

p. 197196

Subroutines

cp_set_solution_callback
PurposeSets the solution callback procedure that will be called each time that a solution has been foundby the solver. Note that this callback procedure does not take any argument.
Synopsisprocedure cp_set_solution_callback(callbackName:string)Argument
callbackName

the name of the procedure to call

ExampleThe following example shows how to use the solution callback:model "Using callbacks"
uses "kalis"declarations
NBTASKS = 5
TASKS = 1..NBTASKS
DUR: array(TASKS) of integer
DURs: array(set of cpvar) of integer
DUE: array(TASKS) of integer
WEIGHT: array(TASKS) of integer
start: array(TASKS) of cpvar
tmp: array(TASKS) of cpvar
tardiness: array(TASKS) of cpvar
twt: cpvar
zeroVar: cpvar
Strategy: array(range) of cpbranching
Disj: set of cpctr
nodesx: array(range) of integer
nodesy: array(range) of integer
currentpos: integer
end-declarations! Set of tasks! Task durations! Durations! Due dates! Weights of tasks! Start times! Aux. variable! Tardiness! Objective variable! 0-valued variable! Branching strategy! Disjunctions! x-coordinates! y-coordinates! Initialization of search tree data
nodesx(0) := 1
nodesy(0) := 0
currentpos := 1
! **********************************************************! solution_found: called each time a solution is found! **********************************************************
procedure solution_foundwriteln("A solution has been found :")forall (t in TASKS)
writeln("[", getsol(start(t)), "==>",(getsol(start(t)) + DUR(t)), "]:\t ",getsol(tardiness(t)), " (", getsol(tmp(t)), ")")
writeln("Total weighted tardiness: ", getsol(twt))
end-procedure! **********************************************************! node_explored: called each time a node is explored

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

197

Subroutines! **********************************************************
procedure node_explorednodesx(currentpos) += 1
if (nodesx(currentpos-1)>nodesx(currentpos)) thennodesx(currentpos) := nodesx(currentpos-1)
end-ifnodesy(currentpos) := -currentpos
writeln("[Node explored depth : " , (-nodesy(currentpos)), "]")
end-procedure! **********************************************************! go_down_branch: called each time the search goes down!
a branch of the search tree
! **********************************************************
procedure go_down_branchwriteln("[Branch go_down " , (-nodesy(currentpos)) , "]")
currentpos := currentpos + 1
end-procedure! **********************************************************! go_up_branch: called each time the search goes up!
a branch of the search tree
! **********************************************************
procedure go_up_branchcurrentpos := currentpos - 1
writeln("[Branch go_up " , (-nodesy(currentpos)) , "]")
end-procedure! **********************************************************! Problem definition! **********************************************************
DUR :: [21,53,95,55,34]
DUE :: [66,101,232,125,150]
WEIGHT :: [1,1,1,1,1]
setname(twt, "Total weighted tardiness")
zeroVar = 0
setname(zeroVar, "zeroVar")! Setting up the decision variables
forall (t in TASKS) do
start(t) >= 0
setname(start(t), "Start("+t+")")
DURs(start(t)):= DUR(t)tmp(t) = start(t) + DUR(t) - DUE(t)setname(tardiness(t), "Tard("+t+")")
tardiness(t) = maximum({tmp(t), zeroVar})
end-dotwt = sum(t in TASKS) (WEIGHT(t) * tardiness(t))! Create the disjunctive constraints
disjunctive(union(t in TASKS) {start(t)}, DURs, Disj, 1)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

198

Subroutines! The setxxxcallback methods must be called before! setting the branching with ’cp_set_branching’
cp_set_solution_callback("solution_found")cp_set_node_callback("node_explored")
cp_set_branch_callback("go_down_branch", "go_up_branch")
Strategy(0):= settle_disjunction
Strategy(1):= split_domain(KALIS_MAX_DEGREE,KALIS_MIN_TO_MAX)
cp_set_branching(Strategy)
if not(cp_minimize(twt)) thenwriteln("problem is inconsistent")exit(0)end-ifend-model
Related topics
getsol cp_set_node_callback cp_set_branch_callback

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

199

Subroutines

cp_set_node_callback
PurposeSets the node callback procedure that will be called each time that a node is explored by thesearch algorithm. Note that this callback procedure does not take any argument.
Synopsisprocedure cp_set_node_callback(callbackName:string)Argument
callbackName

the name of the procedure to call

ExampleThe following example shows how to use the node callback:model "Using callbacks"
uses "kalis"declarations
NBTASKS = 5
TASKS = 1..NBTASKS
DUR: array(TASKS) of integer
DURs: array(set of cpvar) of integer
DUE: array(TASKS) of integer
WEIGHT: array(TASKS) of integer
start: array(TASKS) of cpvar
tmp: array(TASKS) of cpvar
tardiness: array(TASKS) of cpvar
twt: cpvar
zeroVar: cpvar
Strategy: array(range) of cpbranching
Disj: set of cpctr
nodesx: array(range) of integer
nodesy: array(range) of integer
currentpos: integer
end-declarations! Set of tasks! Task durations! Durations! Due dates! Weights of tasks! Start times! Aux. variable! Tardiness! Objective variable! 0-valued variable! Branching strategy! Disjunctions! x-coordinates! y-coordinates! Initialization of search tree data
nodesx(0) := 1
nodesy(0) := 0
currentpos := 1
! **********************************************************! solution_found: called each time a solution is found! **********************************************************
procedure solution_foundwriteln("A solution has been found :")forall (t in TASKS)
writeln("[", getsol(start(t)), "==>",(getsol(start(t)) + DUR(t)), "]:\t ",getsol(tardiness(t)), " (", getsol(tmp(t)), ")")
writeln("Total weighted tardiness: ", getsol(twt))
end-procedure! **********************************************************! node_explored: called each time a node is explored

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information200

Subroutines! **********************************************************
procedure node_explorednodesx(currentpos) += 1
if (nodesx(currentpos-1)>nodesx(currentpos)) thennodesx(currentpos) := nodesx(currentpos-1)
end-ifnodesy(currentpos) := -currentpos
writeln("[Node explored depth : " , (-nodesy(currentpos)), "]")
end-procedure! **********************************************************! go_down_branch: called each time the search goes down!
a branch of the search tree
! **********************************************************
procedure go_down_branchwriteln("[Branch go_down " , (-nodesy(currentpos)) , "]")
currentpos := currentpos + 1
end-procedure! **********************************************************! go_up_branch: called each time the search goes up!
a branch of the search tree
! **********************************************************
procedure go_up_branchcurrentpos := currentpos - 1
writeln("[Branch go_up " , (-nodesy(currentpos)) , "]")
end-procedure! **********************************************************! Problem definition! **********************************************************
DUR :: [21,53,95,55,34]
DUE :: [66,101,232,125,150]
WEIGHT :: [1,1,1,1,1]
setname(twt, "Total weighted tardiness")
zeroVar = 0
setname(zeroVar, "zeroVar")! Setting up the decision variables
forall (t in TASKS) do
start(t) >= 0
setname(start(t), "Start("+t+")")
DURs(start(t)):= DUR(t)tmp(t) = start(t) + DUR(t) - DUE(t)setname(tardiness(t), "Tard("+t+")")
tardiness(t) = maximum({tmp(t), zeroVar})
end-dotwt = sum(t in TASKS) (WEIGHT(t) * tardiness(t))! Create the disjunctive constraints
disjunctive(union(t in TASKS) {start(t)}, DURs, Disj, 1)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

201

Subroutines! The setxxxcallback methods must be called before! setting the branching with ’cp_set_branching’
cp_set_solution_callback("solution_found")cp_set_node_callback("node_explored")
cp_set_branch_callback("go_down_branch", "go_up_branch")
Strategy(0):= settle_disjunction
Strategy(1):= split_domain(KALIS_MAX_DEGREE,KALIS_MIN_TO_MAX)
cp_set_branching(Strategy)
if not(cp_minimize(twt)) thenwriteln("problem is inconsistent")exit(0)end-ifend-model
Related topics
getsol cp_set_solution_callback cp_set_branch_callback

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

202

Subroutines

cp_set_branch_callback
PurposeSets the branch callback procedure that will be called each time that a branch is explored by thesearch algorithm. Note that this callback procedure does not take any argument.
Synopsisprocedure cp_set_branch_callback(callbackNameDown:string, callbackNameUp:string)Argument
callbackNameDown, callbackNameUp

the name of the procedure to call, in the case thebranch is explored downward (resp. upward)

ExampleThe following example shows how to use the branch callback:model "Using callbacks"
uses "kalis"declarations
NBTASKS = 5
TASKS = 1..NBTASKS
DUR: array(TASKS) of integer
DURs: array(set of cpvar) of integer
DUE: array(TASKS) of integer
WEIGHT: array(TASKS) of integer
start: array(TASKS) of cpvar
tmp: array(TASKS) of cpvar
tardiness: array(TASKS) of cpvar
twt: cpvar
zeroVar: cpvar
Strategy: array(range) of cpbranching
Disj: set of cpctr
nodesx: array(range) of integer
nodesy: array(range) of integer
currentpos: integer
end-declarations! Set of tasks! Task durations! Durations! Due dates! Weights of tasks! Start times! Aux. variable! Tardiness! Objective variable! 0-valued variable! Branching strategy! Disjunctions! x-coordinates! y-coordinates! Initialization of search tree data
nodesx(0) := 1
nodesy(0) := 0
currentpos := 1
! **********************************************************! solution_found: called each time a solution is found! **********************************************************
procedure solution_foundwriteln("A solution has been found :")forall (t in TASKS)
writeln("[", getsol(start(t)), "==>",(getsol(start(t)) + DUR(t)), "]:\t ",getsol(tardiness(t)), " (", getsol(tmp(t)), ")")
writeln("Total weighted tardiness: ", getsol(twt))
end-procedure! **********************************************************

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information203

Subroutines! node_explored: called each time a node is explored! **********************************************************
procedure node_explorednodesx(currentpos) += 1
if (nodesx(currentpos-1)>nodesx(currentpos)) thennodesx(currentpos) := nodesx(currentpos-1)
end-ifnodesy(currentpos) := -currentpos
writeln("[Node explored depth : " , (-nodesy(currentpos)), "]")
end-procedure! **********************************************************! go_down_branch: called each time the search goes down!
a branch of the search tree
! **********************************************************
procedure go_down_branchwriteln("[Branch go_down " , (-nodesy(currentpos)) , "]")
currentpos := currentpos + 1
end-procedure! **********************************************************! go_up_branch: called each time the search goes up!
a branch of the search tree
! **********************************************************
procedure go_up_branchcurrentpos := currentpos - 1
writeln("[Branch go_up " , (-nodesy(currentpos)) , "]")
end-procedure! **********************************************************! Problem definition! **********************************************************
DUR :: [21,53,95,55,34]
DUE :: [66,101,232,125,150]
WEIGHT :: [1,1,1,1,1]
setname(twt, "Total weighted tardiness")
zeroVar = 0
setname(zeroVar, "zeroVar")! Setting up the decision variables
forall (t in TASKS) do
start(t) >= 0
setname(start(t), "Start("+t+")")
DURs(start(t)):= DUR(t)tmp(t) = start(t) + DUR(t) - DUE(t)setname(tardiness(t), "Tard("+t+")")
tardiness(t) = maximum({tmp(t), zeroVar})
end-dotwt = sum(t in TASKS) (WEIGHT(t) * tardiness(t))! Create the disjunctive constraints
disjunctive(union(t in TASKS) {start(t)}, DURs, Disj, 1)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

204

Subroutines! The setxxxcallback methods must be called before! setting the branching with ’cp_set_branching’
cp_set_solution_callback("solution_found")cp_set_node_callback("node_explored")
cp_set_branch_callback("go_down_branch", "go_up_branch")
Strategy(0):= settle_disjunction
Strategy(1):= split_domain(KALIS_MAX_DEGREE,KALIS_MIN_TO_MAX)
cp_set_branching(Strategy)
if not(cp_minimize(twt)) thenwriteln("problem is inconsistent")exit(0)end-ifend-model
Related topics
getsol cp_set_solution_callback cp_set_node_callback

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

205

Subroutines

9.7

Scheduling
addpredecessors

Adds a set of predecessors for a task

p. 211

addsuccessors

Adds a set of tasks as successors of a task

p. 213

consumes

Sets the minimal and maximal amount of resource consumed by a task
for a particular resourcep. 233

cp_close_schedule

Close the schedule.

p. 268cp_get_default_schedule_strategy Gets the default schedule search strategy of cp_schedulep. 258cp_schedule

Optimizes the schedule with respect to an objective variable.

cp_set_schedule_strategy Sets the schedule search strategy for cp_schedulep. 231
p. 257

cp_show_schedule

Shows a textual representation of the current schedulegetassignment

Gets the cpvar representing the assignment of a task for a particular
resource.
p. 262

getcapacity

Get the maximal capacity of a resource for a specific time period.
p. 252getconsumption

Gets the cpvar representing the consumption of a task for a particular
resourcep. 219getduration

Gets the cpvar representing a task duration

p. 218getendGets the cpvar representing a task completion timep. 217getmakespanGets the cpvar representing the makespan of the schedule.

p. 232

getproduction

Gets the cpvar representing the production of a task for a particular
resourcep. 223

getprovision

Gets the cpvar representing the provision of a task for a particular
resourcep. 225getrequirement

Gets the cpvar representing the requirement of a task for a particular
resourcep. 221getsetuptime

Gets the sequence dependent setup times between two tasks

p. 255getstart

Gets the cpvar representing a task start timep. 216has_assignment

Tests whether an assignment decision variable for a task and aparticular resource exists.

p. 264is_consuming

Tests whether a task consumes a specific resourcep. 227

is_fixed

Tests if a task is fixed

p. 208is_fixed

Tests if a disjunction is fixed

p. 256

is_idletime

Tests if a timestep is an idle timestep for a resource.

p. 267

is_producing

Tests whether a task produces a specific resourcep. 229is_providing

Tests whether a task provides a specific resourcep. 230Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

p. 215206

Subroutines

is_requiring

Tests whether a task requires a specific resource

produces

Sets the minimal and maximal amount of resource produced by a task
for a particular resourcep. 239providesSets the minimal and maximal amount of resource provided by a task
for a particular resource.
p. 242requires

Sets the minimal and maximal amount of resource required by a task
for a particular resourcep. 236

resusage

Creates a resource usagep. 259

set_resource_attributes

Sets some attributes for a resourcep. 245

set_task_attributes

Sets some attributes for a task

p. 209setcapacity

Sets the maximal capacity of a resource between two time bounds.
p. 246setduration

Sets the duration of a task

p. 210setidletimes

Specifies the set of timesteps where a resource is idle.

p. 266setmaxavailability

Sets the maximal capacity of a resource between two time bounds.
p. 248

setminusage

Sets the minimum usage of a resource between two time bounds.
p. 250

setpredecessors

Sets the tasks that must precede a task

p. 212

setsetuptime

Sets sequence dependent setup times between two tasks

p. 254setsuccessors

Sets the set of tasks that must succeed a task

p. 214

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

p. 228207

Subroutines

is_fixed
PurposeReturns true if the task passed in argument has its start and completion times fixed.
Synopsisfunction is_fixed(task:cptask) :Argumenttaskbooleanthe task

Return value
true if task is fixed
ExampleThe following example shows how to see if a cptask task is fixed
if is_fixed(task) thenwrite(’task is fixed! ’)end-ifRelated topics
getlb getub getmiddle getsize getval getdegree gettarget getrand getnext getprev contains

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

208

Subroutines

set_task_attributes
PurposeSets some attributes for a task.
A cptask is represented by three cpvar:
 start representing the start time of the task
 end representing the completion time of the task duration representing the duration of the task.

These three structural variables are linked with the following constraint: task + duration ≤ end.
The start time variable represents two specific parameters of the task: the Earliest Start Time (EST,
represented by its lower bound) and its Latest Start Time (LST, represented by its upper bound).
The end variable represents another two parameters of the task: the Earliest Completion Time
(ECT, represented by its lower bound) and its Latest Completion Time (LCT, represented by its
upper bound). The duration variable represents the following two parameters of the task: theminimum task duration (Dmin, represented by its lower bound) and the maximum task duration(Dmax, represented by its upper bound). The graphic below illustrates these properties:

Synopsisprocedure set_task_attributes(task:cptask, duration:integer, resource:cpresource,
precedences:set of cptask)
procedure set_task_attributes(task:cptask, duration:integer, resource:cpresource)
procedure set_task_attributes(task:cptask, duration:integer)
procedure set_task_attributes(task:cptask, duration:integer, precedences:set of
cptask)procedure set_task_attributes(task:cptask, resource:cpresource, requirement:integer)
Arguments
task
durationresource
precedences
requirement

the task to set attributes
the duration of the taska resource that is required during the execution of the task
the set of tasks that must precede t in the scheduleamount of the specified resource required per time unit

ExampleThe following example shows how to set some attributes of a task:

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

209

Subroutines

setduration
PurposeA cptask is represented by three cpvar:
 ’start’ representing the start time of the task
 ’end’ representing the completion time of the task
 ’duration’ representing the duration of the task.

These three structural variables are linked with the following constraint: task + duration ≤ end.
The duration variable represents two specific parameters of the task: The minimum task duration(Dmin, represented by its lower bound) and the maximum task duration (Dmax, represented byits upper bound). The graphic below illustrates these properties:

Synopsisprocedure setduration(task:cptask, duration:integer)
procedure setduration(task:cptask, durationMin:integer, durationMax:integer)
Arguments
task
duration
durationMin
durationMax

a taskfixed duration of the task
minimum duration for the task
maximum duration for the task

Related topics
getduration

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

210

Subroutines

addpredecessors
PurposeAdds a set of tasks as predecessors to a task. A task precedes some other task when it must becompleted before the start of the second task. The following graphic shows two tasks A and B
where A precedes B (and respectively B succeeds A as the relation is reflexive):

Synopsisprocedure addpredecessors(task:cptask, predset:set of cptask)
Arguments
task
predsetthe task
the set of tasks that must precede ’task’

Related topics
addsucessors setpredecessors setsuccessors

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

211

Subroutines

setpredecessors
PurposeSets the set of tasks that must precede a task. A task precedes some other task when it must becompleted before the start of the second task. The following graphic shows two tasks A and B
where A precedes B (and respectively B succedes A as the relation is reflexive):

Synopsisprocedure setpredecessors(task:cptask, predset:set of cptask)
Arguments
task
predsetthe task
the set of tasks that must precede ’task’

Related topics
addpredecessors addsucessors setsuccessors

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

212

Subroutines

addsuccessors
PurposeAdds a set of tasks as successors of a task. A task succeeds some other task when its processing
cannot start before the completion of this task. The following graphic shows two tasks A and B
where A precedes B (and respectively B succeeds to A as the relation is reflexive):

Synopsisprocedure addsuccessors(task:cptask, succset:set of cptask)
Arguments
task
succsetthe task
the set of tasks that must succeed ’task’

Related topics
addpredecessors setpredecessors setsuccessors

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

213

Subroutines

setsuccessors
PurposeSets the set of tasks that must succeed a task. A task succeeds some other task when its processing
cannot start before the completion of this task. The following schema shows two tasks A and B
where A precedes B (and respectively B succeeds A as the relation is reflexive):

Synopsisprocedure setsuccessors(task:cptask, succset:set of cptask)
Arguments
task
succsetthe task
the set of tasks that must succeed ’task’

Related topics
addpredecessors addsucessors setpredecessors

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

214

Subroutines

cp_show_schedule
PurposeShows a textual representation of the current schedule
Synopsisprocedure cp_show_schedule

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

215

Subroutines

getstart
PurposeRetrieves the ’start’ variable of a task.
A cptask is represented by three cpvar:
 ’start’ representing the start time of the task
 ’end’ representing the completion time of the task
 ’duration’ representing the duration of the task.

These three structural variables are linked with the following constraint: start + duration ≤ end.
The start time variable represents two specific parameters of the task: the Earliest Starting Time
(EST represented by its lower bound) and its Latest Starting Time (LST represented by its upperbound). The graphic below illustrates these properties:

Synopsisfunction getstart(t:cptask) :Argumentt

cpvar

the task

Return value
The cpvar representing the start time of t
Related topics
getend getduration getconsumption getrequirement getproduction getprovision

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

216

Subroutines

getendPurposeRetrieves the ’end’ variable of a task.
A cptask is represented by three cpvar:
 ’start’ representing the start time of the task
 ’end’ representing the completion time of the task
 ’duration’ representing the duration of the task.

These three structural variables are linked with the following constraint: start + duration ≤ end.
The ’end’ variable represents two specific parameters of the task: the Earliest Completion Time
(ECT, represented by its lower bound) and its Latest Completion Time (LCT, represented by its
upper bound). The graphic below illustrates these properties:

Synopsisfunction getend(t:cptask) :Argumentt

cpvar

the task

Return value
The cpvar representing the completion time of t
Related topics
getstart getduration getconsumption getrequirement getproduction getprovision

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

217

Subroutines

getduration
PurposeRetrieves the ’duration’ variable of a task.
A cptask is represented by three cpvar:
 ’start’ representing the start time of the task
 ’end’ representing the completion time of the task
 ’duration’ representing the duration of the task.

These three structural variables are linked with the following constraint: start + duration ≤ end.
The duration variable represents two specific parameters of the task: the minimum task duration(Dmin, represented by its lower bound) and the maximum task duration (Dmax represented by its
upper bound). The graphic below illustrates these properties:

Synopsisfunction getduration(t:cptask) :Argumentt

cpvar

the task

Return value
The cpvar representing the duration of t
Related topics
getstart getend getconsumption getrequirement getproduction getprovision

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

218

Subroutines

getconsumption
PurposeGets the cpvar representing the consumption of a task for a particular resource.
A task consumes some amount of processing power of a resource when this amount must be
made available for the execution of the task. The resource requirement is considered as
renewable which means that whenever the task ends the processing power that was used is nolonger available for processing other tasks.
Synopsisfunction getconsumption(task:cptask, resource:cpresource) : cpvar
function getconsumption(task:cptask, resource:cpresource, p:integer) :Arguments
task
resourcep

integer

the task
the resource
the timestep

Return value
The cpvar representing the consumption of ’resource’ by ’task’
ExampleThe following example illustrates this:model "Producer Consumer"
uses "kalis"declarations
Masonry, Carpentry, Roofing, Windows, Facade, Garden, Plumbing,Ceiling, Painting, MovingIn : cptask! Declaration of tasks

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information219

Subroutinesmoney_available : cpresource
end-declarations! Resource declaration! ’money_available’ is a cumulative resource with max. amount of 29$
set_resource_attributes(money_available,KALIS_DISCRETE_RESOURCE,29)! Limit resource availability to 20$ in the time interval [0,14]
setcapacity(money_available, 0, 14, 20)! Setting the task durations and predecessor sets
set_task_attributes(Masonry , 7 )set_task_attributes(Carpentry, 3, {Masonry} )set_task_attributes(Roofing , 1, {Carpentry} )set_task_attributes(Windows , 1, {Roofing} )
set_task_attributes(Facade, 2, {Roofing} )
set_task_attributes(Garden, 1, {Roofing} )
set_task_attributes(Plumbing , 8, {Masonry} )set_task_attributes(Ceiling , 3, {Masonry} )set_task_attributes(Painting , 2, {Ceiling} )
set_task_attributes(MovingIn , 1, {Windows,Facade,Garden,Painting})! Setting the resource consumptions
consumes(Masonry , 7, money_available )consumes(Carpentry, 3, money_available )consumes(Roofing , 1, money_available )consumes(Windows , 1, money_available )consumes(Facade, 2, money_available )consumes(Garden, 1, money_available )consumes(Plumbing , 8, money_available )consumes(Ceiling , 3, money_available )consumes(Painting , 2, money_available )consumes(MovingIn , 1, money_available )! Find the optimal schedule (minimizing the makespan)
if cp_minimize(getmakespan) thencp_show_sol
else
writeln("No solution found")end-ifend-model
Related topics
getstart getend getduration getrequirement getproduction getprovision

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

220

Subroutines

getrequirement
PurposeGets the cpvar representing the requirement of a task for a particular resource.
A task requires some amount of processing power of a resource when this amount must be madeavailable for the execution of the task. The resource requirement is considered as recoverable
which means that whenever the task ends the processing power that was used by it becomes
available again for processing other tasks.
Synopsisfunction getrequirement(task:cptask, resource:cpresource) : cpvar
function getrequirement(task:cptask, resource:cpresource, p:integer) :Arguments
task
resourcep

integer

the task
the resource
the timestep

Return value
The cpvar representing the requirement of ’resource’ by ’task’
ExampleThe following example illustrates this:model "Producer Consumer"
uses "kalis"declarations
Masonry, Carpentry, Roofing, Windows, Facade, Garden, Plumbing,Ceiling, Painting, MovingIn : cptask! Declaration of tasks

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

221

Subroutinesmoney_available : cpresource
end-declarations! Resource declaration! ’money_available’ is a cumulative resource with max. amount of 29$
set_resource_attributes(money_available,KALIS_DISCRETE_RESOURCE,29)! Limit resource availability to 20$ in the time interval [0,14]
setcapacity(money_available, 0, 14, 20)! Setting the task durations and predecessor sets
set_task_attributes(Masonry , 7 )set_task_attributes(Carpentry, 3, {Masonry} )set_task_attributes(Roofing , 1, {Carpentry} )set_task_attributes(Windows , 1, {Roofing} )
set_task_attributes(Facade, 2, {Roofing} )
set_task_attributes(Garden, 1, {Roofing} )
set_task_attributes(Plumbing , 8, {Masonry} )set_task_attributes(Ceiling , 3, {Masonry} )set_task_attributes(Painting , 2, {Ceiling} )
set_task_attributes(MovingIn , 1, {Windows,Facade,Garden,Painting})! Setting the resource consumptions
consumes(Masonry , 7, money_available )consumes(Carpentry, 3, money_available )consumes(Roofing , 1, money_available )consumes(Windows , 1, money_available )consumes(Facade, 2, money_available )consumes(Garden, 1, money_available )consumes(Plumbing , 8, money_available )consumes(Ceiling , 3, money_available )consumes(Painting , 2, money_available )consumes(MovingIn , 1, money_available )! Find the optimal schedule (minimizing the makespan)
if cp_minimize(getmakespan) thencp_show_sol
else
writeln("No solution found")end-ifend-model
Related topics
getstart getend getduration getconsumption getproduction getprovision

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

222

Subroutines

getproduction
PurposeGets the cpvar representing the production of a task for a particular resource.
A task produces some amount of processing power for a resource at its start. The capacity
produced is considered as non-renewable which means that the produced capacity remains
available even after the termination of the task.
Synopsisfunction getproduction(task:cptask, resource:cpresource) : cpvar
function getproduction(task:cptask, resource:cpresource, p:integer) :Arguments
task
resourcep

integer

the task
the resource
the timestep

Return value
The cpvar representing the production of ’resource’ by ’task’
ExampleThe following example illustrates this:model "Producer Consumer"
uses "kalis"declarations
Masonry, Carpentry, Roofing, Windows, Facade, Garden, Plumbing,Ceiling, Painting, MovingIn : cptask! Declaration of tasksmoney_available : cpresource! Resource declaration

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

223

Subroutines

end-declarations! ’money_available’ is a cumulative resource with max. amount of 29$
set_resource_attributes(money_available,KALIS_DISCRETE_RESOURCE,29)! Limit resource availability to 20$ in the time interval [0,14]
setcapacity(money_available, 0, 14, 20)! Setting the task durations and predecessor sets
set_task_attributes(Masonry , 7 )set_task_attributes(Carpentry, 3, {Masonry} )set_task_attributes(Roofing , 1, {Carpentry} )set_task_attributes(Windows , 1, {Roofing} )
set_task_attributes(Facade, 2, {Roofing} )
set_task_attributes(Garden, 1, {Roofing} )
set_task_attributes(Plumbing , 8, {Masonry} )set_task_attributes(Ceiling , 3, {Masonry} )set_task_attributes(Painting , 2, {Ceiling} )
set_task_attributes(MovingIn , 1, {Windows,Facade,Garden,Painting})! Setting the resource consumptions
consumes(Masonry , 7, money_available )consumes(Carpentry, 3, money_available )consumes(Roofing , 1, money_available )consumes(Windows , 1, money_available )consumes(Facade, 2, money_available )consumes(Garden, 1, money_available )consumes(Plumbing , 8, money_available )consumes(Ceiling , 3, money_available )consumes(Painting , 2, money_available )consumes(MovingIn , 1, money_available )! Find the optimal schedule (minimizing the makespan)
if cp_minimize(getmakespan) thencp_show_sol
else
writeln("No solution found")end-ifend-model
Related topics
getstart getend getduration getconsumption getrequirement getprovision

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

224

Subroutines

getprovision
PurposeGets the cpvar representing the provision of a task for a particular resource.
A task provides some amount of processing power for a resource during its execution. The
capacity provided is considered as renewable which means that whenever the providing task
ends, the provided capacity is no longer available.
Synopsisfunction getprovision(task:cptask, resource:cpresource) : cpvar
function getprovision(task:cptask, resource:cpresource, p:integer) :Arguments
task
resourcep

integer

the task
the resource
the timestep

Return value
The cpvar representing the provision of ’resource’ by ’task’
ExampleThe following example illustrates this:model "Producer Consumer"
uses "kalis"declarations
Masonry, Carpentry, Roofing, Windows, Facade, Garden, Plumbing,Ceiling, Painting, MovingIn : cptask! Declaration of tasksmoney_available : cpresource! Resource declaration

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

225

Subroutines

end-declarations! ’money_available’ is a cumulative resource with max. amount of 29$
set_resource_attributes(money_available,KALIS_DISCRETE_RESOURCE,29)! Limit resource availability to 20$ in the time interval [0,14]
setcapacity(money_available, 0, 14, 20)! Setting the task durations and predecessor sets
set_task_attributes(Masonry , 7 )set_task_attributes(Carpentry, 3, {Masonry} )set_task_attributes(Roofing , 1, {Carpentry} )set_task_attributes(Windows , 1, {Roofing} )
set_task_attributes(Facade, 2, {Roofing} )
set_task_attributes(Garden, 1, {Roofing} )
set_task_attributes(Plumbing , 8, {Masonry} )set_task_attributes(Ceiling , 3, {Masonry} )set_task_attributes(Painting , 2, {Ceiling} )
set_task_attributes(MovingIn , 1, {Windows,Facade,Garden,Painting})! Setting the resource consumptions
consumes(Masonry , 7, money_available )consumes(Carpentry, 3, money_available )consumes(Roofing , 1, money_available )consumes(Windows , 1, money_available )consumes(Facade, 2, money_available )consumes(Garden, 1, money_available )consumes(Plumbing , 8, money_available )consumes(Ceiling , 3, money_available )consumes(Painting , 2, money_available )consumes(MovingIn , 1, money_available )! Find the optimal schedule (minimizing the makespan)
if cp_minimize(getmakespan) thencp_show_sol
else
writeln("No solution found")end-ifend-model
Related topics
getstart getend getduration getconsumption getrequirement getproduction

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

226

Subroutines

is_consuming
PurposeReturns true IFF the specified task consumes a specific resource.
Synopsisfunction is_consuming(task:cptask, resource:cpresource) :Arguments
task
resource

booleanthe task
the resource

Return value
true IFF the task consumes the specified resource, false otherwise
Related topics
is_requiring is_producing is_providing

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

227

Subroutines

is_requiring
PurposeReturns true IFF the specified task requires a specific resource.
Synopsisfunction is_requiring(task:cptask, resource:cpresource) :Arguments
task
resource

booleanthe task
the resource

Return value
true IFF the task requires the specified resource, false otherwise
Related topics
is_consuming is_producing is_providing

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

228

Subroutines

is_producing
PurposeReturns true IFF the specified task produces a specific resource.
Synopsisfunction is_producing(task:cptask, resource:cpresource) :Arguments
task
resource

booleanthe task
the resource

Return value
true IFF the task produces the specified resource, false otherwise
Related topics
is_consuming is_requiring is_providing

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information229

Subroutines

is_providing
PurposeReturns true IFF the specified task provides a specific resource.
Synopsisfunction is_providing(task:cptask, resource:cpresource) :Arguments
task
resource

booleanthe task
the resource

Return value
true IFF the task provides the specified resource, false otherwise
Related topics
is_consuming is_requiring is_producing

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

230

Subroutines

cp_schedule
PurposeOptimizes the schedule with respect to an objective variable.
Synopsisfunction cp_schedule(obj:cpvar) : integerfunction cp_schedule(obj:cpfloatvar) : integerfunction cp_schedule(obj:cpfloatvar, maximization:boolean) : integerfunction cp_schedule(obj:cpvar, maximization:boolean) : integer
Arguments
obj
maximization

the objective variable
true for maximization of the objective and false for minimization (default:
minimization)

Return value
0 if schedule is inconsistent, 1 if schedule is suboptimal, 2 if schedule is optimal
Related topics
getmakespan cp_set_schedule_strategy

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

231

Subroutines

getmakespanPurposeGets the cpvar representing the makespan of the schedule. The makespan is the completion timeof the last task in the schedule.

Synopsisfunction getmakespan :cpvar

Return value
The cpvar representing the makespan of the schedule
Related topics
cp_schedule

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

232Subroutines

consumes
PurposeSets the minimal and maximal amount of resource consumed by a task for a particular resource.
A task consumes some amount of processing power of a resource when this amount must be
made available for the execution of the task. The resource requirement is considered as
renewable which means that whenever the tasks ends The processing power that was required is
no longer available for processing other tasks. Note that a minimal amount of 0 is possible thus
allowing modeling of alternative resources. The type of resource consumption can be defined inseveral ways:
 By specifying a resource and a constant consumption parameter ’consumption’. In this casethe resource consumption is constant other the execution of the task.
 By specifying a resource and a minimal ’minCons’ and maximal ’maxCons’ consumption

parameters: In this case the resource consumption is a decision variable but is constant otherthe execution of the task.
 By specifying a cpresusage ’usage’ (see resusage for further detail).
 By a set of alternative cpresusage ’optUsages’: This makes it possible to model alternative

resources. The type of resource consumption is defined by the resource usage passed inargument (see resusage for further detail).
 By a set of alternative cpresusage ’optUsages’ , a minimal ’minalt’ and a maximal ’maxalt’

number of alternative resources that must be consumed: Between [minalt..maxalt]
alternative consumptions from the set defined will be active which means that several
resources will be chosen to be consumed by the task. The type of resource consumption isdefined by the resource usage passed in argument (see resusage for further detail).
Synopsisprocedure consumes(task:cptask, consumption:integer, resource:cpresource)
procedure consumes(task:cptask, consumptionMin:integer, consumptionMax,
resource:cpresource)
procedure consumes(task:cptask, usage:cpresusage)procedure consumes(task:cptask, optUsages:set of cpresusage)procedure consumes(task:cptask, optUsages:set of cpresusage, minalt:integer,
maxalt:integer)
Arguments
task
consumption
minCons
maxConsresource
usage
optUsages
minaltmaxaltthe task
constant positive resource consumption
minimal resource consumption
maximal resource consumption
the resource to be consumed
the resource usage
the set of alternatives resource consumption
minimal number of resources that must be consumed
maximal number of resources that may be consumed

ExampleThe following example illustrates this:Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

233

Subroutines

model "Producer Consumer"
uses "kalis"declarations
Masonry, Carpentry, Roofing, Windows, Facade, Garden, Plumbing,Ceiling, Painting, MovingIn : cptask! Declaration of tasksmoney_available : cpresource! Resource declaration
end-declarations! ’money_available’ is a cumulative resource with max. amount of 29$
set_resource_attributes(money_available,KALIS_DISCRETE_RESOURCE,29)! Limit resource availability to 20$ in the time interval [0,14]
setcapacity(money_available, 0, 14, 20)! Setting the task durations and predecessor sets
set_task_attributes(Masonry , 7 )set_task_attributes(Carpentry, 3, {Masonry} )set_task_attributes(Roofing , 1, {Carpentry} )set_task_attributes(Windows , 1, {Roofing} )
set_task_attributes(Facade, 2, {Roofing} )
set_task_attributes(Garden, 1, {Roofing} )
set_task_attributes(Plumbing , 8, {Masonry} )set_task_attributes(Ceiling , 3, {Masonry} )set_task_attributes(Painting , 2, {Ceiling} )
set_task_attributes(MovingIn , 1, {Windows,Facade,Garden,Painting})! Setting the resource consumptions
consumes(Masonry , 7, money_available )Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

234

Subroutines

consumes(Carpentry, 3, money_available )consumes(Roofing , 1, money_available )consumes(Windows , 1, money_available )consumes(Facade, 2, money_available )consumes(Garden, 1, money_available )consumes(Plumbing , 8, money_available )consumes(Ceiling , 3, money_available )consumes(Painting , 2, money_available )consumes(MovingIn , 1, money_available )! Find the optimal schedule (minimizing the makespan)
if cp_minimize(getmakespan) thencp_show_sol
else
writeln("No solution found")end-ifend-model
Related topics
produces provides requires is_providing is_consuming is_requiring is_producing resusage

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

235

Subroutines

requiresPurposeSets the minimal and maximal amount of resource required by a task for a particular resource.
A task requires some amount of processing power of a resource when this amount must be madeavailable for the execution of the task. The resource requirement is considered as renewablewhich means that whenever the tasks ends the processing power that was required is stillavailable for processing other tasks. Note that a minimal amount of 0 is possible thus allowing
modelisation of alternative resources. The type of resource requirement can be defined in severalways: By specifying a resource and a constant requirement parameter ’requirement’. In this casethe resource requirement is constant other the execution of the task.
 By specifying a resource and a minimal ’minReq’ and maximal ’maxReq’ requirement

parameters: In this case the resource requirement is a decision variable but is constant otherthe execution of the task.
 By specifying a cpresusage ’usage’ (see resusage for further detail).
 By a set of alternative cpresusage ’optUsages’: This makes it possible to model alternative

resources. The type of resource requirement is defined by the resource usage passed inargument (see resusage for further detail).
 By a set of alternative cpresusage ’optUsages’, a minimal ’minalt’ and a maximal ’maxalt’

number of alternative resources that are required: Between [minalt..maxalt] alternativerequirements from the set will be active which means that several resources will be chosen as
requirements by the task. The type of resource requirement is defined by the resource usage
passed in argument (see resusage for further detail).
Synopsisprocedure requires(task:cptask, requirement:integer, resource:cpresource)
procedure requires(task:cptask, minReq:integer, maxReq:integer, resource:cpresource)
procedure requires(task:cptask, usage:cpresusage)procedure requires(task:cptask, optUsages:set of cpresusage)procedure requires(task:cptask, optUsages:set of cpresusage, minalt:integer,
maxalt:integer)
Arguments
task
requirement
minReq
maxReqresource
usage
optUsages
minaltmaxaltthe task
constant positive resource consumption
minimal resource requirement
maximal resource requirement
the resource to be required
the resource usage
the set of alternatives resource requirements
minimal number of resources that must be required
maximal number of resources that may be required

ExampleThe following example illustrates this:Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

236

Subroutines

model "Producer Consumer"
uses "kalis"declarations
Masonry, Carpentry, Roofing, Windows, Facade, Garden, Plumbing,Ceiling, Painting, MovingIn : cptask! Declaration of tasksmoney_available : cpresource! Resource declaration
end-declarations! ’money_available’ is a cumulative resource with max. amount of 29$
set_resource_attributes(money_available,KALIS_DISCRETE_RESOURCE,29)! Limit resource availability to 20$ in the time interval [0,14]
setcapacity(money_available, 0, 14, 20)! Setting the task durations and predecessor sets
set_task_attributes(Masonry , 7 )set_task_attributes(Carpentry, 3, {Masonry} )set_task_attributes(Roofing , 1, {Carpentry} )set_task_attributes(Windows , 1, {Roofing} )
set_task_attributes(Facade, 2, {Roofing} )
set_task_attributes(Garden, 1, {Roofing} )
set_task_attributes(Plumbing , 8, {Masonry} )set_task_attributes(Ceiling , 3, {Masonry} )set_task_attributes(Painting , 2, {Ceiling} )
set_task_attributes(MovingIn , 1, {Windows,Facade,Garden,Painting})! Setting the resource consumptions
consumes(Masonry , 7, money_available )Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

237

Subroutines

consumes(Carpentry, 3, money_available )consumes(Roofing , 1, money_available )consumes(Windows , 1, money_available )consumes(Facade, 2, money_available )consumes(Garden, 1, money_available )consumes(Plumbing , 8, money_available )consumes(Ceiling , 3, money_available )consumes(Painting , 2, money_available )consumes(MovingIn , 1, money_available )! Find the optimal schedule (minimizing the makespan)
if cp_minimize(getmakespan) thencp_show_sol
else
writeln("No solution found")end-ifend-model
Related topics
produces provides requires is_providing is_consuming is_requiring is_producing resusage

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

238

Subroutines

produces
PurposeSets the minimal and maximal amount of resource produced by a task for a particular resource.
A task produces some amount of processing power for a resource at its start. The capacity
produced is considered as non renewable which means that the produced capacity remains
available even after the completion of the task. Note that a minimal amount of 0 is possible thus
allowing modelisation of alternative resources. The type of resource production can be defined inseveral ways:
 By specifying a resource and a constant production parameter ’production’. In this case theresource production is constant other the execution of the task.
 By specifying a resource and a minimal ’minProd’ and maximal ’maxProd’ production

parameters: In this case the resource production is a decision variable but is constant overthe execution of the task.
 By specifying a cpresusage ’usage’ (see resusage for further detail).
 By a set of alternative cpresusage ’optUsages’: This makes it possible to model alternative

resources. The type of resource production is defined by the resource usage passed inargument (see resusage for further detail).
 By a set of alternative cpresusage ’optUsages’, a minimal ’minalt’ and a maximal ’maxalt’

number of alternative resources that may be produced: Between [minalt..maxalt] alternative
productions from the set will be active which means that several resources will be chosen to
be produced by the task. The type of resource production is defined by the resource usage
passed in argument (see resusage for further detail)
Synopsisprocedure produces(task:cptask, production:integer, resource:cpresource)
procedure produces(task:cptask,minProd:integer, maxProd:integer, resource:cpresource)
procedure produces(task:cptask, usage:cpresusage)procedure produces(task:cptask, optUsages:set of cpresusage)procedure produces(task:cptask, optUsages:set of cpresusage, minalt:integer,
maxalt:integer)
Arguments
task
production
minProd
maxProdresource
usage
optUsages
minaltmaxaltthe task
constant positive resource production
minimal resource production
maximal resource production
the resource to be produced
the resource usage
the set of alternatives resource production
minimal number of resources that must be produced
maximal number of resources that may be produced

ExampleThe following example illustrates this:Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

239

Subroutines

model "Producer Consumer"
uses "kalis"declarations
Masonry, Carpentry, Roofing, Windows, Facade, Garden, Plumbing,Ceiling, Painting, MovingIn : cptask! Declaration of tasksmoney_available : cpresource! Resource declaration
end-declarations! ’money_available’ is a cumulative resource with max. amount of 29$
set_resource_attributes(money_available,KALIS_DISCRETE_RESOURCE,29)! Limit resource availability to 20$ in the time interval [0,14]
setcapacity(money_available, 0, 14, 20)! Setting the task durations and predecessor sets
set_task_attributes(Masonry , 7 )set_task_attributes(Carpentry, 3, {Masonry} )set_task_attributes(Roofing , 1, {Carpentry} )set_task_attributes(Windows , 1, {Roofing} )
set_task_attributes(Facade, 2, {Roofing} )
set_task_attributes(Garden, 1, {Roofing} )
set_task_attributes(Plumbing , 8, {Masonry} )set_task_attributes(Ceiling , 3, {Masonry} )set_task_attributes(Painting , 2, {Ceiling} )
set_task_attributes(MovingIn , 1, {Windows,Facade,Garden,Painting})! Setting the resource consumptions
consumes(Masonry , 7, money_available )Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information240

Subroutines

consumes(Carpentry, 3, money_available )consumes(Roofing , 1, money_available )consumes(Windows , 1, money_available )consumes(Facade, 2, money_available )consumes(Garden, 1, money_available )consumes(Plumbing , 8, money_available )consumes(Ceiling , 3, money_available )consumes(Painting , 2, money_available )consumes(MovingIn , 1, money_available )! Find the optimal schedule (minimizing the makespan)
if cp_minimize(getmakespan) thencp_show_sol
else
writeln("No solution found")end-ifend-model
Related topics
produces provides requires is_providing is_consuming is_requiring is_producing resusage

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information241

SubroutinesprovidesPurposeSets the minimal and maximal amount of resource provided by a task for a particular resource.
A task provides some amount of processing power for a resource during its execution. The
capacity provided is considered as renewable which means that whenever the providing task
ends, the provided capacity is no longer available. Note that a minimal amount of 0 is possible
thus allowing modeling of alternative resources. The type of resource provision can be defined inseveral ways:
 By specifying a resource and a constant provision parameter ’provision’. In this case theresource provision is constant over the execution of the task.
 By specifying a resource and minimal ’minProv’ and maximal ’maxProv’ provision parameters:

In this case the resource provision is a decision variable but is constant over the execution of
the task.
 By specifying a cpresusage ’usage’ (see resusage for further detail).
 By a set of alternative cpresusage ’optUsages’: This makes it possible to model alternative

resources. The type of resource provision is defined by the resource usage passed inargument (see resusage for further detail).
 By a set of alternative cpresusage ’optUsages’, a minimal ’minalt’ and a maximal ’maxalt’

number of alternative resources that must be provided: Between [minalt..maxalt] alternative
provisions from the set will be active which means that several resources will be chosen to beprovided by the task. The type of resource provision is defined by the resource usage passed
in argument (see resusage for further detail).
Synopsisprocedure provides(task:cptask, provision:integer, resource:cpresource)
procedure provides(task:cptask, minProv:integer, maxProv:integer, resource:cpresource)
procedure provides(task:cptask, usage:cpresusage)procedure provides(task:cptask, optUsages:set of cpresusage)procedure provides(task:cptask, optUsages:set of cpresusage, minalt:integer,
maxalt:integer)
Arguments
task
provision
minProv
maxProv
resource
usage
optUsages
minaltmaxaltthe task
constant positive resource consumption
minimal resource consumption
maximal resource provision
the resource to be provided
the resource usage
the set of alternatives resource provisionminimal number of resources that must be provided
maximal number of resources that may be provided

ExampleThe following example illustrates this:Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

242

Subroutines

model "Producer Consumer"
uses "kalis"declarations
Masonry, Carpentry, Roofing, Windows, Facade, Garden, Plumbing,Ceiling, Painting, MovingIn : cptask! Declaration of tasksmoney_available : cpresource! Resource declaration
end-declarations! ’money_available’ is a cumulative resource with max. amount of 29$
set_resource_attributes(money_available,KALIS_DISCRETE_RESOURCE,29)! Limit resource availability to 20$ in the time interval [0,14]
setcapacity(money_available, 0, 14, 20)! Setting the task durations and predecessor sets
set_task_attributes(Masonry , 7 )set_task_attributes(Carpentry, 3, {Masonry} )set_task_attributes(Roofing , 1, {Carpentry} )set_task_attributes(Windows , 1, {Roofing} )
set_task_attributes(Facade, 2, {Roofing} )
set_task_attributes(Garden, 1, {Roofing} )
set_task_attributes(Plumbing , 8, {Masonry} )set_task_attributes(Ceiling , 3, {Masonry} )set_task_attributes(Painting , 2, {Ceiling} )
set_task_attributes(MovingIn , 1, {Windows,Facade,Garden,Painting})! Setting the resource consumptions
consumes(Masonry , 7, money_available )Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

243Subroutines

consumes(Carpentry, 3, money_available )consumes(Roofing , 1, money_available )consumes(Windows , 1, money_available )consumes(Facade, 2, money_available )consumes(Garden, 1, money_available )consumes(Plumbing , 8, money_available )consumes(Ceiling , 3, money_available )consumes(Painting , 2, money_available )consumes(MovingIn , 1, money_available )! Find the optimal schedule (minimizing the makespan)
if cp_minimize(getmakespan) thencp_show_sol
else
writeln("No solution found")end-ifend-model
Related topics
produces provides requires is_providing is_consuming is_requiring is_producing resusage

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

244

Subroutines

set_resource_attributes
PurposeSets some attributes for a resource.
A resource can be of two different types:
 Disjunctive when the resource can be used only by one task at a time.
 Cumulative when the resource can be used by several tasks at the same time.

Note that a disjunctive resource is semantically equivalent to a cumulative resource with maximal
capacity one and unit resource usage for each task using this resource but this equivalence does
not hold in term of constraint propagation. The parameter type allows the user to choose
between a disjunctive resource (KALIS_UNARY_RESOURCE) and a cumulative resource(KALIS_DISCRETE_RESOURCE). The last parameter, capacity, indicates the structural maximal
capacity of the resource. When the resource is disjunctive this parameter must be equal to one.
The structural capacity does not vary over time but a maximal temporal capacity can be imposedat any time point with the setcapacity function. The following graphic shows an example withthree tasks A, B and C processed on a disjunctive resource and on a cumulative resource withresource usage 3 for task A, 1 for task B and 1 for task C.

Synopsisprocedure set_resource_attributes(resource:cpresource, type:integer)
procedure set_resource_attributes(resource:cpresource, type:integer, capacity:integer)
procedure set_resource_attributes(resource:cpresource, type:integer, capacity:integer,
propagationHint:integer)
Arguments
resource
type
capacityalg

the resource
resource type: KALIS_DISCRETE_RESOURCE or KALIS_UNARY_RESOURCE
maximal capacity of a discrete resource
propagation algorithm choice: KALIS_TIMETABLING, KALIS_TASK_INTERVALS, or
KALIS_DISJUNCTIONS

Related topics
set_task_attributes

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

245

Subroutines

setcapacity
PurposeSets the maximal capacity (the maximal amount of processing units available) of a discrete
resource between two time bounds. This routine can only be applied to resources of type
KALIS_DISCRETE_RESOURCE.
Synopsisprocedure setcapacity(resource:cpresource, tmin:integer, tmax:integer, capa:integer)
Arguments
resource
tmin
tmax
capa

the resource
lower bound of the time interval
upper bound of the time interval
the maximal amount of processing units available of resource in the interval[tmin,tmax]

ExampleThe following example shows how to use setcapacity:model "Resource capacity"uses "kalis"declarations
A, B, C : cptask
resource : cpresource
end-declarations! Declaration of tasks! Declaration of resource

setname(A,"A"); setname(B,"B"); setname(C,"C")! The resource is a cumulative resource with maximum capacity 6
set_resource_attributes(resource, KALIS_DISCRETE_RESOURCE, 6)! Setting the resource capacity in the interval 0..2 to 3
setcapacity(resource, 0, 2, 3)! Setting the resource capacity in the interval 3..4 to 2
setcapacity(resource, 3, 4, 2)! Setting the resource capacity in time period 5 to 1
setcapacity(resource, 5, 5, 1)! Setting the task durations
set_task_attributes(A, 1)
set_task_attributes(B, 2)
set_task_attributes(C, 3)! Setting the resource requirements of the tasks
requires(A, 1, resource)
requires(B, 2, resource)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

246

Subroutines

requires(C, 3, resource)! Find the optimal schedule (minimizing the makespan)
if cp_schedule(getmakespan) <> 0 thencp_show_sol
else
writeln("no solution found")end-ifend-model
Related topics
setmaxavailability setminusage set_resource_attributes

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

247

Subroutines

setmaxavailability
PurposeSets the maximal capacity (the maximal amount of processing units available) of a resource
between two time bounds. This routine can only be applied to resources of type
KALIS_DISCRETE_RESOURCE.
Synopsisprocedure setmaxavailability(resource:cpresource, tmin:integer, tmax:integer,
capa:integer)
Arguments
resource
tmin
tmax
capa

the resource
lower bound of the time interval
upper bound of the time interval
the maximal amount of processing units available of resource in the interval[tmin,tmax]

ExampleThe following example shows how to use setcapacity:model "Resource capacity"uses "kalis"declarations
A, B, C : cptask
resource : cpresource
end-declarations! Declaration of tasks! Declaration of resource

setname(A,"A"); setname(B,"B"); setname(C,"C")! The resource is a cumulative resource with maximum capacity 6
set_resource_attributes(resource, KALIS_DISCRETE_RESOURCE, 6)! Setting the resource capacity in the interval 0..2 to 3
setcapacity(resource, 0, 2, 3)! Setting the resource capacity in the interval 3..4 to 2
setcapacity(resource, 3, 4, 2)! Setting the resource capacity in time period 5 to 1
setcapacity(resource, 5, 5, 1)! Setting the task durations
set_task_attributes(A, 1)
set_task_attributes(B, 2)
set_task_attributes(C, 3)! Setting the resource requirements of the tasks
requires(A, 1, resource)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

248

Subroutines

requires(B, 2, resource)
requires(C, 3, resource)! Find the optimal schedule (minimizing the makespan)
if cp_schedule(getmakespan) <> 0 thencp_show_sol
else
writeln("no solution found")end-ifend-model
Related topics
setcapacity setminusage set_resource_attributes

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

249

Subroutines

setminusage
PurposeSets the minimum usage (the minimum number of processing units used) of a resource between
two time bounds. This routine can only be applied to resources of type KALIS_DISCRETE_RESOURCE.
Synopsisprocedure setminusage(resource:cpresource, tmin:integer, tmax:integer, capa:integer)
Arguments
resource
tmin
tmax
capa

the resource
lower bound of the time interval
upper bound of the time interval
the minimum usage of processing units of resource in the interval [tmin,tmax]

ExampleThe following example shows how to use setcapacity:model "Resource capacity"uses "kalis"declarations
A, B, C : cptask
resource : cpresource
end-declarations! Declaration of tasks! Declaration of resource

setname(A,"A"); setname(B,"B"); setname(C,"C")! The resource is a cumulative resource with maximum capacity 6
set_resource_attributes(resource, KALIS_DISCRETE_RESOURCE, 6)! Setting the resource capacity in the interval 0..2 to 3
setcapacity(resource, 0, 2, 3)! Setting the resource capacity in the interval 3..4 to 2
setcapacity(resource, 3, 4, 2)! Setting the resource capacity in time period 5 to 1
setcapacity(resource, 5, 5, 1)! Setting the task durations
set_task_attributes(A, 1)
set_task_attributes(B, 2)
set_task_attributes(C, 3)! Setting the resource requirements of the tasks
requires(A, 1, resource)
requires(B, 2, resource)
requires(C, 3, resource)

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information250

Subroutines! Find the optimal schedule (minimizing the makespan)
if cp_schedule(getmakespan) <> 0 thencp_show_sol
else
writeln("no solution found")end-ifend-model
Related topics
setcapacity setmaxavailability set_resource_attributes

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information251Subroutines

getcapacity
PurposeGets the maximal capacity (the maximal amount of processing units available) of a resource
between two time bounds.
Synopsisfunction getcapacity(resource:cpresource, tmin:integer, tmax:integer, capa:integer) :integer
Arguments
resource
tslot

the resource
lowerbound of the time interval

ExampleThe following example shows how to use getcapacity:model "Resource capacity"uses "kalis"declarations
A, B, C : cptask
resource : cpresource
end-declarations! Declaration of tasks! Declaration of resource

setname(A,"A"); setname(B,"B"); setname(C,"C")! The resource is a cumulative resource with maximum capacity 6
set_resource_attributes(resource, KALIS_DISCRETE_RESOURCE, 6)! Setting the resource capacity in the interval 0..2 to 3
setcapacity(resource, 0, 2, 3)! Setting the resource capacity in the interval 3..4 to 2
setcapacity(resource, 3, 4, 2)! Setting the resource capacity in time period 5 to 1
setcapacity(resource, 5, 5, 1)! Setting the task durations
set_task_attributes(A, 1)
set_task_attributes(B, 2)
set_task_attributes(C, 3)! Setting the resource requirements of the tasks
requires(A, 1, resource)
requires(B, 2, resource)
requires(C, 3, resource)! Find the optimal schedule (minimizing the makespan)
if cp_schedule(getmakespan) <> 0 then

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

252

Subroutines

cp_show_sol
else
writeln("no solution found")end-ifend-model
Related topics
setcapacity

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

253

Subroutines

setsetuptime
PurposeSets sequence dependent setup times between two tasks. The setup time depends on the relative
execution order in the schedule of the two tasks.

Synopsisprocedure setsetuptime(task1:cptask, task2:cptask, task1_before_task2:integer,task2_before_task1:integer)
Arguments
task1
task2
task1_before_task2
task2_before_task1

a taskanother task
setup time between the two tasks if task1 prececedes task2
setup time between the two tasks if task2 prececedes task1

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

254

Subroutines

getsetuptime
PurposeReturn the sequence dependent setup times between task1 and task2 if task1 precedes task2. The
setup time depends on the relative execution order in the schedule of the two tasks.

Synopsisfunction getsetuptime(task1:cptask, task2:cptask) :Arguments
task1
task2

integera taskanother task

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

255

Subroutines

is_fixed
PurposeReturns true if the status of the disjunction passed in argument is known.
Synopsisfunction is_fixed(disj:cpctr) :Argument
disj

booleanthe disjunction

Return value
true if disjunction is fixed
ExampleThe following example shows how to see if a cpctr disj is fixed
if is_fixed(disj) thenwrite(’status of disj is known’)end-ifRelated topics
setpriority getpriority

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

256

Subroutines

cp_set_schedule_strategy
PurposeThe cp_schedule search algorithm is decomposed in two distinct phases. The first phase target thefinding of an near optimal heuristic solution quiclly. The second and last phase focuses on
improving the bound and prove optimality.
Synopsisprocedure cp_set_schedule_strategy(phase:integer, arrayBranching:array(range) of
cpbranching)procedure cp_set_schedule_strategy(phase:integer, branching:cpbranching)ArgumentsphasebranchingarrayBranchingalgorithm phase KALIS_INITIAL_SOLUTION,KALIS_OPTIMAL_SOLUTION
the search strategy
the search strategies

ExampleThe following example shows how to set the search stragey for the cp_schedule function
cp_set_schedule_strategy(KALIS_INITIAL_SOLUTION,
assign_var(KALIS_SMALLEST_MIN,KALIS_MIN_TO_MAX))
Related topics
KALIS_INITIAL_SOLUTION KALIS_OPTIMAL_SOLUTION cp_schedule

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

257

Subroutines

cp_get_default_schedule_strategy
PurposeThe cp_schedule search algorithm is decomposed in two distinct phases. The target of the firstphase is finding quickly a near optimal heuristic solution. The second and last phase focuses on
improving the bound and proving optimality.
Synopsisprocedure cp_get_default_schedule_strategy(phase:integer, branching:cpbranching)Argumentsphasebranchingalgorithm phase (KALIS_INITIAL_SOLUTION,KALIS_OPTIMAL_SOLUTION)
the search strategy

ExampleThe following example shows how to set the search stragey for the cp_schedule function
cp_set_schedule_strategy(KALIS_INITIAL_SOLUTION,
assign_var(KALIS_SMALLEST_MIN,KALIS_MIN_TO_MAX))
Related topics
KALIS_INITIAL_SOLUTION KALIS_OPTIMAL_SOLUTION cp_schedule

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

258

Subroutines

resusage
PurposeCreates a resource usage. A resource usage is a means to specify the way that a resource will be
produced/consumed/provided/required by a task. Three types of resource usages can be used: CASE 1: Constant resource usage. This is the simplest case where the resource usage isconstant all along the execution of the task. For example a task A will require 2 units ofresource R during its execution.
 CASE 2: Variable resource usage but constant over the execution of the task. This caseallows the resource usage to be variable but constant during the execution of the task.
Therefore, a decision variable is associated with the resource usage that can be constrained
like any other variable. For example a task A will require between 2 units and 4 units ofresource R during its execution.
 CASE 3: Variable resource usage over the execution of the task. This case allows the resource

usage to vary during the execution of the task using a resource usage profile defined as a listof integers. For example a task A will require [2,3,2,3,2,1,2,1] resource units wich means ’2’
for the first timestep of its execution; ’3’ for the second etc.. If the duration of the task
exceeds the length of the profile, then the resource usage is considered as 0 after the end of
the profile. If the task duration is smaller than the length of the profile, the profile will betruncated to the duration of the task.
Synopsisfunction resusage(resource:cpresource, usage:integer) : cpresusage
function resusage(resource:cpresource, usagemin:integer, usagemax:integer) :cpresusage
function resusage(resource:cpresource, profile:array of integer) : cpresusage
Arguments
resource
usage
usageminusagemax
profilethe resource
the constant resource usage
minimal resource usage
maximal resource usage
profile of resource usage

ExampleThe following example illustrates this:model "Non constant resource usage"
uses "kalis"forward procedure print_solution(tasks: set of cptask,
resources: set of cpresource)
declarations
res1,res2: cpresource

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information259

Subroutines

taska,taskb,taskc: cptask
end-declarations
taska.start<= 15
taska.duration = 4
taskb.start<= 15
taskb.duration = 3
taskc.start<= 15
taskc.duration = 5! Define a discrete resource with periods of unavailability
set_resource_attributes(res1, KALIS_DISCRETE_RESOURCE, 6)
setcapacity(res1, 0, 15, 0)
setcapacity(res1, 1, 5, 6)
setcapacity(res1, 7, 11, 6)
requires(taska, {resusage(res1,[1,3,5,6])})requires(taskb, {resusage(res1,[5,3,1])})requires(taskc, {resusage(res1,1,1)})! Define a resource with initial capacity at 0
set_resource_attributes(res2, KALIS_DISCRETE_RESOURCE, 0)
provides(taska, resusage(res2,[1,3,1,2]))
consumes(taskb, resusage(res2,[3,1,2]))
produces(taskc, resusage(res2,[3,1,2,0,2]))
if not cp_propagate thenwriteln("Problem is infeasible"); exit(1)end-ifwhile (cp_find_next_sol) do
print_solution({taska,taskb,taskc},{res1,res2})
end-do!------------------------------------------------------------!**** Display results ****
procedure print_solution(tasks: set of cptask,
resources: set of cpresource)
forall(res in resources) dowriteln("Resource ", res.name)forall(timeindex in 0..getub(getmakespan)) dowrite(strfmt(timeindex,3), " Cap: ", getcapacity(res,timeindex))
forall(t in tasks)
if getrequirement(t,res,timeindex)>0 thenwrite(", ", t.name, "(req):", getrequirement(t,res,timeindex))
elif getproduction(t,res,timeindex)>0 thenwrite(", ", t.name, "(prod):", getproduction(t,res,timeindex))
elif getconsumption(t,res,timeindex)>0 thenwrite(", ", t.name, "(cons):", getconsumption(t,res,timeindex))
elif getprovision(t,res,timeindex)>0 thenwrite(", ", t.name, "(prov):", getprovision(t,res,timeindex))
end-ifFair Isaac Corporation and Artelys SA Confidential and Proprietary Information

260

Subroutines

writeln
end-doend-doend-procedure
end-model
Related topics
set_task_attributes

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

261

Subroutines

getassignment
PurposeGets the cpvar representing the assignment of a task for a particular resource. In the following
example, either task A requires resource R1 with resource profile [1,2,1,1,2,1,1,2], or task A
requires resource R2 with resource profile [2,2,1,1,1,1,1,2]. The choice depends on the value ofthe decision variables A.assignment(R1) and A.assignment(R2) that can both take a value of 0 (thetask is not assigned to this resource) or a value of 1 (the task is assigned to this resource).

Synopsisfunction getassignment(task:cptask, resource:cpresource) :Arguments
task
resource

cpvar

the task
the resource

Return value
The cpvar representing the assignment of ’task’ to ’resource’
ExampleThe following example illustrates this:model "Alternative resources and non constant resource usage"
uses "kalis"declarations
res1,res2: cpresourcetaska,taskb : cptask
arr1,arr2: list of integer
end-declarations! Fix start times and durations
taska.start= 3taska.duration = 4
taskb.start= 3
taskb.duration = 4! Define 2 cumulative resources
set_resource_attributes(res1, KALIS_DISCRETE_RESOURCE, 4)
set_resource_attributes(res2, KALIS_DISCRETE_RESOURCE, 4)
setname(taska,"taska"); setname(taskb,"taskb")
setname(res1,"R1"); setname(res2,"R2")

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

262

Subroutines! Define alternative resources for both tasks
arr1 := [1,3,2,3]
arr2 := [2,4,1,3]
requires(taska, {resusage(res1,arr1),resusage(res2,arr2)}, 1, 1)
requires(taskb, {resusage(res1,1,1),resusage(res2,1,1)}, 1, 1)! Find all solutions
while (cp_find_next_sol) do
cp_show_sol
end-doend-model
Related topics
has_assignment getstart getend getduration getconsumption getrequirement getproduction
getprovision

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

263

Subroutines

has_assignment
PurposeIn the following example, either task A requires resource R1 with resource profile [1,2,1,1,2,1,1,2],
or task A requires resource R2 with resource profile [2,2,1,1,1,1,1,2]. The choice depends on thevalue of the decision variables A.assignment(R1) and A.assignment(R2) that can both take a valueof 0 (the task is not assigned to this resource) or a value of 1 (the task is assigned to this resource).

Synopsisfunction has_assignment(task:cptask, resource:cpresource) :Arguments
task
resource

booleanthe task
the resource

Return value
true IFF a cpvar representing the assignment of ’task’ to ’resource’ exists
ExampleThe following example illustrates this:model "Alternative resources and non constant resource usage"
uses "kalis"declarations
res1,res2: cpresourcetaska,taskb : cptask
arr1,arr2: list of integer
end-declarations! Fix start times and durations
taska.start= 3taska.duration = 4
taskb.start= 3
taskb.duration = 4! Define 2 cumulative resources
set_resource_attributes(res1, KALIS_DISCRETE_RESOURCE, 4)
set_resource_attributes(res2, KALIS_DISCRETE_RESOURCE, 4)
setname(taska,"taska"); setname(taskb,"taskb")
setname(res1,"R1"); setname(res2,"R2")! Define alternative resources for both tasks

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information264

Subroutines

arr1 := [1,3,2,3]
arr2 := [2,4,1,3]
requires(taska, {resusage(res1,arr1),resusage(res2,arr2)}, 1, 1)
requires(taskb, {resusage(res1,1,1),resusage(res2,1,1)}, 1, 1)! Find all solutions
while (cp_find_next_sol) do
cp_show_sol
end-doend-model
Related topics
getassignment getstart getend getduration getconsumption getrequirement getproduction
getprovision

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

265

Subroutines

setidletimes
PurposeSpecifies the set of timesteps during which a resource should be considered as idle. When a task
overlaps an idle timestep, resource usages are shifted to the right provided that the task duration
is variable.
Synopsisprocedure setidletimes(resource:cpresource, idleTimeSteps:
Arguments
resource
idleTimeSteps

set of integer)

the resource
The set of idle time steps

ExampleHere is an example:

Related topics
consumes requires provides produces resusage is_idletime

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

266

Subroutines

is_idletime
PurposeTests whether a specific timestep is defined as an idle time for the resource passed in theargument.
Synopsisfunction is_idletime(resource:cpresource, timestep:
Arguments
resource
timestep

integer) :booleanthe resource
The time step

ExampleHere is an example:

Related topics
consumes requires provides produces resusage is_idletime

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

267

Subroutines

cp_close_schedule
PurposeClose the schedule, i.e., mark problem definition as complete, and post the underlying structural
constraints of the tasks and resources. (A call to propagate does not automatically close theschedule.)
Synopsisprocedure cp_close_schedule

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

268

Subroutines

9.8

Linear relaxations
cp_add_linrelax_solver

Add a linear relaxation solver to the linear relaxation solver list p. 277

cp_clear_linrelax_solver Clear the linear relaxation solver list
cp_get_linrelax

Returns an automatic relaxation of the cp problem

p. 279p. 272

cp_remove_linrelax_solver Remove a linear relaxation solver from the linear relaxation solver
list
p. 278cp_show_relax

Pretty printing of a linear relaxation

p. 276

export_prob

Export the linear relaxation in LP format

p. 285

fix_to_relaxedFix the continuous variables to their optimal value in the relaxation
solver passed in argument
p. 274

generate_cuts

Generate and add cuts to the relaxation passed in parameters

p. 280get_indicator

Get an indicator variable for a given variable and a value.

p. 283

get_linrelax

Get the linear relaxation for a constraint

p. 284

get_linrelax_solver

Returns a linear relaxation solver from a linear relaxation, an objective
variables and some configuration parameters
p. 273

get_reduced_cost

Get a reduced cost value from a linear relaxation solver

p. 286

get_relaxed_value

Returns the optimal relaxed value for a variable in a relaxation

p. 287KALIS_LARGEST_REDUCED_COST Get a largest reduced cost variable selector from a linear
relaxation solver

p. 270KALIS_NEAREST_RELAXED_VALUE Get a nearest relaxed value selector from a linear relaxation
solverp. 271
lp_optimize

Launch LP/MIP solver without CP branching.

p. 281

set_integer

Set integrality flag for a variable in a linear relaxation

p. 288

set_linrelax_solver_attribute Parameter setting for a linear relaxation solver.

p. 282

set_verbose_levelSet the verbose level for a specific linear relaxation solver

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

p. 275269

Subroutines

KALIS_LARGEST_REDUCED_COST
PurposeGet a largest reduced cost variable selector from a linear relaxation solver.
Synopsisprocedure KALIS_LARGEST_REDUCED_COST(relaxationSolver:cplinrelaxsolver)
Argument
relaxationSolver

the linear relaxation solver

ExampleThe following example shows how to use this function with a specific relaxation solver
cp_set_branching(assign_var(KALIS_LARGEST_REDUCED_COST(mysolver),KALIS_NEAREST_RELAXED_VALUE(mysolver)))
Related topics
KALIS_NEAREST_RELAXED_VALUE cp_set_branching

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

270

Subroutines

KALIS_NEAREST_RELAXED_VALUE
PurposeGet a nearest relaxed value selector from a linear relaxation solver.
Synopsisprocedure KALIS_NEAREST_RELAXED_VALUE(relaxationSolver:cplinrelaxsolver)
Argument
relaxationSolver

the linear relaxation solver

ExampleThe following example shows how to use this function with a specific cplinrelaxsolver
cp_set_branching(assign_var(KALIS_LARGEST_REDUCED_COST(mysolver),KALIS_NEAREST_RELAXED_VALUE(mysolver)))
Related topics
KALIS_LARGEST_REDUCED_COST cp_set_branching

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

271

Subroutines

cp_get_linrelax
PurposeReturns an automatic relaxation of the cp problem
Synopsisfunction cp_get_linrelax(orientation:function cp_get_linrelax(orientation:
cplinrelax
Arguments
orientation
constraints

integer) : cplinrelax
integer,constraints: set of integer) :0 for an ’LP oriented’ relaxation (convex hull) and 1 for a ’MIP oriented’
relaxation (can be an exact representation of the underlying CP problem)the set of constraints types to relax (KALIS_LINEAR_CONSTRAINTS,
KALIS_LOGICAL_CONSTRAINTS, KALIS_DISTANCE_CONSTRAINTS,
KALIS_NON_LINEAR_CONSTRAINTS, KALIS_ALL_CONSTRAINTS)

Return value
A linear relaxation
ExampleThe following example shows how to obtain a ’MIP oriented’ relaxation by relaxing only thelinear part of the problem and the logical constraints.
relax := cp_get_linrelax(1,{KALIS_LINEAR_CONSTRAINTS,
KALIS_LOGICAL_CONSTRAINTS})
Related topics
get_linrelax_solver cp_add_linrelax_solver

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

272

Subroutines

get_linrelax_solver
PurposeReturns a linear relaxation solver from a linear relaxation, an objective variables and someconfiguration parameters
Synopsisfunction get_linrelax_solver(linrelax:cplinrelax, objective:cpvar, sense:integer,
solvingType:integer, before_event:proc, must_relax:proc, after_event:proc) :cplinrelaxsolver
function get_linrelax_solver(linrelax:cplinrelax, objective:cpfloatvar, sense:integer,
solvingType:integer, before_event:proc, must_relax:proc, after_event:proc) :cplinrelaxsolver
function get_linrelax_solver(linrelax:cplinrelax, objective:cpvar, sense:integer,
solvingType:integer, configuration:integer) : cplinrelaxsolver
function get_linrelax_solver(linrelax:cplinrelax, objective:cpfloatvar, sense:integer,
solvingType:integer, configuration:integer) : cplinrelaxsolver
function get_linrelax_solver(linrelax:cplinrelax, objective:cpvar, sense:integer,
solvingType:integer, cpvarsToBeInstantiated:set of cpvar,
floatvarsToBeInstantiated:set of cpfloatvar) : cplinrelaxsolver
function get_linrelax_solver(linrelax:cplinrelax, objective:cpfloatvar, sense:integer,
solvingType:integer, cpvarsToBeInstantiated:set of cpvar,
floatvarsToBeInstantiated:set of cpfloatvar) : cplinrelaxsolver
Arguments
relax
objective
sense
solvingType
before_event
must_relax
after_relax
configuration

the linear relaxation
the objective variable
KALIS_MINIMIZE for minimization or KALIS_MAXIMIZE for maximization
KALIS_SOLVE_AS_LP or KALIS_SOLVE_AS_MIP
a user callback triggered before the relaxation is solved
a user callback saying when to solve the relaxationa user callback triggered after the resolution of the relaxation
One of the three predefined configurations (KALIS_TOPNODE_RELAX_SOLVER,
KALIS_TREENODE_RELAX_SOLVER, or KALIS_BILEVEL_RELAX_SOLVER)
cpvarsToBeInstantiated the set of cpvar to be instantiated before the resolution of therelaxation for a KALIS_BILEVEL_RELAX_SOLVER
floatvarsToBeInstantiated the set of cpfloatvar to be instantiated before the resolution of therelaxation for a KALIS_BILEVEL_RELAX_SOLVER

Return value
A linear relaxation solver

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

273

Subroutines

fix_to_relaxedPurposeThis method can be called during the tree search process to instantiate all the continuous
variables to their values in the optimal solution of a relaxation.
Synopsisprocedure fix_to_relaxed(linrelaxSolver:cplinrelax)
Argument
linrelaxSolver

the linear relaxation solver

ExampleThe following example shows how to use the fix_to_relaxed method.
fix_to_relaxed(linrelaxSolver)
Related topics
get_relaxed_value

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

274

Subroutines

set_verbose_level
PurposeSet the verbose level for a specific linear relaxation solver.
Synopsisprocedure set_verbose_level(linrelaxSolver:cplinrelaxsolver,flag:boolean)
Arguments
linrelaxSolver
flag

the linear relaxation solver
value true or false to enable/disable output printing

ExampleThe following example shows how to use the set_verbose_level function.
set_verbose_level(linrelaxSolver,true)
Related topics
get_linrelax_solver

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information275

Subroutines

cp_show_relax
PurposePretty printing of the linear relaxation to the standard output.
Synopsisprocedure cp_show_relax(relax:cplinrelax)
Argument
relax

the linear relaxation to be printed

ExampleThe following example shows how to use the cp_show_relax method.
cp_show_relax(relax)
Related topics
cp_show_var cp_show_stats cp_show_prob

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

276

Subroutines

cp_add_linrelax_solver
PurposeAdd a linear relaxation solver to the linear relaxation solver list.
Synopsisprocedure cp_add_linrelax_solver(linrelaxSolver:cplinrelaxsolver)
Argument
linrelaxSolver

the linear relaxation solver to add

ExampleThe following example shows how to use the cp_add_linrelax_solver function.
cp_add_linrelax_solver(mylinrelaxsolver)
Related topics
get_linrelax_solver cp_clear_linrelax_solver cp_remove_linrelax_solver

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

277

Subroutines

cp_remove_linrelax_solver
PurposeRemove a linear relaxation solver from the linear relaxation solver list.
Synopsisprocedure cp_remove_linrelax_solver(linrelaxSolver:cplinrelaxsolver)
Argument
linrelaxSolver

the linear relaxation solver to remove

ExampleThe following example shows how to use the cp_remove_linrelax_solver function.
cp_remove_linrelax_solver(linrelaxsolver)
Related topics
get_linrelax_solver cp_clear_linrelax_solver cp_add_linrelax_solver

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

278

Subroutines

cp_clear_linrelax_solver
PurposeClear the linear relaxation solver list.
Synopsisprocedure cp_clear_linrelax_solver
ExampleThe following example shows how to use the cp_remove_linrelax_solver function.
cp_clear_linrelax_solver
Related topics
get_linrelax_solver cp_remove_linrelax_solver cp_add_linrelax_solver

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

279

Subroutines

generate_cuts
PurposeGenerate and add cuts to the relaxation passed in parameters
Synopsisprocedure generate_cuts(linrelaxsolver:cplinrelaxsolver, linrelax:cplinrelax)
Arguments
linrelaxsolver
linrelax

a linear relaxation solver
the linear relaxation to use

Related topics
get_linrelax_solver cp_get_linrelax get_linrelax

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

280

Subroutines

lp_optimize
PurposeLaunch optimization of the relaxation solver with the LP/MIP solver alone (no branching by Kalis).
Synopsisfunction lp_optimize(linrelaxsolver:cplinrelaxsolver, sense:: integer
Arguments
linrelaxsolver
sense
alg

integer, alg:

integer)a linear relaxation solver
KALIS_MINIMIZE for minimization or KALIS_MAXIMIZE for maximization
solve as LP (0) or as MIP (1)Related topics
get_linrelax_solver cp_get_linrelax get_linrelax

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

281

Subroutines

set_linrelax_solver_attribute
PurposeSets the value of the indicated control parameter of a linear relaxation solver.
Synopsisprocedure set_linrelax_solver_attribute(linrelaxSolver:cplinrelaxsolver,
param:integer, value:integer)
procedure set_linrelax_solver_attribute(linrelaxSolver:cplinrelaxsolver,
param:integer, value:integer)
Arguments
linrelaxSolver
param

value

a linear relaxation solver
identifier of a solver parameter (KALIS_RELAX_PRESOLVE,
KALIS_RELAX_RCOSTS_PROPAG, KALIS_RELAX_RELOAD_BASIS,KALIS_RELAX_GLOBAL, KALIS_RELAX_ALGORITHM)
the value to be set (0 or 1 in most cases, values for KALIS_RELAX_ALGORITHM:
KALIS_PRIMAL_SIMPLEX, KALIS_DUAL_SIMPLEX, KALIS_BARRIER,
KALIS_NETWORK_SIMPLEX)

ExampleThe following example shows how to set the solution algorithm for a linear relaxation solver.
set_linrelax_solver_attribute(mysolver, KALIS_RELAX_ALGORITHM,
KALIS_PRIMAL_SIMPLEX)
Related topics
get_linrelax_solver cp_remove_linrelax_solver cp_add_linrelax_solver

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

282

Subroutines

get_indicator
PurposeGet a 0-1 valued cpauxvar indicating whether the variable is instantiated (1) or not (0) to thespecified value.
Synopsisfunction get_indicator(var:cpvar,i:integer) :Argumentsvar
icpauxvar

the variable
the value

Return value
An auxiliary relaxation variable
ExampleThe following example shows how to use the get_indicator function.
indvar:= get_indicator(var,i)Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

283

Subroutines

get_linrelax
PurposeGet the linear relaxation for a constraint.
Synopsisfunction get_linrelax(ctr:cpctr, orientation:integer) :Arguments
ctr
orientation

cplinrelax

the constraint to relax
0 for a ’LP oriented’ relaxation and 1 for a ’MIP oriented’ one

Return value
A linear relaxation
ExampleThe following example shows how to get a ’MIP oriented’ linear relaxation of a constraint ’ctr’.
get_linrelax(ctr,1)
Related topics
cp_get_linrelax

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

284

Subroutines

export_prob
PurposeExport the linear program from a linear relaxation solver to a text file in LP format.
Synopsisprocedure export_prob(linrelaxsolver:cplinrelaxsolver, name:string)Arguments
linrelaxsolver
namethe linear relaxation solver
a file nameExampleThe following example shows how to use the export_prob function.
export_prob(mylinrelaxsolver, "mymatout")
Related topics
cp_get_linrelax get_linrelax_solver get_linrelax

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

285

Subroutines

get_reduced_cost
PurposeGet the reduced cost for a variable from a linear relaxation solver
Synopsisfunction get_reduced_cost(linsolver:cplinrelaxsolver, var:cpvar) : realfunction get_reduced_cost(linsolver:cplinrelaxsolver, var:cpfloatvar) : real
Arguments
linsolver
var

the linear relaxation solver
a CP variable

Return value
The reduced cost value
ExampleThe following example shows how to use the get_reduced_cost function.
rc := get_reduced_cost(linsolver, x)
Related topics
get_relaxed_value get_linrelax set_integer

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

286

Subroutines

get_relaxed_value
PurposeReturns the optimal relaxed value for a variable in a relaxation.
Synopsisfunction get_relaxed_value(linsolver:cplinrelaxsolver, var:cpvar) : realfunction get_relaxed_value(linsolver:cplinrelaxsolver, var:cpfloatvar) : real
Arguments
linsolver
var

the linear relaxation solver
a CP variable

Return value
The relaxation solution value
ExampleThe following example shows how to use the get_relaxed_value function.
rv := get_relaxed_value(linsolver, x)
Related topics
get_reduced_cost get_linrelax set_integer

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

287

Subroutines

set_integer
PurposeThis method turns a variable into an integer variable in a linear relaxation.
Synopsisprocedure set_integer(relax:cplinrelax, var:cpauxvar, global:boolean)
procedure set_integer(relax:cplinrelax, var:cpvar, global:boolean)
Arguments
relax
var
globala linear relaxationa relaxation variable
true for a discrete variable, false otherwise

ExampleThe following example shows how to use the set_integer routine.
set_integer(myrelax, xaux, true)
Related topics
get_relaxed_value get_reduced_cost get_linrelax

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

288

A PPENDIX A

Contacting FICO
FICO provides clients with support and services for all our products. Refer to the following
sections for more information.

Product support
FICO offers technical support and services ranging from self-help tools to direct assistance with a
FICO technical support engineer. Support is available to all clients who have purchased a FICO
product and have an active support or maintenance contract. You can find support contact
information on the Product Support home page (www.fico.com/support).
On the Product Support home page, you can also register for credentials to log on to FICO Online
Support, our web-based support tool to access Product Support 24x7 from anywhere in the world.
Using FICO Online Support, you can enter cases online, track them through resolution, findarticles in the FICO Knowledge Base, and query known issues.
Please include ’Xpress’ in the subject line of your support queries.

Product education
FICO Product Education is the principal provider of product training for our clients and partners.
Product Education offers instructor-led classroom courses, web-based training, seminars, andtraining tools for both new user enablement and ongoing performance support. For additional
information, visit the Product Education homepage at www.fico.com/en/product-training or
email producteducation@fico.com.

Product documentation
FICO continually looks for new ways to improve and enhance the value of the products andservices we provide. If you have comments or suggestions regarding how we can improve thisdocumentation, let us know by sending your suggestions to techpubs@fico.com.

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

289

Contacting FICO

Sales and maintenanceUSA, CANADA AND ALL AMERICASEmail: XpressSalesUS@fico.com
WORLDWIDE
Email: XpressSalesUK@fico.com
Tel: +44 207 940 8718
Fax: +44 870 420 3601
Xpress Optimization, FICO
FICO HouseInternational Square
Starley Way
Birmingham B37 7GN
UK

Related services
Strategy Consulting: Included in your contract with FICO may be a specified amount ofconsulting time to assist you in using FICO Optimization Modeler to meet your business needs.
Additional consulting time can be arranged by contract.
Conferences and Seminars: FICO offers conferences and seminars on our products and services.
For announcements concerning these events, go to www.fico.com or contact your FICO accountrepresentative.

About FICO
FICO (NYSE:FICO) delivers superior predictive analytics solutions that drive smarter decisions. The
company’s groundbreaking use of mathematics to predict consumer behavior has transformed
entire industries and revolutionized the way risk is managed and products are marketed. FICO’sinnovative solutions include the FICO® Score—the standard measure of consumer credit risk in
the United States—along with industry-leading solutions for managing credit accounts,
identifying and minimizing the impact of fraud, and customizing consumer offers with pinpoint
accuracy. Most of the world’s top banks, as well as leading insurers, retailers, pharmaceuticalcompanies, and government agencies, rely on FICO solutions to accelerate growth, control risk,
boost profits, and meet regulatory and competitive demands. FICO also helps millions ofindividuals manage their personal credit health through www.myfico.com. Learn more atwww.fico.com. FICO: Make every decision countTM .

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

290

Bibliography[BR01]

C. Bessière and J.-C. Régin. Refining the Basic Constraint Propagation Algorithm. In Proceedings of IJCAI-01,
pages 309—315, Seattle, 2001.

[CL94a]Y. Caseau and F. Laburthe. Cumulative Scheduling with Task Intervals. In Joint International Conference andSymposium on Logic Programming, 1994.

[CL94b]Y. Caseau and F. Laburthe. Improved CLP Scheduling with Task Intervals. In ICLP94 Proceedings of the EleventhInternational Conference on Logic Programming, MIT Press, pages 369—383, 1994.

[LP96]

C. Le Pape. Edge-Finding Constraint Propagation Algorithms for Disjunctive and Cumulative. In Proceedings ofthe 15th Workshop of the U.K. Planning and Scheduling Special Interest Group, pages 17—22, Liverpool, 1996.

[MVH08] L. Mercier and P. Van Hentenryck. Edge Finding for Cumulative Scheduling. INFORMS Journal on Computing,
20:143—153, 2008.
[R9́4]

J.-C. Régin. A Filtering Algorithm for Constraint of Difference in CSPs. In Proceedings of AAAI94, pages
362—367, Seattle, 1994.

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

291

IndexAabs, 81
addpredecessors, 211
addsuccessors, 213
all_different, 83
and, 69
arity, 1
assign_and_forbid, 172
assign_var, 168
automatic relaxation, 21
Bbenders decomposition, 24
branchingrelaxation, 24
branching scheme, 9
bs_group, 193
Cconstraint graph, 1
Constraint Programming, 1
constraint propagation, 2constraint satisfaction problem, 1
consumes, 233
contains, 128
CP, see Constraint Programming
cp_add_linrelax_solver, 277
cp_clear_linrelax_solver, 279
cp_close_schedule, 268
cp_find_next_sol, 141
cp_get_default_schedule_strategy, 258
cp_get_linrelax, 272
cp_infeas_analysis, 154
cp_local_optimize, 158
cp_maximise, 143
cp_maximize, 144
cp_minimise, 145
cp_minimize, 146
cp_post, 139
cp_propagate, 140
cp_remove_linrelax_solver, 278
cp_reset_params, 160
cp_reset_search, 142
cp_restore_state, 156
cp_save_state, 155
cp_schedule, 231
cp_set_branch_callback, 203
cp_set_branching, 189
cp_set_node_callback, 200
cp_set_schedule_strategy, 257
cp_set_solution_callback, 197
cp_shave, 153

cp_show_best_sol, 150
cp_show_prob, 148
cp_show_relax, 276
cp_show_schedule, 215
cp_show_sol, 149
cp_show_stats, 192
cp_show_var, 137
cpctr, 7cpfloatvar, 5
cplinctr, 67
cpnlinctr, 75
cpresource, 14
cptask, 14
cpvar, 5create, 5, 17
CSP, see constraint satisfaction problem
cumulative, 101
cycle, 85Ddisjunction selection heuristic, 12
disjunctive, 103
distance, 79
distribute, 99
domain, 1
E
Earliest Completion Time, 15
Earliest Start Time, 15
ECT, see Earliest Completion Timeelement, 94
equiv, 71
EST, see Earliest Start Timeexp, 78
export_prob, 285
F
fix_to_relaxed, 274
G
generate_cuts, 280
generic_binary_constraint, 96
generic_nary_constraint, 98
get_indicator, 283
get_linrelax, 284
get_linrelax_solver, 273
get_reduced_cost, 286
get_relaxed_value, 287
getactivebranch, 115
getarity, 109
getassignment, 262
getcapacity, 252

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

292

Indexgetconsumption, 219
getdegree, 123
getduration, 218
getelt, 165
getend, 217
getlb, 117
getmakespan, 232
getmiddle, 119getname, 151
getnext, 126
getprev, 127
getpriority, 110
getproduction, 223
getprovision, 225
getrand, 125
getrequirement, 221
getsetuptime, 255
getsize, 120, 166
getsol, 147
getstart, 216
gettag, 112, 195
gettarget, 124
getub, 118
getval, 121, 163
group_serializer, 194H
has_assignment, 264
hybrid model, 25
Iimplies, 73
indicator variable, 22
is_consuming, 227
is_equal, 129
is_fixed, 122, 208, 256
is_idletime, 267
is_producing, 229
is_providing, 230
is_requiring, 228
is_same, 130K
KALIS_ALL_CONSTRAINTS, 50
KALIS_AUTO_PROPAGATE, 57
KALIS_AUTO_RELAX, 64
KALIS_BACKTRACKS, 59
KALIS_BARRIER, 54
KALIS_BILEVEL_RELAX_SOLVER, 49
KALIS_CHECK_SOLUTION, 62
KALIS_COMPUTATION_TIME, 59
KALIS_COPYRIGHT, 40
KALIS_DEFAULT_CONTINUOUS_LB, 62
KALIS_DEFAULT_CONTINUOUS_UB, 62
KALIS_DEFAULT_LB, 57
KALIS_DEFAULT_PRECISION_RELATIVITY, 63
KALIS_DEFAULT_PRECISION_VALUE, 63
KALIS_DEFAULT_SCHEDULE_HORIZ_MAX, 63
KALIS_DEFAULT_SCHEDULE_HORIZ_MIN, 63
KALIS_DEFAULT_UB, 57

KALIS_DEPTH, 58
KALIS_DICHOTOMIC_OBJ_SEARCH, 64
KALIS_DISCRETE_RESOURCE, 40
KALIS_DISJ_INPUT_ORDER, 44
KALIS_DISJ_PRIORITY_ORDER, 44
KALIS_DISJUNCTIONS, 45
KALIS_DISTANCE_CONSTRAINTS, 50
KALIS_DUAL_SIMPLEX, 54
KALIS_EDGE_FINDING, 45
KALIS_FORWARD_CHECKING, 31
KALIS_GEN_ARC_CONSISTENCY, 32
KALIS_INITIAL_SOLUTION, 46
KALIS_INPUT_ORDER, 35
KALIS_LARGEST_ECT, 42
KALIS_LARGEST_EST, 42
KALIS_LARGEST_LCT, 42
KALIS_LARGEST_LST, 43
KALIS_LARGEST_MAX, 36
KALIS_LARGEST_MIN, 35
KALIS_LARGEST_REDUCED_COST, 270
KALIS_LINEAR_CONSTRAINTS, 49
KALIS_LOGICAL_CONSTRAINTS, 50
KALIS_MAX_BACKTRACKS, 60
KALIS_MAX_COMPUTATION_TIME, 61
KALIS_MAX_DEGREE, 35
KALIS_MAX_DEPTH, 60
KALIS_MAX_NODES, 59
KALIS_MAX_NODES_BETWEEN_SOLUTIONS, 61
KALIS_MAX_SOLUTIONS, 60
KALIS_MAX_TO_MIN, 39
KALIS_MAXIMIZE, 51
KALIS_MAXREGRET_LB, 36
KALIS_MAXREGRET_UB, 36
KALIS_MIDDLE_VALUE, 39
KALIS_MIN_TO_MAX, 39
KALIS_MINIMIZE, 51
KALIS_NARY_OBJ_SEARCH, 65
KALIS_NEAREST_RELAXED_VALUE, 271
KALIS_NEAREST_VALUE, 39
KALIS_NETWORK_SIMPLEX, 55
KALIS_NODES, 58
KALIS_NON_LINEAR_CONSTRAINTS, 49
KALIS_OPT_ABS_TOLERANCE, 61
KALIS_OPT_REL_TOLERANCE, 61
KALIS_OPTIMAL_SOLUTION, 46
KALIS_OPTIMIZE_WITH_RESTART, 58
KALIS_PRIMAL_SIMPLEX, 54
KALIS_RANDOM_VALUE, 40
KALIS_RANDOM_VARIABLE, 37
KALIS_RELAX_ALGORITHM, 53
KALIS_RELAX_GLOBAL, 52
KALIS_RELAX_MIP_ABS_STOP, 53
KALIS_RELAX_MIP_REL_STOP, 53
KALIS_RELAX_OPT_TOL, 53
KALIS_RELAX_PRESOLVE, 52
KALIS_RELAX_RCOSTS_PROPAG, 52
KALIS_RELAX_RELOAD_BASIS, 52
KALIS_RESET_OPT_PARAMS, 48
KALIS_RESET_PARAMS_ALL, 46
KALIS_RESET_SEARCH_PARAMS, 48

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

293

IndexKALIS_RESET_VAR_BOUNDS, 47
KALIS_RESET_VAR_PRECISION, 47
KALIS_SCHEDULE_ENABLE_SHAVING, 65
KALIS_SDOMDEG_RATIO, 37
KALIS_SEARCH_LIMIT, 58
KALIS_SLIM_BY_BACKTRACKS, 33
KALIS_SLIM_BY_DEPTH, 33
KALIS_SLIM_BY_NODES, 32
KALIS_SLIM_BY_SOLUTIONS, 33
KALIS_SLIM_BY_TIME, 33
KALIS_SLIM_UNREACHED, 32
KALIS_SMALLEST_DOMAIN, 37
KALIS_SMALLEST_ECT, 41
KALIS_SMALLEST_EST, 41
KALIS_SMALLEST_LCT, 41
KALIS_SMALLEST_LST, 42
KALIS_SMALLEST_MAX, 38
KALIS_SMALLEST_MIN, 38
KALIS_SOLVE_AS_LP, 51
KALIS_SOLVE_AS_MIP, 51
KALIS_TASK_INPUT_ORDER, 43
KALIS_TASK_INTERVALS, 45
KALIS_TASK_RANDOM_ORDER, 43
KALIS_THREADS, 65
KALIS_TIMETABLING, 44
KALIS_TLIM_ABS_OPT, 34
KALIS_TLIM_REL_OPT, 34
KALIS_TLIM_UNREACHED, 34
KALIS_TOLERANCE_LIMIT, 59
KALIS_TOPNODE_RELAX_SOLVER, 48
KALIS_TREENODE_RELAX_SOLVER, 49
KALIS_UNARY_RESOURCE, 40
KALIS_USE_3B_CONSISTENCY, 64
KALIS_VERBOSE_LEVEL, 64
KALIS_WIDEST_DOMAIN, 38
L
Latest Completion Time, 15Latest Start Time, 15
LCT, see Latest Completion Timelinear relaxation, 22
branching, 24
ln, 77
lp_optimize, 281
LST, see Latest Start TimeM
Mathematical Programming, 21
maximum_minimum, 90
meta branching scheme, 194

produces, 239
provides, 242
Rrelaxation variable, 22
requires, 236
resusage, 259
S
search techniques, 2
set_integer, 288
set_linrelax_solver_attribute, 282
set_resource_attributes, 245
set_reversible_attributes, 161
set_sol_as_target, 159
set_task_attributes, 209
set_verbose_level, 275
setcapacity, 246
setdomain, 132
setduration, 210
setelt, 164
setfirstbranch, 114
setidletimes, 266
setlb, 133
setmaxavailability, 248
setminusage, 250
setname, 152
setprecision, 136
setpredecessors, 212
setpriority, 111
setsetuptime, 254
setsuccessors, 214
settag, 113
settarget, 131settle_disjunction, 176
setub, 134
setval, 135, 162
solution, 2
split_domain, 181
Ttask_serialize, 185
tree search, 2Vvalue selection heuristic, 12
variable selection heuristic, 11Ooccurrence, 92
optimization, 12
or, 70P
path_order, 157
probe_assign_var, 178probe_settle_disjunction, 179
producer_consumer, 105

Fair Isaac Corporation and Artelys SA Confidential and Proprietary Information

294