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

Example of arc consistency does not imply satisfiability

I've read that arc consistency does not imply satisfiability. The provided example was X in D ∧ Y in D ∧ X ≠ Y ∧ X = Y for domains D with more than one value. My understanding is that for each of the possible values of X (from D) there are values…
0
votes
1 answer

Allocating numbers (x1, x2, x3, ...) to each element in a list (a1, a2, a3, ...) so that a1/x1 is similar to a2/x2 and so on

Suppose I have a list of numbers = [3, 10, 20, 1, ...] How can I assign a number (x1, x2, x3, x4, ...) to each of the elements in the list, so that 3/x1 ~= 10/x2 ~= 20/x3 ~= 1/x4 = ... ? Edit: there are some restrictions on the numbers (x1, x2,…
0
votes
1 answer

Use IntVar as index of IntVar[] array in a constraint

I want to use the value of an IntVar as an index of another IntVar array in a constraint, using Choco Solver. I have an IntVar who contains the next task who follow the i-th task And I have another IntVar who contains the person assigned to a…
ingambe
  • 26
  • 3
0
votes
2 answers

Is there an example that uses the flexible job shop problem with CPLEX instead of CP?

I´m a beginner in CPLEX and I want to ask if there is any example available that modifies the flexible job shop example in a way that it can be solved with CPLEX and not with CP?
Alex
  • 71
  • 6
0
votes
1 answer

Constraining domain for variable through list

I have a list defined in one part of my program as people([tom,betty,sue,fred,charles,chay]) I would like to constraint a variable to be N values in this domain. Something like : setup(GroupCount) :- length(Group, GroupCount), people(X), …
ZM-
  • 94
  • 1
  • 9
0
votes
1 answer

How to put two elements in the same sequence?

I want to force the flexible job shop example model in CP Optimizer that if a specific mode/element is put in a sequence the successor has to be put also in the same sequence which means in this case that both have to be done on the same machine.…
Alex
  • 71
  • 6
0
votes
0 answers

Prolog CLP(FD) Number of items in result

I'm now solving a scheduling problem and I'm a bit stuck on the way how to describe number or count of certain items in result. For example, the result is a list of numbers between 1..7 and I want to at least see or better to define constraints on…
Jan Drozen
  • 894
  • 2
  • 12
  • 28
0
votes
1 answer

'method' object is not sub scriptable in python

I am implementing Minimum Remaining Values of CSP in python.And I got some errors. I run with python3 and also with python2 interpreter . def select_unassigned_variable(assignments, csp): variables = [var for var in csp.nodes() …
Cecelia
  • 1
  • 6
0
votes
1 answer

How to fix "WARNING: Logging before InitGoogleLogging() is written to STDERR ..." error in Python (or-tools)?

I m trying to solve an optimisation problem using python 3.7.1, spider and or-tools. For the time being, I want to classify objects in 3 different classes using constraints. First, I tried to solve it using: #solver =…
Aurelien.M
  • 53
  • 1
  • 1
  • 9
0
votes
1 answer

Is it possible to deduce the tiles each player has just by viewing the tiles played for an entire Scrabble game?

Given as input the tiles used by each player for every turn and the tiles each player has left at the end of the game, disregarding the possibility of swapping all of the tiles for a turn, is it possible to deduce the tiles each player has for each…
crj11
  • 197
  • 7
0
votes
2 answers

Gecode: constraining integer variables using a float value

I use Gecode through its C++ API in a kind of learning context with positive and negative examples. In this context I have two BoolVarArray: positive_bags_ and negative_bags_. And what I want to do seems very simple: I want to constrain these bags…
Heleo
  • 25
  • 8
0
votes
1 answer

Having trouble understanding how to express real world problem to opensolver or minizinc for worker allocation

I am going to start off with that I am not well versed in Minizinc nor constraint programming, I have watched excel "solver" tutorials on youtube which I can understand, but I do not see how I can translate my issue into a excel solver-able…
0
votes
1 answer

How to get current time in CP when using Intervals for scheduling

I am trying to schedule tasks in different machines. These machines have dynamique available ressources, for example: machine 1: max capacity 4 core. At T=t1 => available CPU = 2 core; At T=t2 => available CPU = 1 core; Each interval has a fixed…
0
votes
1 answer

Backjumping, CSP, AIMA book

Context: backjumping is an optimization to vanilla backtracking. It reduces the search tree's branching factor by intelligently jumping back to a node which is the cause of the failure (instead of backtracking to the chronological parent). Chapter 5…
0
votes
1 answer

variable with condition in minizinc

I am converting the model in aimms to minizinc. In aimms, I have a variable defined as X with index domain (k,i), where i,s,t is index of set Hour Definition of X with indices i,s,t is: sum((s,t) | (s <= i) and (t >= i), Pick(s,k,t) +…