簡而言之,我們現在試圖將IQP轉換爲ILP。舊的實施花了大約2天時間,現在用線性工具完成 - 它應該加速。基本上問題是最大化(大約50個二元變量):在ILP中尋找最多需要太多時間,爲什麼?
$$ \ sum_ {g = 1}^{5} sum_ {p = 1}^{10}(S [p] x [g] [p] -Tiredness [G] [p] -Sleepness [G] [p])$$
更新
我認爲大衛是在正確的軌道上,但是當我試圖最大限度地與表達獎金 - 變數,他們每次都是零,爲什麼?在某些代碼下方,分數可能類似S[1..10]=[1,2,3,4,5,6,7,8,9,10];
。如果X1,X2是兩個變量
int S[1..10] = ...; // Scores per player =s
dvar int x1[1..10] in 0..1;
dvar int x2[1..10] in 0..1;
dvar int x3[1..10] in 0..1;
dvar int x4[1..10] in 0..1;
dvar int x5[1..10] in 0..1;
dvar int b1[1..10] in 0..100;
dvar int b2[1..10] in 0..100;
//ERR: the values of b1 and b2 should be maximized...
// WHY not here so?
maximize
sum(i in 1..10)
(
S[i] *
(
(x1[i]+x2[i]+x3[i]+x4[i]+x5[i])
- 1/10 * (b1 +b2)
)
);
subject to
{
//We must play in 5 games.
//It means that there are 5 players in each game.
sum(i in 1..10) x1[i]==5;
sum(i in 1..10) x2[i]==5;
sum(i in 1..10) x3[i]==5;
sum(i in 1..10) x4[i]==5;
sum(i in 1..10) x5[i]==5;
// IQP problem into ILP -problem
forall (i in 1..10)
{
//ERROR HERE!
//it returns zero for b1 and b2, they should be maximized...
//I am trying to use the tip by David here, see his answer.
// EQ1: x2[i] * (x1[i]+x3[i])
b1 <= 2*x2[i];
b1 <= x1[i]+x3[i];
// EQ2: x4[i] * (x3[i]+x5[i]+x1[i])
b2 <= 3*x4[i];
b2 <= x3[i]+x5[i]+x1[i];
}
};
這並不奇怪,它很慢,因爲這不是一個線性規劃問題(但是一個* integer *線性規劃問題),而且你有50個變量,而不是20個。你試圖解決什麼問題? – jpalecek
所以你需要將玩家分配給遊戲,對吧?在ILP問題中,您沒有限制遊戲中的玩家數量,這樣好嗎? – jpalecek