我正在做一些实验来比较 Sicstus Prolog 中的不同标签启发式。
但我不断进入“资源错误:内存不足”。
我很确定我在测试代码中做错了什么。
以下代码将复制我的问题:
:- use_module(library(clpfd)).
:- use_module(library(lists)).
atest( R, C ):-
X is R * C,
length( M, X),
domain( M, 0, X),
all_distinct( M ),
statistics(walltime, [_,_SinceLast]),
labeling( [],M ),
statistics(walltime, [_,SinceLast]),
write('Labeling time: '), write(SinceLast),write('ms'),nl.
% Testcode for looping through alot of variations and run one test for each variant
t1:-
Cm = 1000,
Cr = 1000,
(
for(C,0, Cm),
param([Cm,Cr])
do
(
for(R, 0, Cr ),
param([C])
do
atest( C, R )
)
).
调用 t1 谓词后不久,我收到“资源错误:内存不足”异常。
我想我应该在调用 atest 释放资源后做点什么?
另外:这是测量标记时间的正确方法吗?有没有更好的方法来做到这一点?