How to implement This MP problem in ECLIPSE CLP or Prolog?

扶醉桌前 提交于 2019-12-11 15:55:47

问题


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

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

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


回答1:


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

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:

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

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

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:

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

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

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



来源:https://stackoverflow.com/questions/55778381/how-to-implement-this-mp-problem-in-eclipse-clp-or-prolog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!