clp

Representing logical disjunctions in Constraint Handling Rules

夙愿已清 提交于 2019-12-25 06:26:49
问题 I am writing a constraint solver in Prolog that implements a simple logical formula: "(alive(A) and animal(A)) iff (awake(A) or asleep(A))" . I found one way to implement it in Constraint Handling Rules, but it is much more verbose than the original formula: :- use_module(library(chr)). :- chr_constraint is_true/1. is_true(A) \ is_true(A) <=> true. is_true(alive(A)),is_true(animal(A)) ==> is_true(awake(A));is_true(asleep(A)). is_true(awake(A)) ==> is_true(animal(A)),is_true(alive(A)). is_true

SWI Prolog CLP(FD) scheduling

巧了我就是萌 提交于 2019-12-24 13:26:32
问题 I am solving a scheduling task in SWI Prolog using the CLPFD library. Since it is the first time I solve something more serious than was the sendmory I probably need some good advices from more experienced users. Let me briefly describe the domain/the task. Domain I have a "calendar" for a month. Everyday there are 2 for the whole day, 2 for the whole night (long 12h service). There are also, only Mon-Fri 10 more workers for 8 hours (short service). The domain constraints are, obviously:

Solve Instant Insanity in PROLOG with CLP

不羁的心 提交于 2019-12-23 15:51:54
问题 This is the game I've managed to generate the problem with 4 colours and 4 cubes randomly mixed and following the colour scheme suggested in the link. So, the goal is to generate the possible solutions to the problem using clpfd . The main principle is basic, the same face for all 4 cubes must be different. Used all_different/2 on 4 lists, each of them containing the respective side of the "tower" composed by 4 faces. So far, so good. Now I must assure that the final result is a composition

Error of running an executable file from Python subprosess

旧时模样 提交于 2019-12-14 02:24:47
问题 I am trying to run an executable file (a linear programming solver CLP.exe) from Python 3.5. Import subprocess exeFile = " C:\\MyPath\\CLP.exe" arg1 = "C:\\Temp\\LpModel.mps" arg2 = "-max" arg3 = " -dualSimplex" arg4 = " -printi all" arg5 = "-solution t solutionFile.txt" subprocess.check_output([exeFile, arg1, arg2, arg3, arg4, arg5], stderr=subprocess.STDOUT, shell=False) When I run the python file in Eclipse PyDev, I can see the results in Eclipse console. But, no solution results are saved

Verify_attributes in SICStus Prolog

你。 提交于 2019-12-10 15:26:53
问题 Attribute variables permit to extend unification. The following is about arcane details of the interface. Let's cut right to the chase! In sicstus-prolog library(atts) provides predicates for using attributed variables. I think I get what the SICStus Prolog User's Manual page for library(atts) says, except for one detail about verify_attributes(-Var, +Value, -Goals) : [...] verify_attributes/3 is called before Var has actually been bound to Value. If it fails, the unification is deemed to

How to validate commutativity involving the dif/2 constraint?

前提是你 提交于 2019-12-08 19:14:02
问题 There is a lot of hype around the dif/2 constraint, especially as a rescue for some non-declarativity of (\=)/2 and (\==)/2. This non-declarativity is often characterized as non-monotonicity and examples of non-communtativity are given. But what would be the means to test whether test cases involving dif/2 are commutative. Here is a meta explanation what I want to do: I make a commutativity test, and I want to probe that both variants give the same result: ?- A, B. -- versus -- ?- B, A. So