wikillm

Concept · 1 paper · updated 2026-10-18

Constraint satisfaction

Model finite-domain problems as variables, domains and rules, then let a solver find assignments that meet every rule, or optimise one quantity. Covers the Python-embedded route that compiles to the XCSP3 format and the choice of solver backend. One source so far: a library guide with no benchmarks.

constraint-programmingcombinatorial-optimizationmodeling

Markdown2 min read

AI-compiled overview, updated 2026-10-18, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

Overview

A constraint satisfaction problem (CSP) gives each unknown a finite domain of values and a set of rules that the values must jointly obey. A solution is an assignment that breaks no rule. A constraint optimisation problem (COP) adds one quantity to minimise or maximise 2009.00326 §2.2 2009.00326 §2.3. The author states the problem; a solver does the search 2009.00326 intro.

The only source on this page so far is the PyCSP3 user guide. It documents one toolchain, reports no benchmark results and does not survey the field. The page therefore describes that toolchain and its stated limits.

Variants

Python-embedded model compiled to XCSP3

Variables, domains, rules and an optional objective are written as Python code. Instance data sits in a separate JSON file. The model and data compile to an XCSP3 XML instance, which a solver reads 2009.00326 §5.1. The guide's worked examples use this route. Card: PyCSP3: Modeling Combinatorial Constrained Problems in Python.

Solver backend chosen at solve time

The compiled instance is passed to a backend. The guide names ACE as the default and Choco as the other constant 2009.00326 §6.1. Options are a string passed through to the solver. The guide does not say which backend to prefer for which constraint form 2009.00326 §6.1. The card for the same paper records bugs that the repository's tests report for both backends. Check a backend against the form you need before relying on it. Card: PyCSP3: Modeling Combinatorial Constrained Problems in Python.

When to use which

SituationUseWhy
Model and data should stay apart, and any supporting solver should read one standard filePython-embedded model compiled to XCSP3The workflow keeps modelling, data and solving as separate steps 2009.00326 §5.1
Every solution, or a set number of them, is needed from PythonSolver piloting with the solution count setCovered in 2009.00326 §6.2
An unsatisfiable model must be explainedUnsatisfiable-core extractionEnabled with extraction=True 2009.00326 §6.4
Choosing a solver or estimating run time for a model classNot answered by this sourceThe guide reports no run times or solver rankings 2009.00326 intro
Variables with real-valued or unbounded domainsOutside the stated scopeOnly finite integer and symbolic domains can be declared 2009.00326 §2.2

Implementation sketch

Language-agnostic outline of the common core. The steps follow the guide's workflow; the names are placeholders.

Pseudocode
# Declare each unknown with a finite domain: range, set or symbols  [§2.2]
variables = declare_variables(domains)

# Post rules that every solution must satisfy; calls may repeat  [§2.2]
post_constraints(rules)

# Optionally name one quantity to minimise or maximise  [§2.3]
set_objective(term)

# Compile model and data into a standard instance file  [§5.1]
instance = compile_model(model_file, data_file)

# Run a backend on the instance and read its status  [§5.2] [§6.1]
status = run_solver(instance, backend="ACE")

# Read values only when the status reports an answer  [§5.2]
if status in {SAT, OPTIMUM}:
    answers = read_values(variables)

Status values in the guide are UNSAT, SAT, OPTIMUM, UNKNOWN and CORE 2009.00326 §5.2.

Contradictions

Papers

Source and license

Compiled from the papers listed on this page, all published under CC BY, CC BY-SA or CC0, with citations. See each paper's page for its authors and license.