*snip* > > > In GNUProlog, I get possibilities for the value of the variables by > > simply running the file I attached. Than I can modify the file with one > > of the resulting values until all variables have a value. > > How do you achieve this in GNUProlog, it's most likely very similar. > > > I must write a java-program that generates the input to ECLiPSe, get the > > output (the possible values for the variables) and use that values to > > generate a new input and so on , until I've a value for every variable. > If what you are hoping to achieve by finding a value for every variable, is to find values that satisfy all the constraints then there is no need to write a Java program and genereate new input. You can find the values much more simply within ECLiPSe (or GNUProlog for that matter). e.g. Here is the standard SEND+MORE=MONEY example :-lib(ic). send(Digits):- Digits=[S,E,N,D,M,O,R,Y], % Give initial domains to variable Digits :: [0..9], % setup constraints on variables alldifferent(Digits), S #\=0, M #\= 0, S*1000 + E*100 + N*10 + D + M*1000 + O*100 + R*10 + E #= M*10000 + O*1000 + N*100 + E*10 + Y, % search for solution values labeling(Digits). As you can see there are 3 stages to the problem. 1) Declare your problem variables and give them initial domains. 2) Setup the constraints of the problem 3) Search for a valid assignement of values to your variables. Running the query "send(Digits)" gives the following valid assignment ?- send(Digits). Digits = [9, 5, 6, 7, 1, 0, 8, 2] Yes (0.00s cpu, solution 1, maybe more) asking for more solutions says "no", since the above solution is unique. The above example uses the labeling/1 predicate to find valid values for the variabels, ECLiPSe has a number of more general search mechanisms aswell (e.g. in the library "ic_search"). These are explained in detail in the ECLiPSe documentation. Hope that helps. Andrew SadlerReceived on Fri Jan 14 11:34:36 2005
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:33 PM GMT GMT