<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CPMpy | DTAI Stories</title><link>https://dtai.cs.kuleuven.be/stories/tags/cpmpy/</link><atom:link href="https://dtai.cs.kuleuven.be/stories/tags/cpmpy/index.xml" rel="self" type="application/rss+xml"/><description>CPMpy</description><generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><lastBuildDate>Thu, 30 Jul 2026 17:14:00 +0200</lastBuildDate><image><url>img/map[gravatar:%!s(bool=false) shape:circle]</url><title>CPMpy</title><link>https://dtai.cs.kuleuven.be/stories/tags/cpmpy/</link></image><item><title>CPMpy release and celebrations at FLOC26</title><link>https://dtai.cs.kuleuven.be/stories/post/tias-guns/cpmpy_release/</link><pubDate>Thu, 30 Jul 2026 17:14:00 +0200</pubDate><guid>https://dtai.cs.kuleuven.be/stories/post/tias-guns/cpmpy_release/</guid><description>&lt;p>CPMpy made its v1.0 release a week ago, and won multiple medals in the
&lt;a href="https://www.floc26.org/olympics" target="_blank" rel="noopener">FLoC Olympic Games&lt;/a> competitions.&lt;/p>
&lt;div style="text-align: center;">
&lt;figure id="figure-constraint-programming-and-modeling-in-python">
&lt;a href="https://github.com/CPMpy/cpmpy" target="_blank">
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/tias-guns/cpmpy_release/cpmpy_logo_hu2128660dda9467f2b93c849ddbdb802f_226482_2000x2000_fit_lanczos_3.png" class="lazyload" alt="CPMpy logo" width="55%" height="600">
&lt;/a>
&lt;figcaption>
Constraint Programming and Modeling in Python
&lt;/figcaption>
&lt;/figure>
&lt;p>
&lt;a href="https://github.com/CPMpy/cpmpy" target="_blank" rel="noopener">Code&lt;/a>
&lt;i class="fab fa-github pr-1 fa-fw">&lt;/i> ·
&lt;a href="https://cpmpy.readthedocs.io/" target="_blank" rel="noopener">Documentation&lt;/a>
&lt;i class="fas fa-book pr-1 fa-fw">&lt;/i> ·
&lt;a href="https://pypi.org/project/cpmpy/" target="_blank" rel="noopener">PyPI&lt;/a>
&lt;i class="fab fa-python pr-1 fa-fw">&lt;/i>&lt;/p>
&lt;/div>
&lt;!-- &lt;div class="alert alert-tip">
&lt;div>
&lt;strong>v1.0.0 is out!&lt;/strong> Install with &lt;code>pip install cpmpy&lt;/code>, or browse the
&lt;a href="https://github.com/CPMpy/cpmpy/releases" target="_blank" rel="noopener">release on GitHub&lt;/a>.
&lt;/div>
&lt;/div>
-->
&lt;p>Last week we were in Lisbon, Portugal for
&lt;a href="https://www.floc26.org/" target="_blank" rel="noopener">FLoC&lt;/a>, a co-located conference that included CP, SAT, KR, and seven other logic-based conferences.&lt;/p>
&lt;p>Just before the conference, the team managed to finish the v1.0.0 release of our
&lt;a href="https://github.com/CPMpy/cpmpy" target="_blank" rel="noopener">CPMpy&lt;/a> library for combinatorial optimisation. This library has been the foundation of my
&lt;a href="https://people.cs.kuleuven.be/~tias.guns/chat-opt.html" target="_blank" rel="noopener">ERC CHAT-Opt&lt;/a> project. We should have released a version 1 over 3 years ago, but we were too occupied with wanting to make it better and better&amp;hellip;&lt;/p>
&lt;p>As the CHAT-Opt project came to an end, it felt like the right moment to mark it with a 1.0.0 release (we still have plans to make it even better though). We celebrated the release with an official logo, and nice T-shirts featuring the logo that the team members were wearing. We were happy with the many encouraging words and conversations that followed!&lt;/p>
&lt;p>We were also honoured to receive a FLOC Olympic Games medal for our submission with
&lt;a href="https://developers.google.com/optimization" target="_blank" rel="noopener">OR-Tools CP-SAT&lt;/a> to the
&lt;a href="https://www.xcsp.org/competitions/" target="_blank" rel="noopener">XCSP3 competition&lt;/a>. We actually submitted eight different solvers to that competition. The role of CPMpy in such a submission is to efficiently take any instance, minimally modify it to match the solver API, and quickly pass that on to the solver. While this requires careful engineering, it is the solver itself that makes the biggest difference here. Hence, we were happy to take the medal, with no modifications needed, and pass it on to
&lt;a href="https://research.google/people/105821/?&amp;amp;type=google" target="_blank" rel="noopener">Laurent Perron&lt;/a> of the OR-Tools CP-SAT team : )&lt;/p>
&lt;p>Thanks to our team member &lt;a href="https://dtai.cs.kuleuven.be/stories/stories/authors/thomas-sergeys/">Thomas Sergeys&lt;/a>, we not only submitted multiple solvers to the XCSP3 competition, but we also submitted multiple solvers to the
&lt;a href="https://www.cril.univ-artois.fr/PB26/" target="_blank" rel="noopener">Pseudo-Boolean Competition&lt;/a> and to
&lt;a href="https://maxsat-evaluations.github.io/2026/" target="_blank" rel="noopener">MaxSAT Evaluation&lt;/a>. Here too, our submission with OR-Tools tended to perform best among our submissions, even resulting in 2 bronze medals in the XCSP3 COP track and 2 gold medals in the PseudoBoolean parallel DEC_LIN and OPT_LIN tracks!&lt;/p>
&lt;p>(The attentive reader might wonder why we &amp;lsquo;only&amp;rsquo; achieved bronze with cpmpy_ortools on XCSP3 COP, a track in which we achieved gold the past 2 years. The answer is as subtle as it is unfortunate: the competition awards solvers for how quickly they find intermediate solutions. However our submission accidentally buffered all these intermediate solutions throughout the entire solver&amp;rsquo;s runtime, only appearing all at once at the complete end. A simple mistake which we forgot to change during maintenance work&amp;hellip;)&lt;/p>
&lt;p>Finally, this year we not only submitted solvers, but we also used our new CPMpy tools &amp;lsquo;datasets&amp;rsquo; and &amp;lsquo;io&amp;rsquo; to submit instances from public benchmarks to different competitions, translated by CPMpy. If you want to read more about how we did that, check out our SAT Tool paper
&lt;a href="https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.SAT.2026.42" target="_blank" rel="noopener">Unified Programmatic Access to CO Benchmarks, to Connect Constraint Solving Communities&lt;/a>. We also submitted the real-world problem instances of our
&lt;a href="https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.CP.2025.6" target="_blank" rel="noopener">CP26 Best Application Paper&lt;/a> and a benchmark set derived from the
&lt;a href="https://aics.aau.at/saeling/" target="_blank" rel="noopener">SAELING&lt;/a> project in the metalworking industry to the
&lt;a href="https://www.minizinc.org/challenge/2026/" target="_blank" rel="noopener">MiniZinc Challenge&lt;/a>.&lt;/p>
&lt;p>All in all, it should be clear that I am immensely proud of what we have achieved with CPMpy over these past years. The release, the feedback and the awards are great recognition of that effort, and I want to wholeheartedly thank all the researchers that helped build CPMpy along the way.&lt;/p>
&lt;!--
&lt;div class="card relpub">
&lt;div class="card-body">
&lt;small>
&lt;p>This post is based on the following publications:&lt;/p>
&lt;ul>
&lt;li>
&lt;a href="https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.CP.2025.6" target="_blank" rel="noopener">Modeling and Explaining an Industrial Workforce Allocation and Scheduling Problem&lt;/a>. Bleukx, Ignace, Boumazouza, Ryma, Guns, Tias, Laage, Nadine, and Poveda, Guillaume, CP 2025 (Best Application Paper Award).&lt;/li>
&lt;li>
&lt;a href="https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.SAT.2026.42" target="_blank" rel="noopener">Unified Programmatic Access to CO Benchmarks, to Connect Constraint Solving Communities&lt;/a>. Sergeys, Thomas, Bleukx, Ignace, Guns, Tias, SAT 2026 (Tool paper).&lt;/li>
&lt;/ul>
&lt;/small>
&lt;/div>
&lt;/div>
--></description></item><item><title>Modelling and Explaining Workforce Allocation at Airbus with CPMpy</title><link>https://dtai.cs.kuleuven.be/stories/post/ignace-bleukx/modelling-and-explaining-workforce-allocation-at-airbus-with-cpmpy/</link><pubDate>Mon, 27 Apr 2026 16:31:21 +0200</pubDate><guid>https://dtai.cs.kuleuven.be/stories/post/ignace-bleukx/modelling-and-explaining-workforce-allocation-at-airbus-with-cpmpy/</guid><description>&lt;p>As part the EU project Tuples [1] we had the opportunity of collaborating with Airbus Toulouse on a challenging workforce allocation and scheduling problem. Everyday, planners at Airbus factories need to schedule and allocate logistical tasks to worker teams. These tasks are incredibly diverse and range from the transportation of aircraft components from one hangar to another to the loading and unloading of Beluga® cargo planes.&lt;/p>
&lt;div style="display:flex; justify-content:centerl; gap:16px; width:80%; margin:0 auto 1em auto;">
&lt;figure style="flex:1; margin:0;">
&lt;img src="beluga.jpg" alt="Beluga cargo plane" style="width:100%; height:200px; object-fit:cover; display:block;">
&lt;/figure>
&lt;figure style="flex:1; margin:0;">
&lt;img src="factory.jpg" alt="Airbus factory" style="width:100%; height:200px; object-fit:cover; display:block;">
&lt;/figure>
&lt;/div>
&lt;p>Timely execution of these tasks is essential for the operational efficiency of the factory. Indeed, any missed deadlines can cascade throughout the assembly lines and cause significant delays during production of the aircraft. The planning and allocation of these transportation tasks is mostly done by hand by an expert team of planners. They ensure that each task is executed on time, and by a worker team that has the required training for executing that task.&lt;/p>
&lt;p>Using our expertise in constraint optimization, we collaborated with the research team at Airbus to develop a reliable, trustworthy and explainable decision support system for the planners. More specifically, we developed algorithms that can (1) propose an efficient and fair initial schedule that satisfies all operational constraints and (2) can help in resolving operational disruptions throughout the day.&lt;/p>
&lt;h2 id="fair-and-efficient-schedules">Fair and Efficient Schedules&lt;/h2>
&lt;p>Using the open-source CPMpy constraint modelling library, we developed a Constraint Programming (CP) model to solve this large workforce-allocation and scheduling problem.
CP is a declarative approach for solving combinatorial problems, where the user models their problem using integer variables and constraints; after which a general-purpose constraint solver is used to find an optimal solution to the problem. This technology is perfectly suited for this problem as any solution computed by the solver is guaranteed to satisfy all operational constraints.&lt;/p>
&lt;p>Our model shares similarity with state-of the-art CP-models for flexible job-shop problems where the goal is to schedule a set of tasks onto a set of machines, where tasks cannot overlap. We used scheduling-specific global constraints, symmetry breaking techniques and a problem relaxation to efficiently find optimal solutions to the allocation and scheduling problem.
Unique to this use-case of workforce allocation are the objectives we aim to optimize. In traditional scheduling problems, it is common to minimize the makespan. However, for our problem, we construct a bi-objective optimization problem with the following objectives:&lt;/p>
&lt;ol>
&lt;li>Minimize the number of worker-teams used to execute the schedule&lt;/li>
&lt;li>Optimize fairness of the schedule, such that no team is needlessly overused or underused. The fairness is formulated as the “time-dispersion”, which is expressed formally as $max_{t \in Teams} (time_worked_t) - min_{t \in Teams} (time_worked_t)$&lt;/li>
&lt;/ol>
&lt;p>We experiment with two variants of the problem: a pure-allocation and an allocation+scheduling setting. In the pure allocation setting, planners first determine the start-times of each task, and use the CP-model to allocate the tasks to a team. This reflects their current workflow as tasks are scheduled given an order book for the coming planning period. In the allocation+scheduling setting, the solver is free to chose the start-time of each task, given its earliest start-time and deadline.&lt;/p>
&lt;p>Our experiments showed that using clever modelling techniques such as symmetry breaking constraints, most solvers can find optimal solutions for the pure-allocation setting when minimizing the number of teams in the schedule; and ILP solver Gurobi and Pseudo-Boolean solver Exact perform best among the solvers we tested.&lt;/p>
&lt;div style="display:flex; justify-content:center; align-items:stretch; gap:16px; width:100%;">
&lt;figure style="flex:1; margin:0;">
&lt;img src="allocation.svg" alt="Allocation results" style="width:100%; height:300px; object-fit:contain; display:block;">
&lt;/figure>
&lt;figure style="flex:1; margin:0;">
&lt;img src="scheduling_objective.svg" alt="Scheduling objective over time" style="width:100%; height:320px; object-fit:contain; display:block;">
&lt;/figure>
&lt;/div>
&lt;p>While truly optimal solutions with respect to the fairness objective are rarely found, experiments showed that fair schedules can be found within a couple of seconds using modern solvers. Indeed, the right plot shows the how the objectives change over time for the allocation+scheduling problem (the most difficult variant). Here we clearly see the objective decreases rapidly at the start of the solving process.&lt;/p>
&lt;figure >
&lt;a data-fancybox="" href="https://dtai.cs.kuleuven.be/stories/stories/post/ignace-bleukx/modelling-and-explaining-workforce-allocation-at-airbus-with-cpmpy/repair_hu00445bf75aacd3445091330222c180e6_201226_2000x2000_fit_lanczos_3.png" >
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/ignace-bleukx/modelling-and-explaining-workforce-allocation-at-airbus-with-cpmpy/repair_hu00445bf75aacd3445091330222c180e6_201226_2000x2000_fit_lanczos_3.png" class="lazyload" alt="" width="80%" height="1496">
&lt;/a>
&lt;/figure>
&lt;h2 id="explaining-and-resolving-disruptions">Explaining and Resolving Disruptions&lt;/h2>
&lt;p>In our research lab, we have been working on explainable constraint solving: we have studied methods not just for efficiently finding solutions, but also for explaining the answer of a constraint solver to a user.&lt;/p>
&lt;p>For this project, a big hurdle for the planners is to understand the consequences of a disruption and how to resolve them. Examples of disruptions are technical malfunctions or unexpectedly adverse weather conditions that cause a resource or worker team to be unavailable for a certain amount of time. Such disruptions are common and almost unavoidable.&lt;/p>
&lt;p>In collaboration with Airbus, we proposed a method to help the planners resolve disruptions by computing a new schedule which is as similar as possible to the initial schedule. More precisely, we compute a new schedule which (1) does not call in any extra teams; (2) minimizes the number of reallocated tasks and (3) minimizes the delay of tasks compared to the initial schedule.&lt;/p>
&lt;p>This ensures the repaired schedule impacts the least number of teams operating on the plant and reduces the cognitive load on the planners to interpret the newly computed schedule. Moreover, as the new schedule uses the original CP-model, the new schedule is guaranteed to satisfy all operational side-constraints as well.&lt;/p>
&lt;h2 id="acknowledgements">Acknowledgements&lt;/h2>
&lt;p>We are honoured that are work was recognized by the CP 2025 Best Application Award, and thank our collaborators at Airbus for this inspiring and fruitful collaboration.&lt;/p>
&lt;h2 id="references">References&lt;/h2>
&lt;ol>
&lt;li>Tuples | Trustworthy AI, Tuples.ai. (2023).
&lt;a href="https://tuples.ai/" target="_blank" rel="noopener">https://tuples.ai/&lt;/a>&lt;/li>
&lt;li>Bleukx, Ignace, Ryma Boumazouza, Tias Guns, Nadine Laage, and Guillaume Poveda. &amp;ldquo;Modeling and explaining an industrial workforce allocation and scheduling problem.&amp;rdquo; Leibniz International Proceedings in Informatics 340 (2025).‌&lt;/li>
&lt;/ol></description></item><item><title>Sudoku Assistant – An AI Assistant Combining Machine Learning and Reasoning</title><link>https://dtai.cs.kuleuven.be/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/</link><pubDate>Tue, 11 Jun 2024 15:51:11 +0200</pubDate><guid>https://dtai.cs.kuleuven.be/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/</guid><description>&lt;p>&lt;em>This story was originally published via
&lt;a href="https://ai.kuleuven.be/stories/" target="_blank" rel="noopener">Leuven.AI Stories&lt;/a>.&lt;/em>&lt;/p>
&lt;p>
&lt;a href="https://en.wikipedia.org/wiki/Sudoku" target="_blank" rel="noopener">Sudoku&lt;/a> is a popular pen-and-paper puzzle game that involves completing a partially filled-in 9x9 grid such that each row, column, and 3x3 box contains all of the digits from 1 to 9. It is commonly included in the puzzle section of newspapers and magazines, and is even sold in the form of dedicated Sudoku puzzle books. It comes in many variants and even has its own annual
&lt;a href="https://www.wspc2022.com/" target="_blank" rel="noopener">world championship&lt;/a>.&lt;/p>
&lt;p>It is also often included in introductory artificial intelligence (AI) courses as a nice way to introduce students to the area of &lt;em>
&lt;a href="https://en.wikipedia.org/wiki/Constraint_programming" target="_blank" rel="noopener">constraint programming&lt;/a>&lt;/em> (CP), a research field that focuses on solving problems that are expressed as constraints over decision variables. With some basic constraint programming knowledge, it is surprisingly easy to write the Sudoku rules as constraints, and have a generic solver compute the solution in milliseconds.&lt;/p>
&lt;p>However, using these highly effective constraint reasoning techniques requires that the Sudoku is provided in a symbolic way, meaning that the 9x9 grid and the given digits are provided to the system as a matrix of numbers. If the Sudoku were given in the form of an image (taken with a smartphone, for example), then this image could not be given as input to a constraint solver. One first has to recognize the given digits and the empty cells, a task best tackled using computer vision techniques involving (convolutional)
&lt;a href="https://en.wikipedia.org/wiki/Artificial_neural_network" target="_blank" rel="noopener">neural networks&lt;/a>, which are machine learning models that can learn to recognize objects, translate text, generate images and so much more.&lt;/p>
&lt;p>Machine learning (e.g., neural networks) and reasoning (e.g., constraint programming) are subfields of AI that have historically been developed mostly independently from one another. However, nowadays there is a growing research interest in &lt;strong>combining these subfields&lt;/strong>. We have developed the &lt;em>Sudoku Assistant&lt;/em> app,
&lt;a href="https://play.google.com/store/apps/details?id=be.kuleuven.cs.visualsudoku&amp;amp;pli=1" target="_blank" rel="noopener">available on the Google Play store&lt;/a>, as a demonstration of such a combination.&lt;/p>
&lt;h2 id="sudoku-assistant--a-demonstrator-of-three-ai-trends">Sudoku Assistant – a demonstrator of three AI trends&lt;/h2>
&lt;p>The
&lt;a href="https://sudoku-assistant.cs.kuleuven.be/index.html" target="_blank" rel="noopener">Sudoku Assistant&lt;/a> is an AI assistant that can interpret, solve and explain pen-and-paper Sudokus scanned with a smartphone. It uses techniques from both machine learning and constraint programming, but goes one step further: it employs &lt;strong>a new way of integrating the digit recognition and the reasoning more deeply&lt;/strong>, allowing it to solve significantly more scanned Sudokus correctly than previous approaches were able to.&lt;/p>
&lt;p>Furthermore, it isn&amp;rsquo;t limited to merely &lt;em>solving&lt;/em> Sudokus: through the use of our state-of-the-art research on step-wise explanations to constraint satisfaction problems, it is able to &lt;strong>guide the user through the solving process by giving small hints&lt;/strong>. This ensures that the AI system doesn&amp;rsquo;t ruin the fun by doing the solving for you, but is able to assist you when you are stuck.&lt;/p>
&lt;p>The Sudoku Assistant hence demonstrates three concepts that are becoming increasingly important in AI research: &lt;strong>the integration of learning and reasoning, explainable AI&lt;/strong> and &lt;strong>human-centered AI&lt;/strong>. And although the assistant is focused on Sudoku, the underlying techniques are equally applicable to other constraint solving problems like timetabling, scheduling and vehicle routing.&lt;/p>
&lt;h2 id="solving-scanned-sudokus-with-integrated-prediction-and-reasoning">Solving Scanned Sudokus with integrated prediction and reasoning&lt;/h2>
&lt;p>One of the Sudoku Assistant&amp;rsquo;s main features is the ability to solve pen-and-paper Sudokus scanned with a smartphone. To do this, the user starts by taking a picture of a Sudoku puzzle. After a picture is taken, the image is segmented into 81 cells. A pre-trained neural network – more specifically a
&lt;a href="https://en.wikipedia.org/wiki/Convolutional_neural_network" target="_blank" rel="noopener">convolutional neural network&lt;/a> (CNN), which is commonly used for image recognition tasks – is then applied to each cell in order to make a digit prediction.&lt;/p>
&lt;p>For each cell, the output of the CNN is a probability distribution over the 10 possible values: digits 1-9 and the empty cell value. Once a probability distribution has been predicted for each cell, the distributions should be used somehow in order to obtain a solution, i.e., a fully filled-in Sudoku. There are two ways of doing this: a naive way in which the digit prediction and the constraint reasoning are clearly separated, and a more effective way in which they are integrated.&lt;/p>
&lt;figure >
&lt;a data-fancybox="" href="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/segmented_sudoku_new_huc9cbef85045ad7b7c59bbb88e0eb6d62_927916_2000x2000_fit_lanczos_3.png" >
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/segmented_sudoku_new_huc9cbef85045ad7b7c59bbb88e0eb6d62_927916_2000x2000_fit_lanczos_3.png" class="lazyload" alt="Figure 1: Cropped and aligned picture of a Sudoku grid taken with a smartphone camera." width="40%" height="1098">
&lt;/a>
&lt;/figure>
&lt;div style="text-align: center;">
&lt;p>&lt;em>&lt;strong>Figure 1: Cropped and aligned picture of a Sudoku grid taken with a smartphone camera.&lt;/strong>&lt;/em>&lt;/p>
&lt;/div>
&lt;figure >
&lt;a data-fancybox="" href="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/predicted_values_new_hu1241ea1aa8b7e7171c7d9fdd1e5e9852_250744_2000x2000_fit_lanczos_3.png" >
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/predicted_values_new_hu1241ea1aa8b7e7171c7d9fdd1e5e9852_250744_2000x2000_fit_lanczos_3.png" class="lazyload" alt="Figure 2: In each cell, the predicted probability distribution is visualized using a bar chart. The blue bar represents the probability of the cell being empty, while the other 9 bars represent the probabilities of the digits 1 to 9. Bars associated with very small probabilities are omitted." width="40%" height="1101">
&lt;/a>
&lt;/figure>
&lt;div style="text-align: center;">
&lt;p>&lt;em>&lt;strong>Figure 2: In each cell, the predicted probability distribution is visualized using a bar chart. The blue bar represents the probability of the cell being empty, while the other 9 bars represent the probabilities of the digits 1 to 9. Bars associated with very small probabilities are omitted&lt;/strong>&lt;/em>&lt;/p>
&lt;/div>
&lt;h4 id="a-naive-separated-approach">A naive, separated, approach&lt;/h4>
&lt;p>A naive way of using the probability distributions to solve the Sudoku involves assigning to each cell the value that is given the largest probability by the CNN classifier (i.e., the argmax, the most likely prediction). The resulting partial Sudoku can then be modeled as a
&lt;a href="https://en.wikipedia.org/wiki/Constraint_satisfaction_problem" target="_blank" rel="noopener">constraint satisfaction problem&lt;/a> (CSP), which is a problem that consists solely of constraints, and thus does not contain a criterion to be optimized. The CSP can be given to a generic constraint solver in order to obtain the full solution. This approach is schematically shown in Figure 3.&lt;/p>
&lt;p>One large disadvantage of this approach results from the fact that even a single misclassification almost always leads to a wrong solution, or no solution at all. For this reason, even if the digit classifier would have an accuracy of 99%, the naive approach would lead to a correct solution only approximately 0.9981 = 44% of the time (since 81 cells must be classified). To improve on this weakness, a deeper integration of the digit recognition and the reasoning is needed.&lt;/p>
&lt;figure >
&lt;a data-fancybox="" href="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/architecture_1_hu164beb1c87dcc395d31fefdf80d93091_2324848_2000x2000_fit_lanczos_3.png" >
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/architecture_1_hu164beb1c87dcc395d31fefdf80d93091_2324848_2000x2000_fit_lanczos_3.png" class="lazyload" alt="Figure 3: The naive approach. First, a CNN classifier predicts a probability distribution over all 10 possible values for each cell. Then, for each cell, the value with the largest assigned probability is taken and given to a CSP solver, which then computes and outputs the solution." width="3262" height="709">
&lt;/a>
&lt;/figure>
&lt;div style="text-align: center;">
&lt;p>&lt;em>&lt;strong>Figure 3: The naive approach. First, a CNN classifier predicts a probability distribution over all 10 possible values for each cell. Then, for each cell, the value with the largest assigned probability is taken and given to a CSP solver, which then computes and outputs the solution.&lt;/strong>&lt;/em>&lt;/p>
&lt;/div>
&lt;h4 id="an-integrated-approach">An integrated approach&lt;/h4>
&lt;p>To avoid finding no solution or a wrong solution,
&lt;a href="https://arxiv.org/pdf/2003.11001.pdf" target="_blank" rel="noopener">we proposed an alternative approach&lt;/a>, which features a deeper integration of the digit classification and the reasoning required to solve the Sudoku puzzle. This approach is schematically shown in Figure 4.&lt;/p>
&lt;figure >
&lt;a data-fancybox="" href="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/architecture_2_hu232a6aab97fdf676e1fc65193fcac6c9_125929_2000x2000_fit_lanczos_3.png" >
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/architecture_2_hu232a6aab97fdf676e1fc65193fcac6c9_125929_2000x2000_fit_lanczos_3.png" class="lazyload" alt="Figure 4: An integrated approach. The difference with Figure 3 can be seen in the input to the CP solver: here, the full probability distributions produced by the CNN classifier – rather than just the most likely predictions – are used by the CP solver to compute the assignment with the maximum likelihood that respects the Sudoku constraints. This integrated approach can successfully solve considerably more Sudoku puzzles than the naive approach." width="3198" height="642">
&lt;/a>
&lt;/figure>
&lt;div style="text-align: center;">
&lt;p>&lt;em>&lt;strong>Figure 4: An integrated approach. The difference with Figure 3 can be seen in the input to the CP solver: here, the full probability distributions produced by the CNN classifier – rather than just the most likely predictions – are used by the CP solver to compute the assignment with the maximum likelihood that respects the Sudoku constraints. This integrated approach can successfully solve considerably more Sudoku puzzles than the naive approach.&lt;/strong>&lt;/em>&lt;/p>
&lt;/div>
&lt;p>The main idea is to not provide the constraint solver with merely the most likely digit – as predicted by the neural network – for each of the Sudoku’s cells, but rather with the full distributions outputted by the network. In other words, for each of the 81 cells, the solver is given the class probabilities of all 10 possible classes. The solver is then tasked to solve a
&lt;a href="https://en.wikipedia.org/wiki/Constrained_optimization" target="_blank" rel="noopener">constrained optimization problem&lt;/a> (COP), rather than a CSP. This means that it does not merely look for a solution that satisfies certain constraints anymore. It now prefers certain constraint-satisfying solutions over others.&lt;/p>
&lt;p>Concretely, the solver now searches for a solution in which the product of the probabilities associated with all the chosen digits is maximal (i.e., the maximum likelihood solution, given the class probabilities), whilst satisfying the rules of Sudoku. Effectively, this integrated approach allows the reasoning to &lt;strong>correct&lt;/strong> some of the mistakes made by the CNN classifier, by subjecting the classifications to the Sudoku constraints.&lt;/p>
&lt;figure >
&lt;a data-fancybox="" href="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/corrected_value_new_huc2942eceac0cd0a4922ae3cef7e5f8b3_107628_2000x2000_fit_lanczos_3.png" >
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/corrected_value_new_huc2942eceac0cd0a4922ae3cef7e5f8b3_107628_2000x2000_fit_lanczos_3.png" class="lazyload" alt="Figure 5: Wrongly predicted digits corrected by the joint prediction-and-reasoning approach shown in Figure 4." width="40%" height="1104">
&lt;/a>
&lt;/figure>
&lt;div style="text-align: center;">
&lt;p>&lt;em>&lt;strong>Figure 5: Wrongly predicted digits corrected by the joint prediction-and-reasoning approach shown in Figure 4.&lt;/strong>&lt;/em>&lt;/p>
&lt;/div>
&lt;p>Consider, for example, the Sudoku puzzle shown in Figure 5. The naive approach would assign value 2 to the cell highlighted in red, as well as to the cell above it, highlighted in blue, based on the predicted probability distributions (which were shown in Figure 2). However, since two cells in the same column would contain a 2, the CSP solver would not be able to find a valid solution to the problem.&lt;/p>
&lt;p>Instead, our integrated approach recognizes that if the value 2 would occur twice in the same column, a Sudoku constraint would be violated. To correct this conflict, it considers the other probabilities in the predicted distributions. In this case the correction is quite easy: the second largest probability of the cell in red (associated with the value 3) is larger than the second largest probability of the cell in blue, and assigning the value 3 to the cell in red does not conflict with any of the other value assignments. Thus, the value 3 is assigned to the cell in red.&lt;/p>
&lt;p>If, instead, the value 3 &lt;em>did&lt;/em> conflict with another assignment, then either that other assignment would also be corrected, or a value with an even lower probability would be assigned to the cell in red, depending on which option leads to the largest joint probability (the product of the probabilities associated with the assigned values). In this way, the corrections can become quite complex, as is demonstrated in Figure 6, where the cells in red represent the corrections (i.e., value assignments that do not have the largest probability according to the digit recognition model).&lt;/p>
&lt;p>Our approach might even make a correction when there is no direct conflict between any of the most probable values of the different cells. This happens when those values constitute a Sudoku that has no solution, or one that has multiple solutions. Even in these cases the integrated approach knows that the digit recognition model must have made a mistake, since a valid Sudoku must have a unique solution.&lt;/p>
&lt;figure >
&lt;a data-fancybox="" href="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/more_complex_correction_hu1efa411539d1591217fa7ce3f92ae165_15146097_2000x2000_fit_lanczos_3.png" >
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/more_complex_correction_hu1efa411539d1591217fa7ce3f92ae165_15146097_2000x2000_fit_lanczos_3.png" class="lazyload" alt="Figure 6: The corrections made by the novel integrated approach can become quite complex." width="3500" height="1080">
&lt;/a>
&lt;/figure>
&lt;div style="text-align: center;">
&lt;p>&lt;em>&lt;strong>Figure 6: The corrections made by the novel integrated approach can become quite complex.&lt;/strong>&lt;/em>&lt;/p>
&lt;/div>
&lt;div class="card relpub">
&lt;div class="card-body">
&lt;small>
Our approach performs a form of &lt;strong>joint inference&lt;/strong>, taking into account the constraints of the Sudoku problem. The integrated prediction-and-reasoning approach &lt;strong>solves significantly more Sudoku problems correctly&lt;/strong> compared to the naive approach.
&lt;/small>
&lt;/div>
&lt;/div>
&lt;h2 id="guiding-the-user-by-generating-hints">Guiding the user by generating hints&lt;/h2>
&lt;p>We want the Sudoku Assistant to do more than just show the solution and ruin all the fun for the user. We also want it to be able to &lt;em>guide&lt;/em> the user to finding the solution, and to make them learn some solving strategies along the way. For this purpose, we integrated our state-of-the-art research on &lt;em>
&lt;a href="https://www.ijcai.org/proceedings/2021/0191.pdf" target="_blank" rel="noopener">step-wise explaining constraint satisfaction problems&lt;/a>&lt;/em> into the assistant.&lt;/p>
&lt;figure >
&lt;a data-fancybox="" href="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/hint_new_huc9b0472bedb13a4175b54bdb7dac5cbe_4817144_2000x2000_fit_lanczos_3.png" >
&lt;img data-src="https://dtai.cs.kuleuven.be/stories/stories/post/senne-berden-tias-guns/sudoku-assistant-an-ai-assistant-combining-machine-learning-and-reasoning/img/hint_new_huc9b0472bedb13a4175b54bdb7dac5cbe_4817144_2000x2000_fit_lanczos_3.png" class="lazyload" alt="Figure 7: A generated hint." width="40%" height="1094">
&lt;/a>
&lt;/figure>
&lt;div style="text-align: center;">
&lt;p>&lt;em>&lt;em>&lt;strong>Figure 7: A generated hint.&lt;/strong>&lt;/em>&lt;/em>&lt;/p>
&lt;/div>
&lt;p>As a result, the Sudoku Assistant has a hint mechanism that provides the &lt;strong>easiest next move&lt;/strong> among all empty cells. The provided hint highlights only the existing digits and constraints necessary to derive that cell&amp;rsquo;s value.&lt;/p>
&lt;p>In Figure 6, the green cell containing a white puzzle piece represents a derived digit, which is currently hidden to the user in order to give them the chance to derive it by themselves. The cells highlighted in yellow contain the values that are needed in the derivation, and the blue column and row represent the constraints involved. These values and constraints are sufficient to derive that the green cell should contain the digit&amp;hellip; 7!&lt;/p>
&lt;p>We stated above that the Sudoku Assistant always provides the &lt;em>easiest&lt;/em> possible explanation step. We achieve this by using a cost function that expresses an explanation step&amp;rsquo;s difficulty, namely the number of constraints involved in it. This reflects the intuition that explanation steps involving many constraints are more difficult to understand than steps with less constraints.&lt;/p>
&lt;p>Of course, the &amp;lsquo;real&amp;rsquo; cost function that captures the actual difficulty of an explanation step from the perspective of a human is likely much more complex and nuanced, and probably domain dependent. The development of a cost function that better reflects this human perspective is definitely a promising direction for future work.&lt;/p>
&lt;h2 id="a-broader-perspective">A broader perspective&lt;/h2>
&lt;p>The approaches detailed in this article are by no means limited to Sudoku. The integrated approach is applicable to any problem consisting of a classification step followed by a constraint programming step. This means that it can easily be used on the many variants of Sudoku, or other puzzle games like
&lt;a href="https://en.wikipedia.org/wiki/Numberlink" target="_blank" rel="noopener">Numberlink&lt;/a>,
&lt;a href="https://en.wikipedia.org/wiki/Kakuro" target="_blank" rel="noopener">Kakuro&lt;/a> and
&lt;a href="https://en.wikipedia.org/wiki/Hidato" target="_blank" rel="noopener">Hidato&lt;/a>.&lt;/p>
&lt;p>There are also a range of real-world problems that require the scanning and interpreting of documents, where the required structure of the document is known (e.g., tax forms) or where the information provided has to be verified or completed (e.g., subsidy request forms). Even archaeological reconstruction of pieces into statues or paintings
&lt;a href="https://arxiv.org/abs/2005.12548" target="_blank" rel="noopener">requires perception and reasoning&lt;/a>. Just like in the Sudoku setting, knowledge of the requirements and constraints can be used to (re)construct the desired input, even when the machine learning models used for scanning make mistakes.&lt;/p>
&lt;p>Also our approach to step-wise explanations can easily be used on other constraint satisfaction problems, such as other logic puzzles and real-world problems like scheduling, timetabling and routing problems. For example, a company may need to find a schedule ensuring that each employee works a certain number of hours per week, that no two employees are scheduled to do the same job at the same time, and that all shifts are covered. The ability to generate a step-wise explanation of such a schedule can help employees understand why they have to work in certain shifts, and can help increase overall trust in the scheduling system.&lt;/p>
&lt;div class="card relpub">
&lt;div class="card-body">
&lt;small>
&lt;p>The Sudoku Assistant was built using our Python-based
&lt;a href="https://github.com/CPMpy/cpmpy" target="_blank" rel="noopener">CPMpy Constraint Programming and Modeling library&lt;/a>. We started building this library 2 years ago to facilitate the integration of constraint solving and machine learning, and to ease the development of explanation algorithms and other algorithms that involve repeatedly calling constraint solvers. The library, and the Sudoku Assistant, are part of Professor Tias Guns&amp;rsquo; prestigious 5-year ERC funded project on
&lt;a href="https://people.cs.kuleuven.be/~tias.guns/chat-opt.html" target="_blank" rel="noopener">Conversational Human-Aware Technologies for Optimisation&lt;/a>.&lt;/p>
&lt;p>The assistant is based on the following publications:&lt;/p>
&lt;ul>
&lt;li>
&lt;a href="https://link.springer.com/chapter/10.1007/978-3-030-58942-4_24" target="_blank" rel="noopener">Hybrid classification and reasoning for image-based constraint solving&lt;/a>. Maxime Mulamba, Jayanta Mandi, Rocsildes Canoy, and Tias Guns, In International Conference on Integration of Constraint Programming, Artificial Intelligence, and Operations Research, pages 364–380. Springer, 2020.&lt;/li>
&lt;li>
&lt;a href="https://www.ijcai.org/proceedings/2021/0191.pdf" target="_blank" rel="noopener">Efficiently Explaining CSPs with Unsatisfiable Subset Optimization&lt;/a> Emilio Gamba, Bart Bogaerts, and Tias Guns. In International Joint Conference on Artificial Intelligence, 1381-1388, 2021.&lt;/li>
&lt;/ul>
&lt;/small>
&lt;/div>
&lt;/div>
&lt;h2 id="system-overview">System Overview&lt;/h2>
&lt;div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
&lt;iframe src="https://www.youtube.com/embed/aTTjLSrG-l4" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" allowfullscreen title="Sudoku Assistant">&lt;/iframe>
&lt;/div>
&lt;h2 id="try-it-for-yourself">Try it for yourself&lt;/h2>
&lt;div class="play-badge">
You can download the Sudoku Assistant on an Android smartphone or tablet by following the link below.
&lt;a href="https://play.google.com/store/apps/details?id=be.kuleuven.cs.visualsudoku">
&lt;img src="img/google_play_badge.png" width="200px">
&lt;/a>
&lt;/div></description></item></channel></rss>