Manuscript Offprint

arXiv:2610.31119

Constraint Reasoning and Large Language Models Join Forces: Providing Contrastive Explanations for Real-World Optimisation-Based Applications

Roger X. Lera-Leri, Filippo Bistaffa, Athina Georgara, Juan A. Rodríguez-Aguilar

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Roger X. Lera-Leri*‡, Filippo Bistaffa*, Athina Georgara†, Juan Antonio Rodríguez-Aguilar*, *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 Programming (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.

Index Terms—Contrastive Explanations, Constraint Reasoning, Large Language Models, Optimisation-based Decision Support Systems.

I. INTRODUCTION

In many real-world domains, decision-making processes are driven by Decision Support Systems (DSS) based on recommendations computed by an optimisation approach (i.e., the solution to an optimisation problem). For instance, scheduling optimisation problems have been used to guide human decisions across various application domains, such as workforce scheduling [1], food industry production [2], and construction projects [3]. In this work, we consider two real-world scheduling problems as our test cases, both formulated as Mixed-Integer Programming (MIP) models. First, we consider the well-known Resource-Constraint Project Scheduling Problem (RCPSP) [4]–[6], a general framework that, over the years, has been employed to model a wide variety of real-world applications [7]–[9]. Secondly, we consider a problem in the educational domain, the Degree Planning Problem (DPP) [10]. This problem aims to compute a personalised bachelor's degree plan—a sequence of subjects across semesters —that allows a student to acquire the professional skills required for their preferred job. Planning which subjects to undertake is a challenging and important task that significantly impacts students' professional careers. Notice that, in contrast with the RCPSP, which aims at minimising the makespan required to complete all activities, the focus of the DPP is to maximise the preferences of the users (represented by their desired jobs), hence representing a complementary use case with respect to RCPSP.

In these scenarios, an optimisation algorithm would compute and recommend to a user a project scheduling or a bachelor's degree plan. Besides computing a solution to the optimisation problem at hand, there is the challenge of explaining the solution to an end user. Recently, this challenge has also been identified as a key issue by AI researchers. Thus, the need to explain the decisions of a DSS has recently received much attention in the AI community, particularly because of the widespread use of powerful “black-box” Machine Learning (ML) models [11]. Such interest has been amplified by regulations that establish individuals’ right to receive meaningful justifications for algorithmic decisions [12]. However, despite its actual-world relevance, optimisation-based DSS has received much less attention.

In this context, this paper focuses on harnessing AI techniques to generate explanations for optimisation-based DSS. More precisely, our research question is how to leverage the capabilities of Large Language Models (LLMs) to answer the questions that users might pose to the DSS to challenge its recommended decisions (e.g., “Why do you recommend taking a course on Cybersecurity instead of a course on Computational Finance?”). These types of questions reflect a human tendency to seek contrastive explanations —those that do not merely state why something was recommended, but why it was recommended rather than an alternative (e.g., “Computational Finance is not recommended because it is an elective course whose skills are not relevant to your desired job, whereas Cybersecurity contributes to acquiring a high level of Vulnerability Research, a skill required for your desired job.”). The usefulness of contrastive explanations is supported by the social sciences, which argue that explanations are most useful and satisfying when they are contrastive [13]. Notice that aiming at contrastive explanations aligns with state-of-the-art works in eXplainable Artificial Intelligence (XAI), which pursue generating contrastive explanations to justify the outcomes of ML algorithms [14]–[16].

‡^{\ddagger} Corresponding author: Roger X. Lera-Leri (rlera@iiia.csic.es)

Despite their remarkable capabilities in natural language processing, LLMs are known to struggle with abstract reasoning tasks [17]. This limitation becomes particularly problematic when attempting to explain the outcome of optimisation problems, whose explanations typically depend on intricate reasoning across many interdependent constraints. As a result, directly prompting an LLM to explain an outcome (as done, for instance, by Rajani et al. [18]) may lead to unreliable explanations [19], [20]. In particular, LLMs may produce incorrect explanations, for example, by asserting that a user-proposed alternative is infeasible when it is not (as discussed in Section III-E). Moreover, their explanations are often uninformative, as they tend to offer vague statements about the existence of constraints without explicitly identifying which constraints prevent the user-proposed alternative outcome.

To overcome this lack of abstract reasoning capabilities of LLMs, in this paper, we propose Large Language Models for Explainable MIP (LLMxMIP), a novel methodology that places constraint reasoning at the service of LLMs to generate textual explanations that are correct and informative. More specifically, LLMxMIP is a process that follows five main steps, outlined in Figure 1. First, it transforms a user's query, i.e., the question posed by the user, into a constraint and reformulates the original optimisation problem as a Constraint Satisfaction Problem (CSP) that is compliant with the user's query (first and second steps, respectively). Then it identifies conflicts that prevent us from obtaining a better solution that accommodates the user query. This amounts to extracting the set of constraints in the CSP that make it infeasible (third step). 1^{1} Our approach exploits constraint reasoning to compute such a set of constraints, i.e., the minimal subset of constraints that make the CSP infeasible, namely the Irreducible Infeasible Subsystem (IIS) [21]. Afterwards, LLMxMIP transforms the unstructured collection of mathematical constraints in the IIS into a structured graph, the so-called graph of reasons. Such a graph captures the relationships between constraints and assigns them a semantic interpretation — which we call “reason”— by means of Natural Language (NL) templates. Finally, an LLM leverages the graph of reasons to generate a textual explanation.

Overall, we significantly extend prior work [22] on explainability for MILPs, which relies solely on constraint reasoning, by introducing the following novel contributions:

• We propose LLMxMIP, a novel methodology that integrates state-of-the-art Artificial Intelligence (AI) techniques —combining constraint reasoning with LLMs— to explain the outcomes of an optimisation-based process encoded as a MIP.

• We employ constraint reasoning techniques to identify the underlying reasons that explain why it is not possible to obtain a better solution that satisfies the user’s query. Then we transform this unstructured set of reasons into a graph that captures their relationships.

• In contrast to [22], we leverage LLMs to generate textual explanations from the graph of reasons, whose structured representation enables LLMs to produce complete and accurate explanations.

• We test LLMxMIP on two prominent real-world optimisation-based scenarios, i.e., the DPP (considering the data from a real Bachelor’s Degree [10]) and the RCPSP. Our results indicate that using graphs of reasons as input to LLMs results in textual explanations that are significantly better in terms of completeness and readability. Additionally, we show that computing explanations with LLMxMIP is faster than solving such problems in most cases.

This paper is organised as follows. Section II discusses background concepts of integer programming and constraint programming, and the basic notions of the scheduling problems used in the experimental evaluation. In Section III, we propose our approach. In Section IV, we evaluate the quality of the explanations generated with LLMs. Additionally, we perform an empirical analysis of the computational cost of providing explanations. We discuss the related work in Section V. Section VI concludes the paper and discusses future research directions.

References (81)