此序言优化解决方案出了什么问题? [英] Whats wrong with this prolog optimization solution?

查看:125
本文介绍了此序言优化解决方案出了什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

solve(Amounts) :-
    Total = 1505,
    Prices = [215, 275, 335, 355, 420, 580],

    length(Prices, N),
    length(Amounts, N),
    Amounts :: 0..Total//min(Prices),
    Amounts * Prices #= Total,

    labeling(Amounts).

推荐答案

没有问题.此示例来自 http://eclipseclp.org/examples/xkcd287.ecl.txt,并且如果您没有省略该行

There is nothing wrong with it. It is the example from http://eclipseclp.org/examples/xkcd287.ecl.txt, and if you hadn't omitted the line

:- lib(ic).

加载间隔约束求解器,它将正常工作在 ECLiPSe 序言中.

which loads the interval constraint solver, it would work just fine in ECLiPSe Prolog.

这篇关于此序言优化解决方案出了什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆