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
0 answers

Optimization in R for multiple variables

I want to solve an optimization problem in R; The dummy data for the same is given below. # Input Data DTM <- sample(1:30,10,replace=T) DIM <- rep(30,10) Price <- 100 - seq(0.4,1,length.out=10) # Variables that shall be changed to find optimal…
0
votes
2 answers

Python: slow nested for loop

I need to find out an optimal selection of media, based on certain constraints. I am doing it in FOUR nested for loop and since it would take about O(n^4) iterations, it is slow. I had been trying to make it faster but it is still damn slow. My…
user1792899
0
votes
2 answers

Conditional contraints in linear programming for non boolean variables

Question 1 : x , y are integer non negative variables i have a condition - if x > 0 then y=0 Question 2 : a , b , c , d , e are integer non negative variables if any one of above > 0 then other 4 will be zero. How to formulate above…
0
votes
4 answers

Solving mutually recursive constraints in Prolog

I am attempting to solve some mutually recursive constraints with SWI-Prolog. These constraints are relatively simple, but querying any of these predicates leads to infinite recursion: %If X is an animal, then X is a bird or a mammal, and…
Anderson Green
  • 30,230
  • 67
  • 195
  • 328
0
votes
0 answers

difficulty with element method constraint programming

I'm having hard time regarding how to model a constraint. I'm trying to solve a transportation problem and one of the constraints is as follows: t[s[i]] >= t[i] + travelTime (i, s[i]) which t is the time at which node i is visited and s is the…
0
votes
1 answer

Solving an assignment with many preassignments

The problem I want to solve consists of about 800 tasks that have to be assigned to about 120 workers. The workers have to be qualified to do the task and only have a certain number of hours per week available. About 80% of the assignments are…
Dora
  • 47
  • 1
  • 8
0
votes
1 answer

Vehicle Routing Optimization with unspecified capacity of different items

I have a little different variant of vehicle route optimization problem. There are different items which are to be dropped at different stores. Each store require N items of amounts [a1, a2, ...., aN]. As we don't know how many stores will be there…
0
votes
1 answer

Optimization with three variables

I have an equation with three variables to different ranges for the variables f(x)= 150*x + 92*y + 41,1*z -> max subject to x > 0 & x < 600 x > 0 & x < 600 x+y+z <600 if x<200 or y<200 or x+y <200 -> z=0 I would like to find the maximum value for…
0
votes
1 answer

Choco solver constraint/variable definition

I'm trying to port a minizinc model in choco. I know how to define variables and other basic stuff but despite having read the tutorial and some code examples I've some trouble defining some non trivial constraints. Could someone give me some advice…
acco93
  • 128
  • 2
  • 11
0
votes
2 answers

Task scheduling on multiple facilities - cumulative 'var opt error'

I'm having trouble with an implementation of the following CP formulation (full formulation of the problem can be found here (page 4/16)) My implementation seems like code below, but I'm having struggle with following error: MiniZinc: type error:…
mrtn
  • 331
  • 2
  • 12
0
votes
1 answer

How to access solution for dual simplex solver?

I have an objective function with several hundreds of quadratic terms which I would like to minimize; in this case I try to minimize the absolute distance between several variables. So the structure of my problem looks like this (highly…
Cleb
  • 25,102
  • 20
  • 116
  • 151
0
votes
1 answer

How to map database values in objective function in Mixed Integer Programming using IBM Cplex?

I'm trying to model a student assignment probelm using cplex. I have student details in a access database (ex: student id and marks) I was able to obtain these values from db to .mod file using tuples. tuple stuType{ int id; int mark; } stuType…
Ann
  • 403
  • 2
  • 5
  • 17
0
votes
2 answers

How to terminate a Java process from a different one?

I am making a CSP solver that calculates all the combinatory solutions of a specific problem like this (briefly put): // Say we are in a Solver class public void solve() { // find solution... } // This would be in a Problem…
dabadaba
  • 9,064
  • 21
  • 85
  • 155
0
votes
1 answer

setting image in the center of a table view cell using constraintsWithVisualFormat

I am trying to put an image in the center of a table view cell using constraints programmatically. I have taken an working example from the internet and updated it to…
asheyla
  • 3,175
  • 5
  • 18
  • 34
0
votes
0 answers

Choco continue with intermediate solution

Every once in a while my building time jumps from 5s to around 200. And sometimes I don't get any solution even though I got around 17 in the same time with the same data. Is it possible to stop the solver, check if there has been a solution and if…
Dora
  • 47
  • 1
  • 8