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

MiniZinc Assign Different Domain to Each Var in Array

I have an array: array[backpacks] of int: capacity specifying the capacity of each backpack. Now I want to create an array of variables which the constraint solver will have to satisfy. I want each variable to take values in domain 1..capacity where…
Silver
  • 1,327
  • 12
  • 24
0
votes
0 answers

Formulating mapping constraint(gecode)

I need to express a constraint for 2 integer Arrays of the same size x_i = x_j => y_i = y_j in other words, there is an integer function such x = f(y) Is there any solutions for it?
Solon
  • 362
  • 1
  • 13
0
votes
1 answer

CPLEX OPL: Counting values between two decision variables

The situation is as follows: I am creating a daily schedule for a workplace. Each day is divided into timeslots, and at each timeslot I know how many employees must be present. The schedule is created using two integer decision variables that…
TracedWill
  • 13
  • 7
0
votes
0 answers

Generating all possible combinations with given constraint for Nonogram puzzle (Java)

My problem is that i have to generate all possible combinations for rows/columns when I have a constraint. Lets say a have a nonogram puzzle and its row has size of 40. And I have constraints B,11,G,5,B,9 I have to follow a constraints: there is…
0
votes
1 answer

Minizinc modelling: Vars as coordinate sets

I am modelling a constraint satisfaction program in minizinc where the solution is an assignment of points on a 3D grid. One of the constraints is that only one point can occupy any given position, so the points must be pairwise different in at…
Tall Man
  • 13
  • 3
0
votes
1 answer

Java Choco solver error (IntVar read as Int)

I'm trying to use java choco solver, a CP solver, to color a graph. However i can't seem to get it to work. Even the code in the tutorial doesn't work: int n = 8; Model model = new Model(n + "-queens problem"); IntVar[] vars = new…
0
votes
1 answer

Find Constraint network - arc-consistency

I have a question about an arc consistency network example. its nothing with code. i have a network R with Variables X = {x1, x2, x3, x4, x5, x6, x7, x8} and Domains D = {1,2,3,4}. This are my constraints: I have the solution fromy my professor.…
Torben G
  • 750
  • 2
  • 11
  • 33
0
votes
0 answers

Predict data values given history and constraints

If I have data series and a set of constraints and want to predict the most likely values, what is the right algorithm or approach? For example, given the data table as follows: The first three rows illustrate typical data values. Imagine we have…
Tyler Durden
  • 11,156
  • 9
  • 64
  • 126
0
votes
1 answer

How to model special set constraints using Choco solver framework for Java

I'm having problems modelling a problem and solving it with Choco-solver in Java, and I am not that familiar with constraint programming to begin with, but have been tasked to make a seating app for conferences where: Each table must have a minimum…
Ceiku
  • 33
  • 6
0
votes
2 answers

Represent a business rule as a constraint model to find the solution set

In my enterprise application I have business rules like : ((AMOUNT < 20000.00) || ((AMOUNT >= 20000.00) && (RISKEXPOSURE == 'N'))) (ind = A1 || ind = A2 || ind = A3 || ind = S1 || ind = S2 || ind = S9) The rule, as you can see, is made of business…
ssdimmanuel
  • 448
  • 10
  • 29
0
votes
1 answer

Stuck making a Tetris solver in Minizinc

I'm trying to implement a Tetris solver in Minizinc, which is also known as the "packing" problem I suppose. I'm brand new to Minizinc and have barely any idea what I'm doing, but I'm currently stuck on a particular constraint in my code. I am…
0
votes
1 answer

Model suggestion for graph for Constraing Programing solver (gecode)

Problem : Given a labeled(1..n) undirected graph, create a model in Gecode for finding a supergraph with a given sequence degree: Difficulties: the main difficulty is to find fancy model to accurately express degrees over it: Why not Adjacency…
Solon
  • 362
  • 1
  • 13
0
votes
2 answers

How to modify programmatically constraints of UIButton

I have 2 buttons with different constraints write in the storyboard. In my code, I have to tell my first button to take the same constraint of the second button (height, width, and position) but I do not know how to do this without necessarily…
0
votes
1 answer

TSPTW with real road distance

Is it possible to solve asymmetric -travelling salesman problem with time window (with the real road distances) with OptaPlanner or jsprit?
0
votes
0 answers

n-queens with no 3 queens on same line

I am trying to generate a n-queen instances with a more stronger condition such that no 3 queens are on the same line. This is, if (r0, c0), (r1, c1), (r2, c2) are three unique positions of queens, then (c0 - c1) * (r0 - r2) != (c0 - c2) * (r0 -…
rnbguy
  • 1,369
  • 1
  • 10
  • 28