ECLiPSe Code Samples
This is a still somewhat random collection of ECLiPSe code and examples:
Simple Problems To Get Started
- Subset-sum Problem
A small program to solve the problem from this
- Two versions of the famous SEND+MORE=MONEY puzzle, and a more general solver for this kind of puzzle.
- Magic Hexagon
- Another puzzle with numbers and how to avoid symmetric solutions.
- Magic Sequences
- Construct magic sequences.
- Magic Squares
- Construct magic squares.
- Golomb rulers
- Construction of optimal Golomb rulers.
- Lewis Carrol's classical zebra puzzle.
- Reconstructing a pattern from sampling data.
- The unavoidable N-queens problem, and a more scalable version with different search strategies.
- Reasoning about the truth of statements.
- Popular Japanese Puzzle. (standard model, unusual model)
- Binary sudoku
- Only zeros and ones, as described here
- Steiner triplets
- A problems with sets.
- N-Fractions Puzzle
- The n-fractions puzzle, problem 41 in CSPLib.
- Crack the Code
- Mastermind-style problem, set as Challenge Sep-2019 by the Decision Management Community.
- Integer Programming Puzzles
- Martin Chlond's collections of puzzles, good for learning.
- Solution to Enigmas from New Scientist magazine, mixed difficulties.
- Doug Edmunds' CLP Puzzles page
- Collection of zebra-style puzzles.
- Sandwich Sudoku
- The "Sandwich Sudoku" puzzle, featured in The Guardian, May 2019.
- Solitaire Battleships
- The Solitaire Battleships puzzle (1), also problem 114 in CSPLib.
- Another tiling puzzle, also known as divide-by-box (1, 2).
- Domino tiling problem
- An interesting modelling exercise.
- Solving Nonograms ( 1, 3, 5, 6). Short solution using gfd (Gecode solver interface), and alternative solution using lib(ic) with a regular expression constraint based on lib(propia).
- Crowded chessboard
- Place 51 pieces on a chessboard (results)
- Non-dominating Queens
- Using a boolean matrix model, and a version with symmetry breaking.
- Square-Sum Chains
- Construct integer sequences where a certain condition must hold between consecutive numbers.
Planning and Scheduling
- Bin Packing
- Solving bin-packing problems using a global constraint.
- Knapsack Problem
- Different solutions to several variants of the knapsack problem.
- Assignment with Slots and Capacities
- We give four solutions: a linear programming solution, a finite-domain solution using the same model, a hybrid solution using both, and a finite-domain solution with a different model.
- Jobshop Scheduling
- Using propagation and heuristics to solve the Jobshop Scheduling Problem.
- Warehouse location
- The warehouse location problem from van Hentenryck's book.
- Transport, generic version using arrays
- A small transportation problem, solved with lib(eplex).
- The bridge scheduling problem from van Hentenryck's book.
- Square tiling
- Covering a square with smaller squares of different sizes.
- Scheduling players for a golf tournament (uses sets).
- Computing a staff roster (problem statement).
- Small airline crew scheduling example.
- ECLiPSe models at CSPLib
- CSPLib is a library of test problems for constraint solvers.
- Various ECLiPSe models
- ECLiPSe page maintained by Hakan Kjellerstrand.
- ECLiPSe at Stackoverflow
- ECLiPSe-related answers at Stackoverflow.
Programming Tricks and Techniques
- Sudoku with tracing
- How to use data-driven facilities to trace progress during search.
Running these examplesIf you have a recent version of ECLiPSe, you can compile the examples directly from this web site as follows: