本文介绍了如何在ECLIPSE CLP或Prolog中实现此MP问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将此总结作为目标和约束来实现(1-6)谁能帮我实现这些方法?

I want to implement this Summations as Objective and Constraints(1-6)Could anyone help me that how I can Implement them?

OBJ:最小值∑(i = 1..N)∑(j = 1..N)Cij * ∑(k = 1..K)Xijk

OBJ: Min ∑(i=1..N)∑(j=1..N) Cij * ∑(k=1..K)Xijk

约束: ∑(k = 1..K)Yik = 1(对于N中的所有i)

constraint : ∑(k=1..K) Yik=1 (for all i in N)

推荐答案

以下答案特定于ECLiPSe(它使用循环,数组和数组切片符号,这不是标准Prolog的一部分).

The following answer is specific to ECLiPSe (it uses loops, array and array slice notation, which are not part of standard Prolog).

我假设给出了NK(大概是C),并且您的矩阵被声明为

I assume that N and K (and presumably C) are given, and your matrices are declared as

dim(C, [N,N]),
dim(X, [N,N,K]),
dim(Y, [N,K]),

然后您可以循环设置约束:

You can then set up the constraints in a loop:

( for(I,1,N), param(Y) do
    sum(Y[I,*]) $= 1
),

请注意,当K是此数组维的大小时,此处的符号sum(Y[I,*])sum([Y[I,1],Y[I,2],...,Y[I,K]])的简写.

Note that the notation sum(Y[I,*]) here is a shorthand for sum([Y[I,1],Y[I,2],...,Y[I,K]]) when K is the size of this array dimension.

出于目标的考虑,由于嵌套的总和,仍需要一个辅助循环/列表:

For your objective, because of the nested sum, an auxiliary loop/list is still necessary:

( multifor([I,J],1,N), foreach(Term,Terms), param(C,X) do
    Term = (C[I,J] * sum(X[I,J,*]))
),
Objective = sum(Terms),
...

然后,您必须将此目标表达式传递给求解器-具体信息取决于您使用的求解器(例如eplex,ic).

You then have to pass this objective expression to the solver -- the details depend on which solver you use (e.g. eplex, ic).

这篇关于如何在ECLIPSE CLP或Prolog中实现此MP问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 03:56