constraint-programming

Convert Boolean FlatZinc to CNF DIMACS

大城市里の小女人 提交于 2019-12-21 04:43:15
问题 To solve a set of Boolean equations, I am experimenting with the Constraint-Programming Solver MiniZinc using the following input: % Solve system of Brent's equations modulo 2 % Matrix dimensions int: aRows = 3; int: aCols = 3; int: bCols = 3; int: noOfProducts = 23; % Dependent parameters int: bRows = aCols; int: cRows = aRows; int: cCols = bCols; set of int: products = 1..noOfProducts; % Corefficients are stored in arrays array[1..aRows, 1..aCols, products] of var bool: A; array[1..bRows, 1

Z3 Theorem Prover: Pythagorean Theorem (Non-Linear Artithmetic)

て烟熏妆下的殇ゞ 提交于 2019-12-18 07:00:34
问题 Wherefore? The usecase context in which my problem occures I define 3 random item of a triangle. Microsoft Z3 should output: Are the constraints satisfiabe or are there invalid input values? A model for all the other triangle items where all the variables are assigned to concrete values. In order to constrain the items i need to assert triangle equalities - i wanted to start out with the Pythagorean Theorem ( (h_c² + p² = b²) ^ (h_c² + q² = a²) ). The Problem I know that Microsoft Z3 has only

Ordering lists with constraint logic programming

自古美人都是妖i 提交于 2019-12-17 16:35:24
问题 I was wondering if anyone could help me with this problem: I have to order a list using Prolog with Constraing Logic Programming and I must do it with the more efficient way I can. So the main predicate I have defined is the next one: order(Xs,Ys) :- same_length(Xs,Ys), /* To determine the list Ys with the Xs' length */ perm(Xs,Ys), /* Permutation */ ordered(Ys), /* Is Ys ordered? */ ! . The implementation of each of the previous auxiliary predicates is as follows: same_length(Xs,Ys) :-

Duplicate Symbol Linker Error (C++ help)

五迷三道 提交于 2019-12-14 00:50:34
问题 I'm learning some CSP (constraint satisfaction) theory stuff right now, and am using this library to parse XML files. I'm using Xcode as an IDE. My program compiles fine, but when it goes to link the files, I get a duplicate symbol error with the XMLParser_libxml2.hh file. My files are separated as such: A class header file that includes the XMLParser file above A class implementation file that include the class header file A main file that includes the class header file The duplicate symbol

Modeling tennis matchups with Choco (CSP)

£可爱£侵袭症+ 提交于 2019-12-13 07:15:09
问题 I am trying to model a problem with Choco to get the combinations of possible matchups in a tennis event (or any sport). The way I am trying to do it I have the following: // Set of timeslots when the event is held (i.e. 10am-10pm) int nTimeslots = 12; // Courts available: court #1, #2 and #3 int nCourts = 3; String[] players = { "Novak", "Andy", "Roger", "Stan", "Rafel", "Kei", "Tomas", "David" }; int nPlayers = players.length; // Timeslots when each player cannot play for whatever reason

How to use constraint programming for optimizing shopping baskets?

耗尽温柔 提交于 2019-12-12 08:54:31
问题 I have a list of items I want to buy. The items are offered by different shops and different prices. The shops have individual delivery costs. I'm looking for an optimal shopping strategy (and a java library supporting it) to purchase all of the items with a minimal total price. Example: Item1 is offered at Shop1 for $100, at Shop2 for $111. Item2 is offered at Shop1 for $90, at Shop2 for $85. Delivery cost of Shop1: $10 if total order < $150; $0 otherwise Delivery cost of Shop2: $5 if total

Getting all solutions in Google or-tools

眉间皱痕 提交于 2019-12-12 03:37:34
问题 I have a linear problem of finding all solutions that meet all constraints. For example my variables are = [0.323, 0.123, 1.32, 6.3...] Is it possible to get for example top 100 solutions sorted by fitness(maximization/minimization) function? 回答1: In a continuous LP enumerating different solutions is a difficult concept. E.g. consider max x, s.t. x <= 1 . Obviously x=1 , x=0.99999 are solutions and so are the infinite number of solutions in between. We could enumerate "corner solutions" (or

Puzzle taken from Gardner

∥☆過路亽.° 提交于 2019-12-11 01:52:17
问题 I'm trying to solve the following puzzle in Prolog: Ten cells numbered 0,...,9 inscribe a 10-digit number such that each cell, say i, indicates the total number of occurrences of the digit i in this number. Find this number. The answer is 6210001000. This is what I wrote in Prolog but I'm stuck, I think there is something wrong with my ten_digit predicate: %count: used to count number of occurrence of an element in a list count(_,[],0). count(X,[X|T],N) :- count(X,T,N2), N is 1 + N2. count(X,

Why can't my rule solve for X in a simple algebraic equation?

不问归期 提交于 2019-12-11 00:33:37
问题 I'm new to Prolog, so please be gentle. This is my rule: solve(X) :- A = B, A is (7 * (X - 2)), B is (3 * (X + 4)). Obviously, the correct answer here is 6.5 . If I give that to Prolog, it confirms: | ?- solve(6.5). yes However, if I ask Prolog to do the dirty work, it throws an error: | ?- solve(X). uncaught exception: error(instantiation_error,(is)/2) I fully concede that whatever is going on here is due to my misunderstanding of Prolog. Can someone explain to me how I might get this to

How to add domain variable to global_cardinality?

青春壹個敷衍的年華 提交于 2019-12-10 18:37:21
问题 I'm trying to add a constraint global_cardinality to my program and in the manual of SICStus Prolog is written: global_cardinality(+Xs,+Vals) global_cardinality(+Xs,+Vals,+Options) where Xs = [X1,...,Xd] is a list of integers or domain variables, and Vals = [K1-V1,...,Kn-Vn] is a list of pairs where each key Ki is a unique integer and Vi is a domain variable or an integer. True if every element of Xs is equal to some key and for each pair Ki-Vi, exactly Vi elements of Xs are equal to Ki. Now