Questions tagged [constraint-programming]

A constraint network is defined by a triplet , where X is a set of variables, C is a set of constraints, and D a domain for X (i.e. a mapping from variables to sets of values). The constraint satisfaction problem (CSP) is the question of deciding whether a constraint network has a solution or not.

Constraint programming is a form of declarative programming. Constraints specify the desired properties of a solution, not a sequence of steps to execute.

A constraint satisfaction problem (CSP) is defined by a triplet <X,C,D>, where X is a set of variables, C is a set of constraints, and D a domain for X (i.e. a mapping from variables to sets of values). A CSP is called consistent if it has a solution.

Constraint programming blends in naturally with logic programming, since logic programming can in fact be regarded as a special form of constraint programming, where the domain is the set of Herbrand terms. When constraint programming is hosted by a logic programming language, it is called constraint logic programming and abbreviated as CLP.

The notion CLP(X) is used to refer to constraint logic programming over the domain X. The following instances are of particular relevance:

  • CLP(FD): reasoning over integers (see )
  • CLP(B): reasoning over Boolean variables (see )
  • CLP(Q): reasoning over rational numbers (see )
  • CLP(R): reasoning over real numbers or an approximation (see ).

All widely used Prolog systems (see ) ship with several constraint solvers, which are available either as built-in predicates or provided by libraries.

More information:

https://en.wikipedia.org/wiki/Constraint_programming

763 questions
0
votes
1 answer

How can i add an array of values to Google ortools versus a lower and upper bound?

In the documentation and all examples I can find... in terms of nurse scheduling at least, everyone just declares shift values within the search space of {1,4} lets say for shift 1,2,3,4.... solver = pywrapcp.Solver("schedule_shifts") num_nurses…
0
votes
1 answer

Domain Maximum - Choco solver

I'm using choco solver in Java. How can I get the maximum value of a domain? For example here is my domain: IntVar gisement_courant = model.intVar("Gisement courant", 5, 10); How can I get the maximum value of the domain? (Here the max is 10)
0
votes
1 answer

Cannot access decision variables using the C++ API for ILOG's CP

Ok I've spent the last 2 hours trying to make this work but I've run out of ideas. I have developed an OPL model just like the examples shipped with ILOG. What I'm doing is that I load the dataset + the model through a C++ interface program and what…
Greg K.
  • 686
  • 1
  • 5
  • 18
0
votes
1 answer

Increment an IntVar after condition

I'm using the choco solver to solve my constraint problem. Is it possible in Choco to increment an IntVar after a condition like model.ifThen?
0
votes
1 answer

How to suspend in ECLiPSe CLP until full list is instantiated?

ECLiPSe CLP has a built-in predicate suspend(+Goal, +Prio, +CondList) whereby CondList often is of the form X -> inst. But how can you suspend until a whole list is instantiated? If you do List -> inst, it will succeed from the moment one element is…
lavra
  • 11
0
votes
0 answers

make display matrix prolog tkeclipse

I am new to prolog and want to generate a display matrix from the below prolog code as given in the image The image below is generated from the given prolog code using tkEclipse (Eclipse for prolog) Following is the code of constraint…
Sohail
  • 587
  • 7
  • 25
0
votes
1 answer

typical educational constraint processing examples

I'm writing a course describing several topics of Artificial Intelligence. Currently I'm working on the "Constraint Processing" part. To illustrate constraint processing I would like to include a simple example. This examples should have the…
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
0
votes
0 answers

TSP/Optimization/CSP Algorithm

I am dealing with a challenge that is similar to the Traveling Salesman Problem but with a degree of Optimization and Constraint Satisfaction. The algorithm has as input the following variables: A set of points, where each point object has the…
0
votes
1 answer

Colored squares puzzle with Numberjack

I'm going crazy with this problem that I have to solve with Numberjack, that is a library in python for CSP. We have n x m squares with colored sides. These squares must be arranged in a n x m grid in such a way that the squares' adjacent sides are…
0
votes
0 answers

Optimization results different when running script on Matlab 2016b vs 2017b

I have a constrained optimization problem that I attempt to solve in Matlab. I find however that when I run the solver with Matlab 2016b the results are different than when I run it on a different computer with Matlab 2017b. I find it weird that…
WJA
  • 6,676
  • 16
  • 85
  • 152
0
votes
1 answer

how to add constraint in Pulp BinPacking such that two items are not assigned in same bag

I'm using this code and want to add a constraint such that say item a and b are not assigned in the same bag
0
votes
1 answer

Tetris-style divisions of Square (NxN) boards

When I was a child, I had a square board tetris puzzle, and the instruction said there are >15 thousand solutions. I've always wondered how they counted the solutions, and I'd like to replicate that. So I would like to search for divisions of NxN…
h2kyeong
  • 447
  • 3
  • 13
0
votes
1 answer

What is an instance of Option Type at parsing time?

About option types, the specification of Minizinc (sec. 6.6.3) says: Overview. Option types defined using the opt type constructor, define types that may or may not be there. They are similar to Maybe types of Haskell implicity adding a new value…
Patrick Trentin
  • 7,126
  • 3
  • 23
  • 40
0
votes
0 answers

NullPointerException when adding constraint with choco on eclipse

i'm having a problem using choco on eclipse , i tried to add a constraint and i got a nullPointerException can anyone explain to me ? public static void main(String[] args ) { int n=8; CPModel m=new CPModel(); IntegerVariable[] cells =…
AbdallahJg
  • 69
  • 7
0
votes
2 answers

Complex variable in choco

How to check in Choco if a complex variable satisfies the constraints? For example, if I have the following list of configurations: int[][] configurations = new int[][] { {20, 24, 10, 3, 4}, {20, 13, 1, 3, 4}}; where config1 =…
Andrei
  • 7,509
  • 7
  • 32
  • 63