简体   繁体   English

Java的SWI-Prolog接口中的CLPFD

[英]CLPFD in SWI-Prolog interface with Java

I am trying to use JPL to Pass a Query to SWI-Prolog(CLPFD) from Java. 我正在尝试使用JPL将查询从Java传递到SWI-Prolog(CLPFD)。 I get the Following Exception while running the program in Java. 在Java中运行程序时出现以下异常。

Query is = Arithmetic_Expression#=X*Y+X+1,[Y, X] ins 0..100500,Arithmetic_Expression in 1..5/10/12. 查询是= Arithmetic_Expression#= X * Y + X + 1,[Y,X] ins 0..100500,Arithmetic_Expression在1..5 / 10/12中。 Exception in thread "main" jpl.PrologException: PrologException: error(syntax_error(operator_expected), string('Arithmetic_Expression#=X*Y+X+1,[Y, X] ins 0..100500,Arithmetic_Expression in 1..5/10/12. ', 21)) at jpl.Query.get1(Query.java:336) at jpl.Query.getSubstWithNameVars(Query.java:390) at jpl.Util.textToTerm(Util.java:163) at jpl.Query.(Query.java:198) 线程“主”中的异常jpl.PrologException:PrologException:错误(语法错误(operator_expected),字符串('Arithmetic_Expression#= X * Y + X + 1,[Y,X] ins 0..100500,Arithmetic_Expression in 1..5于/ 10/12。',21))在jpl.Query.getSubstWithNameVars(Query.java:390)在jpl.Query.get1(Query.java:336)在jpl.Util.textToTerm(Util.java:163)在jpl.Query。(Query.java:198)

As you can see, My java Program is generating the Query as Union of Ranges from 1..5 / 10 / 12. But SWI-Prolog is taking it as 1..5/10/12. 如您所见,我的Java程序从1..5 / 10/12生成查询作为范围的联合。但是SWI-Prolog将其作为1..5 / 10/12。 Not sure why is this happening? 不知道为什么会这样吗? I guess this might be the reason for my error. 我想这可能是我出错的原因。 Could anyone help me with this error? 有人可以帮我解决这个错误吗?

I am appending / because in my Java Program on to Windows to generate the Query \\ will be given as '\\' and thus my Query is generated as 1..5/10/12. 我要附加/,因为在我的Java程序中,要在Windows上生成查询\\的情况下,它会以'\\'的形式给出,因此我的查询会以1..5 / 10/12的形式生成。

Why is this propogating to SWI-Prolog? 为什么要推广到SWI-Prolog?

The position of the error is the 21st character, thus 错误的位置是第21个字符,因此

Arithmetic_Expression#=X*Y+X+1,[Y, X] ins 0..100500,Arithmetic_Expression in 1..5/10/12.
123456789012345678901^^

Evidently, you have not stated use_module(library(clpfd)) , 显然,您尚未声明use_module(library(clpfd))

However, after that, the next error will be: 但是,此后,下一个错误将是:

ERROR: Domain error: `clpfd_domain' expected, found `1..5/10/12'

Not clear what you mean by /10/20 .In any case, I recommend you learn Prolog and clpfd first before using it from Java. 不清楚/10/20 10/20是什么意思。无论如何,我建议您先学习Prolog和clpfd,然后再从Java使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM