92
Using Hard and Soft Rules to Define and Solve Optimization Problems Barry O’Sullivan 1 Jacob Feldman 1,2 1 Cork Constraint Computation Centre Department of Computer Science, University College Cork, Ireland {b.osullivan|j.feldman}@4c.ucc.ie 2 OpenRules, Inc. New Jersey, USA [email protected] International Business Rules Forum November 2009, Las Vegas, USA O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 1 / 56

Using Hard and Soft Rules to Define and Solve Optimization

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Using Hard and Soft Rulesto Define and Solve Optimization Problems

Barry O’Sullivan1 Jacob Feldman1,2

1Cork Constraint Computation CentreDepartment of Computer Science, University College Cork, Ireland

{b.osullivan|j.feldman}@4c.ucc.ie

2OpenRules, Inc.New Jersey, USA

[email protected]

International Business Rules ForumNovember 2009, Las Vegas, USA

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 1 / 56

Using Hard and Soft Constraintsto Define and Solve Optimization Problems

Barry O’Sullivan1 Jacob Feldman1,2

1Cork Constraint Computation CentreDepartment of Computer Science, University College Cork, Ireland

{b.osullivan|j.feldman}@4c.ucc.ie

2OpenRules, Inc.New Jersey, USA

[email protected]

International Business Rules ForumNovember 2009, Las Vegas, USA

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 2 / 56

Acknowledgements

Financial SupportSupported by Science Foundation Ireland Grant 05/IN/I886.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 3 / 56

Outline

1 Introduction to Constraint Programming

2 Quantitative Approaches

3 Qualitative Approaches

4 Wrap-up

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 4 / 56

Outline

1 Introduction to Constraint ProgrammingThe Constraint Satisfaction ProblemOver-constrained CSPsOvercoming Over-Constrainedness

2 Quantitative Approaches

3 Qualitative Approaches

4 Wrap-up

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 5 / 56

What is a Constraint Satisfaction Problem?

Examplevariables and domains x1 ∈ {1, 2}

x2 ∈ {0, 1, 2, 3}x3 ∈ {2, 3}

constraints x1 > x2x1 + x2 = x3alldifferent(x1, x2, x3)

SolutionBy backtrack search and constraint propagation: x1 = 2, x2 = 1, x3 = 3

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 6 / 56

What is a Constraint Satisfaction Problem?

Examplevariables and domains x1 ∈ {1, 2}

x2 ∈ {0, 1, 2, 3}x3 ∈ {2, 3}

constraints x1 > x2x1 + x2 = x3alldifferent(x1, x2, x3)

SolutionBy backtrack search and constraint propagation: x1 = 2, x2 = 1, x3 = 3

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 6 / 56

What happens when there are no solutions?

In practice, problems often have no solutionsvariables and domains x1 ∈ {1, 2}

x2 ∈ {2, 3}x3 ∈ {2, 3}

constraints x1 > x2x1 + x2 = x3

SolutionThere is no solution. Which is hardly useful in practice.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 7 / 56

What happens when there are no solutions?

In practice, problems often have no solutionsvariables and domains x1 ∈ {1, 2}

x2 ∈ {2, 3}x3 ∈ {2, 3}

constraints x1 > x2x1 + x2 = x3

SolutionThere is no solution. Which is hardly useful in practice.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 7 / 56

What happens when there are no solutions?

In practice, problems often have no solutionsvariables and domains x1 ∈ {1, 2}

x2 ∈ {2, 3}x3 ∈ {2, 3}

constraints x1 > x2x1 + x2 = x3

SolutionThere is no solution. Which is hardly useful in practice.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 7 / 56

Some non-solutions might be regarded as reasonable

x1 x2 x3 comment1 2 2 all constraints violated1 2 3 first constraint violated only (minimum violation)1 3 2 all constraints violated1 3 3 all constraints violated2 2 2 all constraints violated2 2 3 all constraints violated2 3 2 all constraints violated2 3 3 all constraints violated

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 8 / 56

Back to the real-world....

This trivial example can be transferred to a real-world problemA rules-based loan origination system rejects a student request for$30K loan instead of relaxing its hard rules and offering a $29.3K loanto the same student.

From Rules to ConstraintsWhile BR methodologies do not offer a practical solution, we may lookat the Constraint Programming (CP) that has an extensive experiencein dealing with real-life over-constrained problems

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 9 / 56

Soft Constraints as Hard Optimisation Constraints [10]

Cost-based approach [8]Introduce a cost variable for each soft constraintThis variable represents some violation measure of the constraintOptimize aggregation of all cost variables (e.g., their sum, or max)

In this way:Soft global constraints become hard optimization constraintsThe cost variables (z1 and z2) can be used in (meta-)constraints,e.g. (z1 > 0) =⇒ (z2 = 0)Example: if a nurse worked extra hours in the evening she cannotwork next morningWe can apply classical constraint programming solvers

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 10 / 56

Example of a measured constraint violation [10]

Examplex ∈ [9000, 10000]y ∈ [0, 20000]x ≤ y

Let’s make the constraint x ≤ y soft by introducing a ‘cost’ variablez ∈ [0, 5] that represents the amount of violation, as the gapbetween x and y.Suppose that we impose z ∈ [0, 5].By looking at the bounds of x and y, we can immediately deducethat y ∈ [8995, 20000].

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 11 / 56

BR and CP Integration

What are meta-constraints?CP defines meta-constraints that convert soft constraints to hardoptimization constraints

How are they defined?These meta-constraints are usually defined by subject-matter experts(not programmers!) and thus can be expressed in business rules.

IntegrationSo, it is a natural to integrate BR and CP in a such way when:

BR define a problem (or sub-problems)CP solves the problem

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 12 / 56

BR and CP Integration

What are meta-constraints?CP defines meta-constraints that convert soft constraints to hardoptimization constraints

How are they defined?These meta-constraints are usually defined by subject-matter experts(not programmers!) and thus can be expressed in business rules.

IntegrationSo, it is a natural to integrate BR and CP in a such way when:

BR define a problem (or sub-problems)CP solves the problem

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 12 / 56

BR and CP Integration

What are meta-constraints?CP defines meta-constraints that convert soft constraints to hardoptimization constraints

How are they defined?These meta-constraints are usually defined by subject-matter experts(not programmers!) and thus can be expressed in business rules.

IntegrationSo, it is a natural to integrate BR and CP in a such way when:

BR define a problem (or sub-problems)CP solves the problem

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 12 / 56

BR and CP Integration!"#$#%&#'()*+,-./(#012*3-#

!"#4*5(*#-#6789(*88#:,/6;*3#-(4#+*(*,-)*8#-#,*;-)*4#%0&#

%&#8/;<*,#<-;94-)*8#9=#)2*#:,/6;*3#98#/<*,>1/(8),-9(*4##########

-(4#:/9()8#)/#9(1/(898)*(19*8?1/(@91)8#

!"#,*=/,37;-)*8?8/A*(8#)2*#:,/6;*3#6B#4*5(9(+####

C1/(8),-9()#8/A*(9(+#,7;*8D#-(4#+*(*,-)*8#-#(*E##%0&#

%&#8/;<*,#F-;/(+#E9)2#G&?H'&#8/;<*,8I#8/;<*8#-#,*=/,37;-)*4#

/:.39J-./(#:,/6;*3#

"*)7,(8#)2*#,*87;)8#)/#)2*#,7;*#

*(+9(*#=/,#=7,)2*,#-(-;B898#

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 13 / 56

Example “Balancing Financial Portfolio”

ExampleThe “target” portfolio is defined as a currently active set of rules thatdirects a shape of every particular portfolio

Rules ViolationsFluctuation of stock prices makes stock allocation rules being almostalways “a little bit” violated

Objectivekeep portfolio as close as possible to the “target” portfolio

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 14 / 56

Example: Portfolio Management Rules

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 15 / 56

Example: Softening the Rules

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 16 / 56

Typical Scheduling Constraints

ExampleGiven set of activities, each with processing time, resourceconsumption, earliest start time and latest end time, assign anexecution time to each activity so that a given resource does notexceed its capacity

!"#$%&'()%*+,-'$./(01.234&$.32(

•! 5$6+.(2+3(17(&%86$8+29(+&%*(:$3*(#41%+22$./(

8;+9(4+21-4%+(%1.2-;#81.9(+&4'$+23(23&43(

8;+(&.,('&3+23(+.,(8;+9(&22$/.(&.(+<+%-81.(

8;+(31(+&%*(&%86$3"(21(3*&3(&(/$6+.(4+21-4%+(

,1+2(.13(+<%++,($32(%&#&%$3"(

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 17 / 56

Softening Scheduling Constraints

Violation measuresNumber of late activitiesAcceptable overcapacity of resourceUse of overtimeOveruse of skillsWorker preferences

Real-life soft scheduling constraints (LILCO examples)Do not start new job less than x minutes before the end of the shiftUnavailability tolerance (the same person “CAN” be in twodifferent places at the same time)

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 18 / 56

Technical Approaches from Constraint Programming

Quantitative strategiesWe can define a constraint violation cost and optimize an aggregatedfunction defined on all cost variables.

Qualitative strategiesWe can try to find explanations of conflicts or find a preferredrelaxation.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 19 / 56

Outline

1 Introduction to Constraint Programming

2 Quantitative ApproachesPartial Constraint SatisfactionHierarchical Constraint SatisfactionGeneralised Soft Constraints

3 Qualitative Approaches

4 Wrap-up

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 20 / 56

Partial Constraint Satisfaction [3]

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 21 / 56

Principles of Relaxation

We can relax a problem by:Enlarging the domain of avariableEnlarging the set of valuesallowed by a constraintRemove a constraintRemove a variable

Adding values is enough:Add values to a domainAdd values to a constraintAdd all possible values to aconstraintAdd all possible values to adomain

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 22 / 56

Partial Constraint Satisfaction as Optimisation

Partial-order amongst problemsThe partial-order defined over the set of problems is defined in termsof the set of solutions to those problems. Specifically,P1 ≤ P2 ≡ sols(P2) ⊆ sols(P1).

Minimise an Objective Function using Branch-and-BoundSolution Subset – the number of solutions added.Augmentation – the number of constraint augmentations.

Max-CSP – the number of constraints satisfied.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 23 / 56

Partial Constraint Satisfaction [3]

Buy a red shirt and augment the constraints so that it compatiblewith sneakers and denims.Solution: 〈red, sneakers, denims〉Metrics:

I Solution subset distance = 1I Augmentation distance = 3I Max-CSP distance = 1

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 24 / 56

Hierarchical CSP [2]

ApproachWe associate a priority with each constraint, and comparesolutions using a comparator based on the constraints that aresatisfied.Find solutions that satisfy the most important constraints.

ExampleHard constraints: Constraint between shirt and slacks.Strong constraints: Constraint between shoes and slacks.Weak constraints: Constraint between shirt and shoes.

Solutions〈green, cordovans, gray〉, 〈white, sneakers, denims〉.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 25 / 56

Definition of the Hierarchical CSP

A constraint hierarchy is a (finite) multiset of constraints labelledwith a strength/priority.Given a constraint hierarchy H =def {H0,H1, . . . ,Hk}, the set ofconstraints in H0 are the hard constraints, and for each other levelHi, its constraints are more important than those at any level j > i.A solution to a constraint hierarchy H will consist of valuations forvariables in H, that satisfy best constraints in H respecting thehierarchy.Solutions are compared using a comparator

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 26 / 56

An Example Comparator

Locally BetterA valuation θ is locally better that another valuation σ if, for each of theconstraints through some level k − 1, the error after applying θ is equalto that after applying σ, and at level k the error is strictly less for atleast one constraint and less than or equal for all the rest.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 27 / 56

A HCSP Example

Example

Level ConstraintsH0 required cel× 1.8 = fah− 32.0H1 strong fah = 212H2 weak cel = 0

Solving the problemS(H0) = {. . . , 〈0, 32〉, 〈10, 50〉, 〈100, 212〉, . . .}

S = {〈100, 212〉}

The pair 〈100, 212〉 is locally-better wrt the other pairs in S(H0).

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 28 / 56

Generalised Soft Constraints [1]

We can define soft constraint problems as 〈A,+,×,0,1〉 where:A is the set of all possible ‘scores’ of our constraints: 0 and 1 arethe worst and best ‘scores’, respectively;+ compares solutions, and × combines constraintsExamples:

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 29 / 56

Outline

1 Introduction to Constraint Programming

2 Quantitative Approaches

3 Qualitative ApproachesIntuititionFinding Relaxations and ConflictsFinding Preferred Relaxations and Conflicts

4 Wrap-up

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 30 / 56

An industrial example

ExampleIn November 2003, a configuration client had the problem thatconstraint propagation in their configurator was failing for a systemdescribed by 300, 000 constraints.

How do we debug this?There are 2300,000 possible causes, but in our example, only 8 of theconstraints were sufficient to produce the failure, but there are still> 1039 combinations of possibilities.

After this talk you will know how to . . .

Identify these 8 constraints after only 270 consistency checks!

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 31 / 56

An industrial example

ExampleIn November 2003, a configuration client had the problem thatconstraint propagation in their configurator was failing for a systemdescribed by 300, 000 constraints.

How do we debug this?There are 2300,000 possible causes, but in our example, only 8 of theconstraints were sufficient to produce the failure, but there are still> 1039 combinations of possibilities.

After this talk you will know how to . . .

Identify these 8 constraints after only 270 consistency checks!

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 31 / 56

An industrial example

ExampleIn November 2003, a configuration client had the problem thatconstraint propagation in their configurator was failing for a systemdescribed by 300, 000 constraints.

How do we debug this?There are 2300,000 possible causes, but in our example, only 8 of theconstraints were sufficient to produce the failure, but there are still> 1039 combinations of possibilities.

After this talk you will know how to . . .

Identify these 8 constraints after only 270 consistency checks!

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 31 / 56

Where can I apply what I learn?

1 Product Configuration2 Test Generation3 Recommender Systems4 Case-based Reasoning Systems5 Knowledge-based Systems6 Software Product Lines7 Debugging8 Can you think of any others?

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 32 / 56

Classic Setting

Two Categories of Constraintsbackground constraints expressing the connections between thecomponents of the “product”, that cannot be removeduser constraints interactively stated by the user when deciding onoptions (= a query)

ConsistencyA set of constraints is consistent if it admits a solution.The background constraints are assumed to be consistent.The “solubility” of a set of constraints refers to the number ofsolutions it is consistent with.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 33 / 56

Classic Setting

Two Categories of Constraintsbackground constraints expressing the connections between thecomponents of the “product”, that cannot be removeduser constraints interactively stated by the user when deciding onoptions (= a query)

ConsistencyA set of constraints is consistent if it admits a solution.The background constraints are assumed to be consistent.The “solubility” of a set of constraints refers to the number ofsolutions it is consistent with.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 33 / 56

Terminology

ExplanationsConflict: an inconsistent subset of U: show one cause ofinconsistency.Relaxation: a consistent subset of U: show one possible way ofrecovering from it

Optimality – sort ofA relaxation is maximal when no constraint can added whileremaining consistent.A conflict is minimal when no constraint can be removed whileremaining inconsistent.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 34 / 56

Terminology

ExplanationsConflict: an inconsistent subset of U: show one cause ofinconsistency.Relaxation: a consistent subset of U: show one possible way ofrecovering from it

Optimality – sort ofA relaxation is maximal when no constraint can added whileremaining consistent.A conflict is minimal when no constraint can be removed whileremaining inconsistent.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 34 / 56

Example explanation tasks

Configuration as a CSPA “product” is fullyspecified by someconstraintsSeveral options areavailable to the userThe user expresses hispreferences as constraints

ExplanationsWhen preferences conflict:

Conflict show a set ofconflictingpreferences

Relaxation show a set offeasiblepreferences

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 35 / 56

Example explanation tasks

Configuration as a CSPA “product” is fullyspecified by someconstraintsSeveral options areavailable to the userThe user expresses hispreferences as constraints

ExplanationsWhen preferences conflict:

Conflict show a set ofconflictingpreferences

Relaxation show a set offeasiblepreferences

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 35 / 56

Conflicts, Arguments, and Counterarguments (I)

AssumptionThe propagation capability of a constraints solver can be described byoperator Π mapping a set of given constraints to a set of deducedconstraints. (e.g. arc consistency deduces constraints of form x 6= v)

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 36 / 56

Conflicts, Arguments, and Counter-arguments (II)

ConflictFor given set of constraints X + background B:

Π-conflict: subset X of X such that Π(B ∪ X) contains aninconsistency.minimal Π-conflict: no proper subset is a conflictpreferred Π-conflict: culprits are chosen according to a totalorderglobal conflict: Π is complete (i.e. achieves global consistency)

Arguments and Counter-Arguments(counter-)argument for φ: add ¬φ (φ) to B + find conflict

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 37 / 56

Conflicts, Arguments, and Counter-arguments (II)

ConflictFor given set of constraints X + background B:

Π-conflict: subset X of X such that Π(B ∪ X) contains aninconsistency.minimal Π-conflict: no proper subset is a conflictpreferred Π-conflict: culprits are chosen according to a totalorderglobal conflict: Π is complete (i.e. achieves global consistency)

Arguments and Counter-Arguments(counter-)argument for φ: add ¬φ (φ) to B + find conflict

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 37 / 56

Which Explanations?

ExampleA customer wants station-wagon with options:

1 requirement r1: roof racks ($500)2 requirement r2: CD-player ($500)3 requirement r3: extra seat ($800)4 requirement r4: metal color ($500)5 requirement r5: luxury version ($2600)

Total budget for options is $3000

User requirements cannot be satisfiedWhich requirements are in conflict?

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 38 / 56

Which Explanations?

ExampleA customer wants station-wagon with options:

1 requirement r1: roof racks ($500)2 requirement r2: CD-player ($500)3 requirement r3: extra seat ($800)4 requirement r4: metal color ($500)5 requirement r5: luxury version ($2600)

Total budget for options is $3000

User requirements cannot be satisfiedWhich requirements are in conflict?

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 38 / 56

An Arbitary Explanation

Maintain explanations during propagation

r1 roof racks c ≥ 500 {r1}r2 CD-player c ≥ 1000 {r1, r2}r3 extra seat c ≥ 1800 {r1, r2, r3}r4 metal color c ≥ 2300 {r1, r2, r3, r4}r5 luxury version c ≥ 4900 {r1, r2, r3, r4, r5}b total budget c ≤ 3000 {b}

failure {r1, r2, r3, r4, r5, b}

explanation: {r1, r2, r3, r4, r5, b}

This explanation is not minimal (irreducible)!The user may retract constraints unnecessarily.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 39 / 56

An Arbitary Explanation

Maintain explanations during propagation

r1 roof racks c ≥ 500 {r1}r2 CD-player c ≥ 1000 {r1, r2}r3 extra seat c ≥ 1800 {r1, r2, r3}r4 metal color c ≥ 2300 {r1, r2, r3, r4}r5 luxury version c ≥ 4900 {r1, r2, r3, r4, r5}b total budget c ≤ 3000 {b}

failure {r1, r2, r3, r4, r5, b}

explanation: {r1, r2, r3, r4, r5, b}

This explanation is not minimal (irreducible)!The user may retract constraints unnecessarily.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 39 / 56

An Arbitary Explanation

Maintain explanations during propagation

r1 roof racks c ≥ 500 {r1}r2 CD-player c ≥ 1000 {r1, r2}r3 extra seat c ≥ 1800 {r1, r2, r3}r4 metal color c ≥ 2300 {r1, r2, r3, r4}r5 luxury version c ≥ 4900 {r1, r2, r3, r4, r5}b total budget c ≤ 3000 {b}

failure {r1, r2, r3, r4, r5, b}

explanation: {r1, r2, r3, r4, r5, b}

This explanation is not minimal (irreducible)!The user may retract constraints unnecessarily.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 39 / 56

Minimal Explanation

Some other propagation order

r4 metal color c ≥ 500 {r4}r5 luxury version c ≥ 3100 {r4, r5}b total budget c ≤ 3000 {b}

failure {r4, r5, b}

explanation: {r4, r5, b}

Minimal - Good!The explanation is minimal, since any proper subset is consistent.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 40 / 56

Minimal Explanation

Some other propagation order

r4 metal color c ≥ 500 {r4}r5 luxury version c ≥ 3100 {r4, r5}b total budget c ≤ 3000 {b}

failure {r4, r5, b}

explanation: {r4, r5, b}

Minimal - Good!The explanation is minimal, since any proper subset is consistent.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 40 / 56

Minimal Explanation

Some other propagation order

r4 metal color c ≥ 500 {r4}r5 luxury version c ≥ 3100 {r4, r5}b total budget c ≤ 3000 {b}

failure {r4, r5, b}

explanation: {r4, r5, b}

Minimal - Good!The explanation is minimal, since any proper subset is consistent.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 40 / 56

Finding a Minimal Conflict

ExampleStep Activated constraints Result Partial conflict1. ρ1 no fail {}2. ρ1 ρ2 no fail {}3. ρ1 ρ2 ρ3 no fail {}4. ρ1 ρ2 ρ3 ρ4 no fail {}5. ρ1 ρ2 ρ3 ρ4 ρ5 fail {ρ5}6. ρ5 no fail {ρ5}7. ρ5 ρ1 fail {ρ1, ρ5}

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 41 / 56

rePlayXplain: Detect culprit and replay

Modified exampleRequested options 1,2,3,4,7 cost 100$ each; requested options 5,6,8cost 800$ each; budget is 2200.

Add available constraints to CP Solver one after the other;when failure (F) occurs new culprit is detected;backtrack to initial state + add culprit there

QuickXplain: Detect culprit and divide

Divide conflict detection problem into 2 subproblems when culprit isdetected:

1 keep all constraint of first subproblem when solving secondsubproblem;

2 add culprits of second subproblem when solving first subproblem.

Unnecessary Retractions

Use explanation for finding a solution1 user submits requirements r1, . . . , r5 + b2 response: failure due to {r4, r5, b}3 user prefers luxury (r5) to metal color (r4), so removes r4

4 response: failure due to {r3, r5, b}5 user prefers extra seats (r3) to luxury (r5), so removes r5

6 response: success

The retraction of r4 is no longer justified.Can we avoid unnecessary retractions?

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 44 / 56

Unnecessary Retractions

Use explanation for finding a solution1 user submits requirements r1, . . . , r5 + b2 response: failure due to {r4, r5, b}3 user prefers luxury (r5) to metal color (r4), so removes r4

4 response: failure due to {r3, r5, b}5 user prefers extra seats (r3) to luxury (r5), so removes r5

6 response: success

The retraction of r4 is no longer justified.Can we avoid unnecessary retractions?

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 44 / 56

Unnecessary Retractions

Use explanation for finding a solution1 user submits requirements r1, . . . , r5 + b2 response: failure due to {r4, r5, b}3 user prefers luxury (r5) to metal color (r4), so removes r4

4 response: failure due to {r3, r5, b}5 user prefers extra seats (r3) to luxury (r5), so removes r5

6 response: success

The retraction of r4 is no longer justified.Can we avoid unnecessary retractions?

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 44 / 56

Unnecessary Retractions

Use explanation for finding a solution1 user submits requirements r1, . . . , r5 + b2 response: failure due to {r4, r5, b}3 user prefers luxury (r5) to metal color (r4), so removes r4

4 response: failure due to {r3, r5, b}5 user prefers extra seats (r3) to luxury (r5), so removes r5

6 response: success

The retraction of r4 is no longer justified.Can we avoid unnecessary retractions?

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 44 / 56

Unnecessary Retractions

Use explanation for finding a solution1 user submits requirements r1, . . . , r5 + b2 response: failure due to {r4, r5, b}3 user prefers luxury (r5) to metal color (r4), so removes r4

4 response: failure due to {r3, r5, b}5 user prefers extra seats (r3) to luxury (r5), so removes r5

6 response: success

The retraction of r4 is no longer justified.Can we avoid unnecessary retractions?

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 44 / 56

Unnecessary Retractions

Use explanation for finding a solution1 user submits requirements r1, . . . , r5 + b2 response: failure due to {r4, r5, b}3 user prefers luxury (r5) to metal color (r4), so removes r4

4 response: failure due to {r3, r5, b}5 user prefers extra seats (r3) to luxury (r5), so removes r5

6 response: success

The retraction of r4 is no longer justified.Can we avoid unnecessary retractions?

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 44 / 56

Unnecessary Retractions

Use explanation for finding a solution1 user submits requirements r1, . . . , r5 + b2 response: failure due to {r4, r5, b}3 user prefers luxury (r5) to metal color (r4), so removes r4

4 response: failure due to {r3, r5, b}5 user prefers extra seats (r3) to luxury (r5), so removes r5

6 response: success

The retraction of r4 is no longer justified.Can we avoid unnecessary retractions?

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 44 / 56

Preferred Explanation

Again another propagation order

r3 metal color c ≥ 800 {r3}r5 luxury version c ≥ 3300 {r3, r5}b total budget c ≤ 3000 {b}

failure {r3, r5, b}

explanation: {r3, r5, b}

Explanation is preferredIts worst element r5 can safely be retracted

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 45 / 56

Preferred Explanation

Again another propagation order

r3 metal color c ≥ 800 {r3}r5 luxury version c ≥ 3300 {r3, r5}b total budget c ≤ 3000 {b}

failure {r3, r5, b}

explanation: {r3, r5, b}

Explanation is preferredIts worst element r5 can safely be retracted

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 45 / 56

Preferences between Constraints [5]

Intuitive statements with simple semanticspreferences between constraintsprefer(luxury version, metal color)prefer(extra seat, luxury version)

groups of constraintsI equipment contains requirements for roof racks, extra seatI look contains requirements for metal color, seat material

preferences between groupsprefer(equipment, look)

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 46 / 56

The Tasks

Overconstrained problem with preferencesbackground B

constraints C := {c1, . . . , cn}preferences P between the ci’s

such that B ∪ C is inconsistent

The taskspreferred relaxationspreferred explanations

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 47 / 56

The Tasks

Overconstrained problem with preferencesbackground B

constraints C := {c1, . . . , cn}preferences P between the ci’s

such that B ∪ C is inconsistent

The taskspreferred relaxationspreferred explanations

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 47 / 56

Intuition behind the Approach

Preferred ConflictsWe use a preference-guided algorithm that successively adds mostpreferred constraints until they fail. It then backtracks and removes theleast preferred constraints if this preserves the failure.

Preferred RelaxationsWe remove the least preferred constraints from an inconsistent setuntil it is consistent.

DualityPreferred conflicts explain why best elements cannot be added topreferred relaxations.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 48 / 56

Intuition behind the Approach

Preferred ConflictsWe use a preference-guided algorithm that successively adds mostpreferred constraints until they fail. It then backtracks and removes theleast preferred constraints if this preserves the failure.

Preferred RelaxationsWe remove the least preferred constraints from an inconsistent setuntil it is consistent.

DualityPreferred conflicts explain why best elements cannot be added topreferred relaxations.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 48 / 56

Intuition behind the Approach

Preferred ConflictsWe use a preference-guided algorithm that successively adds mostpreferred constraints until they fail. It then backtracks and removes theleast preferred constraints if this preserves the failure.

Preferred RelaxationsWe remove the least preferred constraints from an inconsistent setuntil it is consistent.

DualityPreferred conflicts explain why best elements cannot be added topreferred relaxations.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 48 / 56

Algorithm QUICKXPLAIN [4]

Recursive decomposition à la QUICKSORT

1 If B is inconsistent then: LexXplain(cπ1 , . . . , cπn)(B) = ∅2 If B is consistent and C is a singleton then:

LexXplain(cπ1 , . . . , cπn)(B) = C3 If B is consistent and C has more than one element then split at k

1 let Ck := {cπ1 , . . . , cπk}2 let E2 be LexXplain(cπk+1 , . . . , cπn)(B ∪ Ck)3 let E1 be LexXplain(cπ1 , . . . , cπk )(B ∪ E2)4 LexXplain(cπ1 , . . . , cπn)(B) = E1 ∪ E2

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 49 / 56

Where to Split?

EffectIf a subproblem does not contain an element of the conflict then it canbe solved by a single consistency check, namely B ∪ Ck or B ∪ E2

StrategyChoose subproblems of same size to exploit this effect in a best way

#Consistency ChecksBetween log2

nk + 2k and 2k · log2

nk + 2k (for conflicts of size k)

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 50 / 56

Consistency Checking

The cost of consistency checkingQUICKXPLAIN does multiple consistency checks that are NP-hard ingeneral, but

complexity is polynomial for tree-like CSPsapproximations possible: trade time and optimalitykeep witnesses for success (= solution) and try them when addingconstraintskeep witnesses for failure (= critical search decisions) and trythem when removing constraints

Compilation helps in practiceMost problems in practice give small compiled forms.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 51 / 56

Consistency Checking

The cost of consistency checkingQUICKXPLAIN does multiple consistency checks that are NP-hard ingeneral, but

complexity is polynomial for tree-like CSPsapproximations possible: trade time and optimalitykeep witnesses for success (= solution) and try them when addingconstraintskeep witnesses for failure (= critical search decisions) and trythem when removing constraints

Compilation helps in practiceMost problems in practice give small compiled forms.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 51 / 56

How to use QuickXplainBackground: effort is reduced by putting as many constraints aspossible in the initial backgroundPreference order: order of constraint uniquely characterizes theconflict foundConsistency checker: time can be traded against minimality byan incomplete consistency checker, giving “anytime” behaviour

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 52 / 56

How to use QuickXplainBackground: effort is reduced by putting as many constraints aspossible in the initial backgroundPreference order: order of constraint uniquely characterizes theconflict foundConsistency checker: time can be traded against minimality byan incomplete consistency checker, giving “anytime” behaviour

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 52 / 56

How to use QuickXplainBackground: effort is reduced by putting as many constraints aspossible in the initial backgroundPreference order: order of constraint uniquely characterizes theconflict foundConsistency checker: time can be traded against minimality byan incomplete consistency checker, giving “anytime” behaviour

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 52 / 56

Applications of QuickXplain

Configuration: B2B, B2C find conflicts between user requests.Constraint model debugging isolate failing parts of the constraintmodel.Rule verification find tests that make a rule never applicable.Benders decomposition.Diagnosis of ontologies.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 53 / 56

Applications of QuickXplain

Configuration: B2B, B2C find conflicts between user requests.Constraint model debugging isolate failing parts of the constraintmodel.Rule verification find tests that make a rule never applicable.Benders decomposition.Diagnosis of ontologies.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 53 / 56

Applications of QuickXplain

Configuration: B2B, B2C find conflicts between user requests.Constraint model debugging isolate failing parts of the constraintmodel.Rule verification find tests that make a rule never applicable.Benders decomposition.Diagnosis of ontologies.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 53 / 56

Applications of QuickXplain

Configuration: B2B, B2C find conflicts between user requests.Constraint model debugging isolate failing parts of the constraintmodel.Rule verification find tests that make a rule never applicable.Benders decomposition.Diagnosis of ontologies.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 53 / 56

Applications of QuickXplain

Configuration: B2B, B2C find conflicts between user requests.Constraint model debugging isolate failing parts of the constraintmodel.Rule verification find tests that make a rule never applicable.Benders decomposition.Diagnosis of ontologies.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 53 / 56

Outline

1 Introduction to Constraint Programming

2 Quantitative Approaches

3 Qualitative Approaches

4 Wrap-up

Barry O’Sullivan (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 54 / 56

Take-Home Messages

IntegrationClose integration between business rules and constraint programmingtechniques is straightforward and meaningful.

Reasoning about Soft ConstraintsThere is a large body of work and software tools for reasoning aboutsoft constraints in a variety of quantitative and qualitative settings.

PerspectivesWe can view the integration as a basis for optimisation, but also as abasis for explanation generation.

Barry O’Sullivan (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 55 / 56

Using Hard and Soft Rulesto Define and Solve Optimization Problems

Barry O’Sullivan1 Jacob Feldman1,2

1Cork Constraint Computation CentreDepartment of Computer Science, University College Cork, Ireland

{b.osullivan|j.feldman}@4c.ucc.ie

2OpenRules, Inc.New Jersey, USA

[email protected]

International Business Rules ForumNovember 2009, Las Vegas, USA

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 56 / 56

Stefano Bistarelli, Ugo Montanari, and Francesca Rossi.Semiring-based constraint satisfaction and optimization.J. ACM, 44(2):201–236, 1997.

Alan Borning, Bjørn N. Freeman-Benson, and Molly Wilson.Constraint hierarchies.Lisp and Symbolic Computation, 5(3):223–270, 1992.

Eugene C. Freuder and Richard J. Wallace.Partial constraint satisfaction.Artif. Intell., 58(1-3):21–70, 1992.

Ulrich Junker.Quickxplain: Preferred explanations and relaxations forover-constrained problems.In AAAI, pages 167–172, 2004.

Ulrich Junker and Daniel Mailharro.Preference programming: Advanced problem solving forconfiguration.AI EDAM, 17(1):13–29, 2003.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 56 / 56

David Lesaint, Deepak Mehta, Barry O’Sullivan, Luis Quesada,and Nic Wilson.Personalisation of telecommunications services as combinatorialoptimisation.In Dieter Fox and Carla P. Gomes, editors, AAAI, pages1693–1698. AAAI Press, 2008.

David Lesaint, Deepak Mehta, Barry O’Sullivan, Luis Quesada,and Nic Wilson.Solving a telecommunications feature subscription configurationproblem.In Stuckey [9], pages 67–81.

Thierry Petit, Jean-Charles Régin, and Christian Bessière.Meta-constraints on violations for over constrained problems.In ICTAI, pages 358–365. IEEE Computer Society, 2000.

Peter J. Stuckey, editor.Principles and Practice of Constraint Programming, 14thInternational Conference, CP 2008, Sydney, Australia, September

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 56 / 56

14-18, 2008. Proceedings, volume 5202 of Lecture Notes inComputer Science. Springer, 2008.

Willem van Hoeve.Soft global constraints, 2009.

O’Sullivan and Feldman (4C, UCC) Hard and Soft Constraints BRForum 2009, Las Vegas 56 / 56