Hello,
we have problem with java-prolog interface. If we use our very simple modul "mymodul1.pl" than ciao fall down.
If we use a standard predicate (eg. is/2) without using modules than program runs ok.
our preticate:
?- pred(X).
PLTerm t = new PLStructure("pred",new PLTerm[] {currentSolution});
-> ciaoengine.exe falls down
Console:
PLSocketReader: Socket broken
PLMultithreadSocketReader: Socket broken
?- is(X,2).
PLTerm t = new PLStructure("is",new PLTerm[] {currentSolution, new PLInteger(2)});
-> ok.
Console:
Solution for: is(_0{2}, 2) is 2
There are no more solutions
We found also a problem in executing example "
queens.java". If we don't change dimension and click on "Next sol." button fourtimes then it appears an error and program terminates.
Console:
PLMultithreadSocketReader: Socket broken
Thank You very much for your suggestion!
Ondrej Kohut, Marek Mensik
mymodul1.pl file:
--------------------------------------------------------------------------------
:- module(mymodul1, [pred/1]).
pred(1).
pred(5).
pred(7).
--------------------------------------------------------------------------------
MainPl.java file:
--------------------------------------------------------------------------------
import ciao.CiaoExecutor
;
import CiaoJava.*;
public class MainPl {
private static PLConnection plServer = null;
public static void main(String[] args0) {
System.out.println("Start...");
try {
String argv []= {"i:\\prog\\ciao-1.10p5Win32\\Win32\\bin\\ciaoengine.exe", "-C", "-b", "i:\\prog\\ciao-1.10p5Win32\\library\\javall\\plserver.cpx
"};
plServer = new PLConnection(argv);
} catch (Exception e) {
System.err.println("Problems starting java server: " + e);
e.printStackTrace();
System.exit(1);
}
PLVariable currentSolution = new PLVariable();
PLTerm t = new PLStructure("pred",new PLTerm[] {currentSolution});
//PLTerm t = new PLStructure("is",new PLTerm[] {currentSolution, new PLInteger(2)});
PLGoal goal = new PLGoal(plServer,t);
try {
goal.useModule("mymodul1");
goal.query();
while (goal.nextSolution() != null)
System.out.println("Solution for: " + t + " is "+
currentSolution.getBinding());
System.out.println("There are no more solutions");
} catch (Exception e) {
System.err.println("Problems launching goal: " + e);
System.exit(1);
}
try {
plServer.stop();
System.exit(0);
} catch (Exception e) {
System.err.println("Problems stopping Prolog server: " + e);
System.exit(1);
}
}
}
--------------------------------------------------------------------------------
--
Marek Mensik
~~~~~~~~~~~~~~~~~~~~~~~~
Student
Department of Computer Science