constraint-programming

Given a list of numbers, find all matrices such that each column and row sum up to 264

不打扰是莪最后的温柔 提交于 2020-01-03 08:42:17
问题 Let's say I have a list of 16 numbers. With these 16 numbers I can create different 4x4 matrices. I'd like to find all 4x4 matrices where each element in the list is used once, and where the sum of each row and each colum is equal to 264. First I find all combination of elements within the list that sum up to 264 numbers = [11, 16, 18, 19, 61, 66, 68, 69, 81, 86, 88, 89, 91, 96, 98, 99] candidates = [] result = [x for x in itertools.combinations(numbers, 4) if sum(x) == 264] result becomes a

Prolog Constraint Programing finding even and odd numbers

拟墨画扇 提交于 2020-01-02 15:24:06
问题 I need to create a predicate: applyConstraints(L) That applies constraints to the variables in L such that no two contiguous elements in L are both odd or even how can I do that? With a fixed size L it's simple but what about a variable size L? I need that to be done using sicstus-prolog clpfd library. 回答1: Inspired by @MatsCarlsson's version, I tried to minimize the number of constrained variables involved: applyConstraints(Xs) :- S #\= R, applyConstraints(Xs, S, R). applyConstraints([], _,

Constraint Programming: Scheduling with multiple workers

烂漫一生 提交于 2020-01-02 07:03:17
问题 I'm new to constraint programming. I imagine this is an easy problem but I can't wrap my head around it. Here's the problem: We have multiple machines (N), each with a limited resource (let's say memory, and it can be the same for all machines.) We have T tasks, each with a duration and each requiring some amount of the resource. A machine can work on multiple tasks at the same time as long as its resource isn't exceeded. A task cannot be split among machines and it has to be done in one shot

Optoplanner/jsprit TSPTW with real road distance

我们两清 提交于 2019-12-25 09:17:50
问题 Is it possible to solve asymmetric -travelling sales man problem with time window (with the real road distances) with optoplanner or jsprit? if you are able to provide any documentation or pointer in this regard that is highly appreciated. thanks. 回答1: With OptaPlanner, there is a Vehicle Routing Problem example that supports asymmetric distances and time windows. So just give it only 1 vehicle and you got the Traveling Sales Man variant of that. Look for the code in this directory: see

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

柔情痞子 提交于 2019-12-25 09:02:18
问题 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 expressions ex: (AMOUNT < 20000.00) . The rules could have any number of business conditions joined by boolean operators && and || . The identifiers AMOUNT , RISKEXPOSURE and ind are the business variables (which could vary from 1 to n based on the

Solve extremely simple equation in prolog: A = B + C?

♀尐吖头ヾ 提交于 2019-12-23 14:42:50
问题 I have an extremely simple equation that I would like to be able to solve in prolog: A = B + C I'd like to be able to write a predicate expressing this relation, that can handle any one of the arguments not being instantiated. There is no need to generalize to more complex relations or equations. myEquation(A, B, C) :- ...something... That I could call with the following semantics: myEquation(A,1,2). > A = 3. myEquation(3,B,2). > B = 1. myEquation(3,1,C). > C = 2. Any ideas? Working with

Solve extremely simple equation in prolog: A = B + C?

℡╲_俬逩灬. 提交于 2019-12-23 14:40:59
问题 I have an extremely simple equation that I would like to be able to solve in prolog: A = B + C I'd like to be able to write a predicate expressing this relation, that can handle any one of the arguments not being instantiated. There is no need to generalize to more complex relations or equations. myEquation(A, B, C) :- ...something... That I could call with the following semantics: myEquation(A,1,2). > A = 3. myEquation(3,B,2). > B = 1. myEquation(3,1,C). > C = 2. Any ideas? Working with

Does OptaPlanner support optimizations and constraints on continuous variables?

喜你入骨 提交于 2019-12-23 10:26:14
问题 I'm reading contradictory things in the documentation. On one hand, this passage seems to indicate that continuous planning variables are possible: A planning value range is the set of possible planning values for a planning variable. This set can be a discrete (for example row 1, 2, 3 or 4) or continuous (for example any double between 0.0 and 1.0). On the other hand, when defining a Planning Variable, you must specify a ValueRangeProvider annotation on a field to use for the value set: The

Expressing setup time with cumulatives

主宰稳场 提交于 2019-12-23 09:23:27
问题 There are many families of scheduling problems. I'm looking into a problem where I have families of jobs/tasks where the transition from one family to another family require reconfiguring the machine (setup time). I'm using cumulatives[2/3] to solve this problem, but I feel unsure how the setup time could be expressed. In this small example I have 10 tasks belonging to 3 different families. Any task can run on any machine, but a switch from one task in one family to another task in another

Projection of solutions

给你一囗甜甜゛ 提交于 2019-12-22 10:48:08
问题 Is there a possibility to tell MiniZinc to project solutions on a subset of the set of variables? Or is there any other way to enumerate all solutions that are unique wrt to evaluation of some subset of variables? I have tried to use FlatZinc annotations directly in MiniZinc, but it does not work, since the flattening process adds more defines_var annotations and my annotations are ignored. 回答1: I tried the following model in MiniZinc 2.0 (https://www.minizinc.org/2.0/index.html) and this