1
所以在我的代碼中,我正在爲不同類型的變量寫一個線性程序。有6個。第一個是產品的「x」變量,其餘5個是盒子的「w」變量(五個不同大小的盒子)。我需要所有這些是整數,但是,在我的輸出中,我得到的x變量是整數,但箱大小都是非整數。我已經嘗試了100種不同的東西,我無法弄清楚這一點。PuLP沒有保持Integer類別
對於IND在varset:
maxID = skunulldict[ind]
sky = maxquant[maxID]
globals()[ind] = pulp.LpVariable(ind, 0, sky, cat='Integer')
for indd in contset20:
vn = contvendor[indd]
capC = vv20[vn]
globals()[indd] = pulp.LpVariable(indd, 0, capC, cat='Integer')
for indds in contset40:
vns = contvendor[indds]
capC = vv40[vns]
globals()[indds] = pulp.LpVariable(indds, 0, capC, cat='Integer')
for indd in contset2b:
vn = contvendor[indd]
capC = vv2b[vn]
globals()[indd] = pulp.LpVariable(indd, 0, capC, cat='Integer')
for indd in contset4b:
vn = contvendor[indd]
capC = vv4b[vn]
globals()[indd] = pulp.LpVariable(indd, 0, capC, cat='Integer')
for indd in contsetcs:
vn = contvendor[indd]
capC = vvcs[vn]
globals()[indd] = pulp.LpVariable(indd, 0, capC, cat='Integer')