Constraint Reasoning and Large Language Models Join Forces: Providing Contrastive Explanations for Real-World Optimisation-Based Applications
Organizations: Artificial Intelligence Research Institute, IIIA-CSIC · University of Southampton
Abstract
We focus on optimisation-based Decision Support Systems in real-world applications. In this context, we aim to provide contrastive explanations that answer users' questions about recommendations based on the solution of an optimisation problem, specifically a Mixed-Integer Program (MIP). Addressing this endeavour is crucial to ensure human oversight of the decisions implemented, as required by international guidelines on trustworthy and responsible automated decision-making systems. We propose a novel methodology that combines constraint reasoning techniques and Large Language Models (LLMs) to generate contrastive explanations for optimisation problems encoded as MIPs. Although LLMs have shown impressive capabilities in Natural Language processing, they can produce incorrect answers due to reasoning limitations. To overcome these limitations, we leverage constraint reasoning techniques to distil the information necessary to produce an explanation, which is then passed as input to an LLM as the so-called graph of reasons. Such a graph captures the semantics and the relationships among constraints of the optimisation problem. Results on real-world scheduling domains show that incorporating constraint reasoning improves explanations generated by the LLM. In particular, using the graph of reasons enables the LLM to produce natural-language explanations that include more relevant reasons while reducing errors compared to explanations generated without this structure.
Figures & tables
| Subject | Semester | Offer | Predecessors | Core |
|---|---|---|---|---|
| Programming Fundamentals (PF) | 2 (Spring) | Both | - | Yes |
| Programming Techniques (PT) | 4 (Spring) | Spring | PF | Yes |
| Object Oriented Programming (OOP) | Spring | PF | No | |
| Operating Systems Programming (OSP) | 5 (Autumn) | Autumn | PT or OOP | Yes |
| Question | Query constraints | Constraint encoding ( ) | |
|---|---|---|---|
| Q1. | Why is subject planned at semester ? | veto to plan at semester | |
| Q2. | Why is subject not planned at semester ? | enforce to plan at semester | |
| Q3. | Why is subject not planned before semester ? | enforce to plan before semester | |
| Q4. | Why is subject not planned after semester ? | enforce to plan after | |
| Q5. | Why is subject planned? | veto | |
| Q6. | Why is subject not planned? | enforce |
| Id | Type | Values |
|---|---|---|
| Query | Programming Fundamentals, Semester | |
| Completion | Programming Fundamentals | |
| Offer | Programming Techniques not offered in Autumn | |
| Offer | Object Oriented Prog. not offered in Autumn | |
| Offer | Operating System Prog. not offered in Spring | |
| Precedence | Prog. Fund. before Prog. Techniques |
| (i) Completion ( 4b ): | “ Subject cannot be planned more than once ” |
|---|---|
| (ii) Credits ( 4c ): | “ credits must be planned at semester ” |
| (iii) Offer ( 4d ): | “ Subject cannot be planned at autumn/spring semesters ” |
| (iv) Core ( 4e ): | “ Subject is compulsory ” |
| (v) Precedence ( 4f ): | “ Subject must be planned before Subject ” |
| (vi) Major ( 4g ): | “ Students must complete at least one major ” |
| (vii) Major core ( 4h ): | “ Subject is compulsory to complete major ” |
| Programming Fundamentals is not planned in semester 4 because it must be taken earlier to satisfy the prerequisite requirements of later subjects , particularly Programming Techniques and Object Oriented Programming . These subjects , in turn, need to be completed before taking Operating Systems Programming , a compulsory subject that can only be taken in the autumn . Additionally, Programming Techniques and Object-Oriented Programming cannot be scheduled in the autumn semesters, further constraining their placement. Since subjects cannot be planned more than once, Programming Fundamentals must be scheduled early enough to enable this sequence, making semester 4 too late for it. | Programming Fundamentals is scheduled in semester 2 rather than semester 4 to comply with prerequisite requirements and ensure a feasible progression through the curriculum. Since this subject must be taken before others like Programming Techniques and Object Oriented Programming , delaying it to a later semester would prevent the student from enrolling in these dependent courses on time. Additionally, university rules may restrict when certain subjects can be taken, and each subject can only be planned once, so placing Programming Fundamentals earlier allows for a coherent and complete academic path within the 6-semester limit. |
| Reasons | GoR | IIS |
|---|---|---|
| : PF cannot be planned more than once | ✓ | ✓ |
| : PT cannot be planned at autumn semesters | ✓ | ✗ |
| : OOP cannot be planned at autumn semesters | ✓ | ✗ |
| : OSP cannot be planned at spring semesters | ✓ | ✗ |
| : PF must be planned before PT | ✓ | ✓ |
| : PF must be planned before OOP | ✓ | ✓ |
| Problem | Metric | Graph Prompt | IIS Prompt | p-value |
|---|---|---|---|---|
| DPP | Completeness (%) | |||
| Number of words | ||||
| GFI | ||||
| RCPSP | Completeness (%) | |||
| Number of words | ||||
| GFI |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Id | Type | Constraint Encoding |
|---|---|---|
| Query | ||
| Completion | ||
| Offer | ||
| Offer | ||
| Offer | ||
| Precedence |
| Question | Query constraints | Constraint encoding ( ) | |
|---|---|---|---|
| Q1. | Why is activity completed at time ? | veto complete at time | |
| Q2. | Why is activity not completed at time ? | enforce complete at time | |
| Q3. | Why is activity not completed before time ? | enforce complete before time | |
| Q4. | Why is activity not completed after time ? | enforce to complete after | |
| Q5. | Why is the group of activities completed at ? | veto to complete at time | |
| Q6. | Why is the group of activities not completed at ? | enforce to complete all of them at time |
| (i) Completion : | “ Activity j must be completed ” |
| (ii) Precedence : | “ Act. h must be completed before Act. j starts ” |
| (iii) Resource : | “ Res. r is scarce at time due to Acts. ” |
| The bachelor’s degree planning problem is the problem of finding a plan of university subjects that respects some precedence and university restrictions while maximising the skills learnt. Specifically, the goal is to acquire the required level for the student’s desired job role through the course subjects. In this context, provide an explanation to answer the following question about the solution to the 6-semester bachelor’s degree planning problem. To do so, use the reasons below, which are related to the bachelor’s degree restrictions. Moreover, these reasons are connected to one another like nodes in a graph. Use the reasons and their connections to write the explanation. | ||||
| Partial Solution: | ||||
| Subject | Semester | Offer | Predecessors | Core |
| Prog. Fund. | 2 (Spring) | Both | - | Yes |
| Prog. Tech. | 4 (Spring) | Spring | PF | Yes |
| Obj. Or. Prog. | Spring | PF | No | |
| The bachelor’s degree planning problem is the problem of finding a plan of university subjects that respects some precedence and university restrictions while maximising the skills learnt. Specifically, the goal is to acquire the required level for the student’s desired job role through the course subjects. In this context, provide an explanation to answer the following question about the solution to the 6-semester bachelor’s degree planning problem. To do so, use the reasons below, which are related to the bachelor’s degree restrictions. | ||||
| Partial Solution: | ||||
| Subject | Semester | Offer | Predecessors | Core |
| Prog. Fund. | 2 (Spring) | Both | - | Yes |
| Prog. Tech. | 4 (Spring) | Spring | PF | Yes |
| Obj. Or. Prog. | Spring | PF | No | |