我正在使用MIP,但我遇到了这个问题,我不知道为什么会这样。我已经完成了我的模型。当我用GLPK解决它时,它给mi所有变量值等于0.当我使用默认求解器时,它给出不同的值。但我想使用GLPK。我做错了什么?
model.solve(GLPK())
print pulp.LpStatus[model.status]
for variable in model.variables():
print "{} = {}".format(variable.name, variable.varValue)
print pulp.value(model.objective)
print 'Objective Function Value:'
print pulp.value(model.objective)
它给了我这个结果:
Optimal
__dummy = None
up_{p,g}_(1,_103) = 0
up_{p,g}_(1,_119) = 0
up_{p,g}_(1,_123) = 0
up_{p,g}_(1,_124) = 0
up_{p,g}_(1,_126) = 0
up_{p,g}_(1,_128) = 0
up_{p,g}_(1,_129) = 0
up_{p,g}_(1,_137) = 0
up_{p,g}_(1,_143) = 0
up_{p,g}_(1,_157) = 0
up_{p,g}_(1,_163) = 0
up_{p,g}_(1,_164) = 0
up_{p,g}_(1,_170) = 0
up_{p,g}_(1,_171) = 0
up_{p,g}_(1,_173) = 0
up_{p,g}_(1,_174) = 0
up_{p,g}_(1,_175) = 0
up_{p,g}_(1,_178) = 0
up_{p,g}_(1,_186) = 0
up_{p,g}_(1,_189) = 0
up_{p,g}_(1,_190) = 0
up_{p,g}_(1,_192) = 0
up_{p,g}_(1,_195) = 0
up_{p,g}_(1,_206) = 0
up_{p,g}_(1,_209) = 0
up_{p,g}_(1,_211) = 0
up_{p,g}_(1,_218) = 0
up_{p,g}_(1,_234) = 0
up_{p,g}_(1,_245) = 0
up_{p,g}_(1,_246) = 0
up_{p,g}_(1,_255) = 0
up_{p,g}_(1,_26) = 0
up_{p,g}_(1,_29) = 0
up_{p,g}_(1,_32) = 0
up_{p,g}_(1,_40) = 0
up_{p,g}_(1,_41) = 0
up_{p,g}_(1,_45) = 0
up_{p,g}_(1,_51) = 0
up_{p,g}_(1,_56) = 0
up_{p,g}_(1,_57) = 0
up_{p,g}_(1,_64) = 0
up_{p,g}_(1,_66) = 0
up_{p,g}_(1,_79) = 0
up_{p,g}_(1,_8) = 0
up_{p,g}_(1,_96) = 0
up_{p,g}_(10,_103) = 0
up_{p,g}_(10,_128) = 0
up_{p,g}_(10,_143) = 0
up_{p,g}_(10,_151) = 0
up_{p,g}_(10,_206) = 0
up_{p,g}_(10,_26) = 0
up_{p,g}_(10,_29) = 0
up_{p,g}_(10,_30) = 0
up_{p,g}_(10,_32) = 0
up_{p,g}_(10,_79) = 0
up_{p,g}_(10,_96) = 0
up_{p,g}_(11,_103) = 0
up_{p,g}_(11,_128) = 0
up_{p,g}_(11,_143) = 0
up_{p,g}_(11,_151) = 0
up_{p,g}_(11,_26) = 0
up_{p,g}_(11,_30) = 0
up_{p,g}_(11,_64) = 0
up_{p,g}_(11,_96) = 0
up_{p,g}_(12,_103) = 0
up_{p,g}_(12,_143) = 0
up_{p,g}_(12,_151) = 0
up_{p,g}_(12,_26) = 0
up_{p,g}_(12,_30) = 0
up_{p,g}_(12,_96) = 0
up_{p,g}_(13,_143) = 0
up_{p,g}_(13,_148) = 0
up_{p,g}_(13,_26) = 0
up_{p,g}_(13,_30) = 0
up_{p,g}_(13,_40) = 0
up_{p,g}_(13,_96) = 0
up_{p,g}_(14,_143) = 0
up_{p,g}_(14,_26) = 0
up_{p,g}_(14,_30) = 0
up_{p,g}_(14,_40) = 0
up_{p,g}_(14,_96) = 0
up_{p,g}_(15,_143) = 0
up_{p,g}_(15,_26) = 0
up_{p,g}_(15,_30) = 0
up_{p,g}_(15,_40) = 0
up_{p,g}_(15,_96) = 0
up_{p,g}_(16,_143) = 0
up_{p,g}_(16,_26) = 0
up_{p,g}_(16,_40) = 0
up_{p,g}_(16,_96) = 0
up_{p,g}_(17,_193) = 0
up_{p,g}_(17,_26) = 0
up_{p,g}_(17,_40) = 0
up_{p,g}_(18,_193) = 0
up_{p,g}_(18,_26) = 0
up_{p,g}_(18,_30) = 0
up_{p,g}_(18,_40) = 0
up_{p,g}_(19,_150) = 0
up_{p,g}_(19,_193) = 0
up_{p,g}_(19,_30) = 0
up_{p,g}_(2,_119) = 0
up_{p,g}_(2,_123) = 0
up_{p,g}_(2,_124) = 0
up_{p,g}_(2,_126) = 0
up_{p,g}_(2,_128) = 0
up_{p,g}_(2,_129) = 0
up_{p,g}_(2,_143) = 0
up_{p,g}_(2,_157) = 0
up_{p,g}_(2,_164) = 0
up_{p,g}_(2,_170) = 0
up_{p,g}_(2,_173) = 0
up_{p,g}_(2,_174) = 0
up_{p,g}_(2,_175) = 0
up_{p,g}_(2,_178) = 0
up_{p,g}_(2,_186) = 0
up_{p,g}_(2,_191) = 0
up_{p,g}_(2,_195) = 0
up_{p,g}_(2,_206) = 0
up_{p,g}_(2,_209) = 0
up_{p,g}_(2,_211) = 0
up_{p,g}_(2,_218) = 0
up_{p,g}_(2,_233) = 0
up_{p,g}_(2,_234) = 0
up_{p,g}_(2,_245) = 0
up_{p,g}_(2,_246) = 0
up_{p,g}_(2,_255) = 0
up_{p,g}_(2,_26) = 0
up_{p,g}_(2,_29) = 0
up_{p,g}_(2,_32) = 0
up_{p,g}_(2,_40) = 0
up_{p,g}_(2,_41) = 0
up_{p,g}_(2,_45) = 0
up_{p,g}_(2,_56) = 0
up_{p,g}_(2,_64) = 0
up_{p,g}_(2,_66) = 0
up_{p,g}_(2,_79) = 0
up_{p,g}_(2,_8) = 0
up_{p,g}_(2,_96) = 0
up_{p,g}_(20,_150) = 0
up_{p,g}_(21,_150) = 0
up_{p,g}_(21,_40) = 0
up_{p,g}_(22,_30) = 0
up_{p,g}_(22,_40) = 0
up_{p,g}_(23,_30) = 0
up_{p,g}_(24,_30) = 0
up_{p,g}_(26,_40) = 0
up_{p,g}_(27,_40) = 0
up_{p,g}_(28,_40) = 0
up_{p,g}_(29,_150) = 0
up_{p,g}_(29,_40) = 0
up_{p,g}_(3,_103) = 0
up_{p,g}_(3,_119) = 0
up_{p,g}_(3,_123) = 0
up_{p,g}_(3,_126) = 0
up_{p,g}_(3,_128) = 0
up_{p,g}_(3,_129) = 0
up_{p,g}_(3,_143) = 0
up_{p,g}_(3,_148) = 0
up_{p,g}_(3,_157) = 0
up_{p,g}_(3,_164) = 0
up_{p,g}_(3,_170) = 0
up_{p,g}_(3,_173) = 0
up_{p,g}_(3,_174) = 0
up_{p,g}_(3,_175) = 0
up_{p,g}_(3,_178) = 0
up_{p,g}_(3,_186) = 0
up_{p,g}_(3,_194) = 0
up_{p,g}_(3,_195) = 0
up_{p,g}_(3,_203) = 0
up_{p,g}_(3,_204) = 0
up_{p,g}_(3,_206) = 0
up_{p,g}_(3,_211) = 0
up_{p,g}_(3,_217) = 0
up_{p,g}_(3,_218) = 0
up_{p,g}_(3,_233) = 0
up_{p,g}_(3,_245) = 0
up_{p,g}_(3,_246) = 0
up_{p,g}_(3,_255) = 0
up_{p,g}_(3,_26) = 0
up_{p,g}_(3,_29) = 0
up_{p,g}_(3,_40) = 0
up_{p,g}_(3,_41) = 0
up_{p,g}_(3,_45) = 0
up_{p,g}_(3,_51) = 0
up_{p,g}_(3,_56) = 0
up_{p,g}_(3,_64) = 0
up_{p,g}_(3,_79) = 0
up_{p,g}_(3,_8) = 0
up_{p,g}_(3,_96) = 0
up_{p,g}_(30,_150) = 0
up_{p,g}_(30,_40) = 0
up_{p,g}_(31,_103) = 0
up_{p,g}_(31,_40) = 0
up_{p,g}_(32,_40) = 0
up_{p,g}_(35,_40) = 0
up_{p,g}_(36,_40) = 0
up_{p,g}_(37,_150) = 0
up_{p,g}_(37,_40) = 0
up_{p,g}_(38,_150) = 0
up_{p,g}_(38,_40) = 0
up_{p,g}_(4,_103) = 0
up_{p,g}_(4,_119) = 0
up_{p,g}_(4,_123) = 0
up_{p,g}_(4,_128) = 0
up_{p,g}_(4,_143) = 0
up_{p,g}_(4,_164) = 0
up_{p,g}_(4,_170) = 0
up_{p,g}_(4,_171) = 0
up_{p,g}_(4,_173) = 0
up_{p,g}_(4,_174) = 0
up_{p,g}_(4,_175) = 0
up_{p,g}_(4,_194) = 0
up_{p,g}_(4,_203) = 0
up_{p,g}_(4,_204) = 0
up_{p,g}_(4,_206) = 0
up_{p,g}_(4,_209) = 0
up_{p,g}_(4,_211) = 0
up_{p,g}_(4,_217) = 0
up_{p,g}_(4,_233) = 0
up_{p,g}_(4,_234) = 0
up_{p,g}_(4,_246) = 0
up_{p,g}_(4,_255) = 0
up_{p,g}_(4,_26) = 0
up_{p,g}_(4,_29) = 0
up_{p,g}_(4,_32) = 0
up_{p,g}_(4,_40) = 0
up_{p,g}_(4,_41) = 0
up_{p,g}_(4,_45) = 0
up_{p,g}_(4,_64) = 0
up_{p,g}_(4,_79) = 0
up_{p,g}_(4,_8) = 0
up_{p,g}_(4,_96) = 0
up_{p,g}_(5,_103) = 0
up_{p,g}_(5,_119) = 0
up_{p,g}_(5,_123) = 0
up_{p,g}_(5,_128) = 0
up_{p,g}_(5,_143) = 0
up_{p,g}_(5,_164) = 0
up_{p,g}_(5,_170) = 0
up_{p,g}_(5,_171) = 0
up_{p,g}_(5,_173) = 0
up_{p,g}_(5,_174) = 0
up_{p,g}_(5,_175) = 0
up_{p,g}_(5,_193) = 0
up_{p,g}_(5,_194) = 0
up_{p,g}_(5,_206) = 0
up_{p,g}_(5,_217) = 0
up_{p,g}_(5,_233) = 0
up_{p,g}_(5,_255) = 0
up_{p,g}_(5,_26) = 0
up_{p,g}_(5,_29) = 0
up_{p,g}_(5,_32) = 0
up_{p,g}_(5,_40) = 0
up_{p,g}_(5,_41) = 0
up_{p,g}_(5,_64) = 0
up_{p,g}_(5,_79) = 0
up_{p,g}_(5,_8) = 0
up_{p,g}_(5,_96) = 0
up_{p,g}_(6,_103) = 0
up_{p,g}_(6,_119) = 0
up_{p,g}_(6,_123) = 0
up_{p,g}_(6,_128) = 0
up_{p,g}_(6,_143) = 0
up_{p,g}_(6,_164) = 0
up_{p,g}_(6,_170) = 0
up_{p,g}_(6,_171) = 0
up_{p,g}_(6,_193) = 0
up_{p,g}_(6,_194) = 0
up_{p,g}_(6,_206) = 0
up_{p,g}_(6,_217) = 0
up_{p,g}_(6,_233) = 0
up_{p,g}_(6,_255) = 0
up_{p,g}_(6,_26) = 0
up_{p,g}_(6,_29) = 0
up_{p,g}_(6,_32) = 0
up_{p,g}_(6,_40) = 0
up_{p,g}_(6,_51) = 0
up_{p,g}_(6,_64) = 0
up_{p,g}_(6,_79) = 0
up_{p,g}_(6,_8) = 0
up_{p,g}_(6,_96) = 0
up_{p,g}_(7,_103) = 0
up_{p,g}_(7,_119) = 0
up_{p,g}_(7,_123) = 0
up_{p,g}_(7,_128) = 0
up_{p,g}_(7,_143) = 0
up_{p,g}_(7,_150) = 0
up_{p,g}_(7,_170) = 0
up_{p,g}_(7,_193) = 0
up_{p,g}_(7,_194) = 0
up_{p,g}_(7,_206) = 0
up_{p,g}_(7,_217) = 0
up_{p,g}_(7,_233) = 0
up_{p,g}_(7,_26) = 0
up_{p,g}_(7,_29) = 0
up_{p,g}_(7,_32) = 0
up_{p,g}_(7,_40) = 0
up_{p,g}_(7,_64) = 0
up_{p,g}_(7,_79) = 0
up_{p,g}_(7,_96) = 0
up_{p,g}_(8,_119) = 0
up_{p,g}_(8,_123) = 0
up_{p,g}_(8,_128) = 0
up_{p,g}_(8,_143) = 0
up_{p,g}_(8,_150) = 0
up_{p,g}_(8,_170) = 0
up_{p,g}_(8,_193) = 0
up_{p,g}_(8,_206) = 0
up_{p,g}_(8,_233) = 0
up_{p,g}_(8,_26) = 0
up_{p,g}_(8,_29) = 0
up_{p,g}_(8,_32) = 0
up_{p,g}_(8,_40) = 0
up_{p,g}_(8,_51) = 0
up_{p,g}_(8,_64) = 0
up_{p,g}_(8,_79) = 0
up_{p,g}_(8,_96) = 0
up_{p,g}_(9,_103) = 0
up_{p,g}_(9,_119) = 0
up_{p,g}_(9,_128) = 0
up_{p,g}_(9,_143) = 0
up_{p,g}_(9,_150) = 0
up_{p,g}_(9,_193) = 0
up_{p,g}_(9,_206) = 0
up_{p,g}_(9,_26) = 0
up_{p,g}_(9,_29) = 0
up_{p,g}_(9,_30) = 0
up_{p,g}_(9,_32) = 0
up_{p,g}_(9,_64) = 0
up_{p,g}_(9,_79) = 0
up_{p,g}_(9,_96) = 0
ventaC_bc1 = 0.0
ventaC_bc10 = 0.0
ventaC_bc11 = 0.0
ventaC_bc12 = 0.0
ventaC_bc13 = 0.0
ventaC_bc14 = 0.0
ventaC_bc15 = 0.0
ventaC_bc16 = 0.0
ventaC_bc17 = 0.0
ventaC_bc18 = 0.0
ventaC_bc19 = 0.0
ventaC_bc2 = 0.0
ventaC_bc20 = 0.0
ventaC_bc21 = 0.0
ventaC_bc22 = 0.0
ventaC_bc23 = 0.0
ventaC_bc24 = 0.0
ventaC_bc25 = 0.0
ventaC_bc26 = 0.0
ventaC_bc27 = 0.0
ventaC_bc28 = 0.0
ventaC_bc29 = 0.0
ventaC_bc3 = 0.0
ventaC_bc30 = 0.0
ventaC_bc4 = 0.0
ventaC_bc5 = 0.0
ventaC_bc6 = 0.0
ventaC_bc7 = 0.0
ventaC_bc8 = 0.0
ventaC_bc9 = 0.0
ventaE_be1 = 0.0
ventaE_be10 = 0.0
ventaE_be11 = 0.0
ventaE_be12 = 0.0
ventaE_be13 = 0.0
ventaE_be14 = 0.0
ventaE_be15 = 0.0
ventaE_be16 = 0.0
ventaE_be17 = 0.0
ventaE_be18 = 0.0
ventaE_be19 = 0.0
ventaE_be2 = 0.0
ventaE_be20 = 0.0
ventaE_be21 = 0.0
ventaE_be22 = 0.0
ventaE_be23 = 0.0
ventaE_be24 = 0.0
ventaE_be25 = 0.0
ventaE_be26 = 0.0
ventaE_be27 = 0.0
ventaE_be28 = 0.0
ventaE_be29 = 0.0
ventaE_be3 = 0.0
ventaE_be30 = 0.0
ventaE_be4 = 0.0
ventaE_be5 = 0.0
ventaE_be6 = 0.0
ventaE_be7 = 0.0
ventaE_be8 = 0.0
ventaE_be9 = 0.0
ventaP_bp1 = 0.0
ventaP_bp10 = 0.0
ventaP_bp11 = 0.0
ventaP_bp12 = 0.0
ventaP_bp13 = 0.0
ventaP_bp14 = 0.0
ventaP_bp15 = 0.0
ventaP_bp16 = 0.0
ventaP_bp17 = 0.0
ventaP_bp18 = 0.0
ventaP_bp19 = 0.0
ventaP_bp2 = 0.0
ventaP_bp20 = 0.0
ventaP_bp21 = 0.0
ventaP_bp22 = 0.0
ventaP_bp23 = 0.0
ventaP_bp24 = 0.0
ventaP_bp25 = 0.0
ventaP_bp26 = 0.0
ventaP_bp27 = 0.0
ventaP_bp28 = 0.0
ventaP_bp29 = 0.0
ventaP_bp3 = 0.0
ventaP_bp30 = 0.0
ventaP_bp4 = 0.0
ventaP_bp5 = 0.0
ventaP_bp6 = 0.0
ventaP_bp7 = 0.0
ventaP_bp8 = 0.0
ventaP_bp9 = 0.0
0.0
Objective Function Value:
0.0
In [ ]:
当我擦除GLPK()函数时,它给出了:
model.solve()
print pulp.LpStatus[model.status]
for variable in model.variables():
print "{} = {}".format(variable.name, variable.varValue)
print pulp.value(model.objective)
print 'Objective Function Value:'
print pulp.value(model.objective)
Optimal
up_{p,g}_(1,_103) = 1.0
up_{p,g}_(1,_119) = 0.0
up_{p,g}_(1,_123) = 0.0
up_{p,g}_(1,_124) = 0.0
up_{p,g}_(1,_126) = 0.0
up_{p,g}_(1,_128) = 1.0
up_{p,g}_(1,_129) = 1.0
up_{p,g}_(1,_137) = 0.0
up_{p,g}_(1,_143) = 0.0
up_{p,g}_(1,_157) = 0.0
up_{p,g}_(1,_163) = 0.0
up_{p,g}_(1,_164) = 0.0
up_{p,g}_(1,_170) = 0.0
up_{p,g}_(1,_171) = 0.0
up_{p,g}_(1,_173) = 0.0
up_{p,g}_(1,_174) = 0.0
up_{p,g}_(1,_175) = 1.0
up_{p,g}_(1,_178) = 0.0
up_{p,g}_(1,_186) = 1.0
up_{p,g}_(1,_189) = 1.0
up_{p,g}_(1,_190) = 0.0
up_{p,g}_(1,_192) = 0.0
up_{p,g}_(1,_195) = 0.0
up_{p,g}_(1,_206) = 1.0
up_{p,g}_(1,_209) = 0.0
up_{p,g}_(1,_211) = 0.0
up_{p,g}_(1,_218) = 0.0
up_{p,g}_(1,_234) = 0.0
up_{p,g}_(1,_245) = 0.0
up_{p,g}_(1,_246) = 0.0
up_{p,g}_(1,_255) = 0.0
up_{p,g}_(1,_26) = 0.0
up_{p,g}_(1,_29) = 0.0
up_{p,g}_(1,_32) = 0.0
up_{p,g}_(1,_40) = 0.0
up_{p,g}_(1,_41) = 0.0
up_{p,g}_(1,_45) = 0.0
up_{p,g}_(1,_51) = 0.0
up_{p,g}_(1,_56) = 0.0
up_{p,g}_(1,_57) = 0.0
up_{p,g}_(1,_64) = 0.0
up_{p,g}_(1,_66) = 0.0
up_{p,g}_(1,_79) = 1.0
up_{p,g}_(1,_8) = 0.0
up_{p,g}_(1,_96) = 0.0
up_{p,g}_(10,_103) = 0.0
up_{p,g}_(10,_128) = 0.0
up_{p,g}_(10,_143) = 0.0
up_{p,g}_(10,_151) = 0.0
up_{p,g}_(10,_206) = 0.0
up_{p,g}_(10,_26) = 0.0
up_{p,g}_(10,_29) = 1.0
up_{p,g}_(10,_30) = 0.0
up_{p,g}_(10,_32) = 0.0
up_{p,g}_(10,_79) = 0.0
up_{p,g}_(10,_96) = 0.0
up_{p,g}_(11,_103) = 0.0
up_{p,g}_(11,_128) = 0.0
up_{p,g}_(11,_143) = 0.0
up_{p,g}_(11,_151) = 0.0
up_{p,g}_(11,_26) = 0.0
up_{p,g}_(11,_30) = 0.0
up_{p,g}_(11,_64) = 0.0
up_{p,g}_(11,_96) = 0.0
up_{p,g}_(12,_103) = 1.0
up_{p,g}_(12,_143) = 0.0
up_{p,g}_(12,_151) = 1.0
up_{p,g}_(12,_26) = 0.0
up_{p,g}_(12,_30) = 0.0
up_{p,g}_(12,_96) = 0.0
up_{p,g}_(13,_143) = 0.0
up_{p,g}_(13,_148) = 0.0
up_{p,g}_(13,_26) = 0.0
up_{p,g}_(13,_30) = 0.0
up_{p,g}_(13,_40) = 0.0
up_{p,g}_(13,_96) = 0.0
up_{p,g}_(14,_143) = 0.0
up_{p,g}_(14,_26) = 0.0
up_{p,g}_(14,_30) = 1.0
up_{p,g}_(14,_40) = 0.0
up_{p,g}_(14,_96) = 0.0
up_{p,g}_(15,_143) = 0.0
up_{p,g}_(15,_26) = 0.0
up_{p,g}_(15,_30) = 1.0
up_{p,g}_(15,_40) = 0.0
up_{p,g}_(15,_96) = 0.0
up_{p,g}_(16,_143) = 0.0
up_{p,g}_(16,_26) = 0.0
up_{p,g}_(16,_40) = 0.0
up_{p,g}_(16,_96) = 0.0
up_{p,g}_(17,_193) = 1.0
up_{p,g}_(17,_26) = 0.0
up_{p,g}_(17,_40) = 0.0
up_{p,g}_(18,_193) = 0.0
up_{p,g}_(18,_26) = 1.0
up_{p,g}_(18,_30) = 0.0
up_{p,g}_(18,_40) = 0.0
up_{p,g}_(19,_150) = 0.0
up_{p,g}_(19,_193) = 0.0
up_{p,g}_(19,_30) = 0.0
up_{p,g}_(2,_119) = 0.0
up_{p,g}_(2,_123) = 0.0
up_{p,g}_(2,_124) = 0.0
up_{p,g}_(2,_126) = 0.0
up_{p,g}_(2,_128) = 1.0
up_{p,g}_(2,_129) = 1.0
up_{p,g}_(2,_143) = 0.0
up_{p,g}_(2,_157) = 0.0
up_{p,g}_(2,_164) = 0.0
up_{p,g}_(2,_170) = 0.0
up_{p,g}_(2,_173) = 0.0
up_{p,g}_(2,_174) = 0.0
up_{p,g}_(2,_175) = 0.0
up_{p,g}_(2,_178) = 0.0
up_{p,g}_(2,_186) = 0.0
up_{p,g}_(2,_191) = 0.0
up_{p,g}_(2,_195) = 0.0
up_{p,g}_(2,_206) = 1.0
up_{p,g}_(2,_209) = 0.0
up_{p,g}_(2,_211) = 0.0
up_{p,g}_(2,_218) = 0.0
up_{p,g}_(2,_233) = 1.0
up_{p,g}_(2,_234) = 0.0
up_{p,g}_(2,_245) = 0.0
up_{p,g}_(2,_246) = 0.0
up_{p,g}_(2,_255) = 0.0
up_{p,g}_(2,_26) = 0.0
up_{p,g}_(2,_29) = 0.0
up_{p,g}_(2,_32) = 0.0
up_{p,g}_(2,_40) = 0.0
up_{p,g}_(2,_41) = 0.0
up_{p,g}_(2,_45) = 0.0
up_{p,g}_(2,_56) = 0.0
up_{p,g}_(2,_64) = 0.0
up_{p,g}_(2,_66) = 0.0
up_{p,g}_(2,_79) = 0.0
up_{p,g}_(2,_8) = 0.0
up_{p,g}_(2,_96) = 1.0
up_{p,g}_(20,_150) = 0.0
up_{p,g}_(21,_150) = 0.0
up_{p,g}_(21,_40) = 0.0
up_{p,g}_(22,_30) = 0.0
up_{p,g}_(22,_40) = 0.0
up_{p,g}_(23,_30) = 0.0
up_{p,g}_(24,_30) = 0.0
up_{p,g}_(26,_40) = 0.0
up_{p,g}_(27,_40) = 0.0
up_{p,g}_(28,_40) = 0.0
up_{p,g}_(29,_150) = 0.0
up_{p,g}_(29,_40) = 0.0
up_{p,g}_(3,_103) = 0.0
up_{p,g}_(3,_119) = 1.0
up_{p,g}_(3,_123) = 0.0
up_{p,g}_(3,_126) = 0.0
up_{p,g}_(3,_128) = 1.0
up_{p,g}_(3,_129) = 1.0
up_{p,g}_(3,_143) = 0.0
up_{p,g}_(3,_148) = 0.0
up_{p,g}_(3,_157) = 0.0
up_{p,g}_(3,_164) = 0.0
up_{p,g}_(3,_170) = 0.0
up_{p,g}_(3,_173) = 0.0
up_{p,g}_(3,_174) = 0.0
up_{p,g}_(3,_175) = 1.0
up_{p,g}_(3,_178) = 0.0
up_{p,g}_(3,_186) = 0.0
up_{p,g}_(3,_194) = 0.0
up_{p,g}_(3,_195) = 0.0
up_{p,g}_(3,_203) = 0.0
up_{p,g}_(3,_204) = 0.0
up_{p,g}_(3,_206) = 0.0
up_{p,g}_(3,_211) = 0.0
up_{p,g}_(3,_217) = 1.0
up_{p,g}_(3,_218) = 0.0
up_{p,g}_(3,_233) = 0.0
up_{p,g}_(3,_245) = 0.0
up_{p,g}_(3,_246) = 0.0
up_{p,g}_(3,_255) = 0.0
up_{p,g}_(3,_26) = 0.0
up_{p,g}_(3,_29) = 1.0
up_{p,g}_(3,_40) = 0.0
up_{p,g}_(3,_41) = 1.0
up_{p,g}_(3,_45) = 0.0
up_{p,g}_(3,_51) = 0.0
up_{p,g}_(3,_56) = 0.0
up_{p,g}_(3,_64) = 0.0
up_{p,g}_(3,_79) = 0.0
up_{p,g}_(3,_8) = 0.0
up_{p,g}_(3,_96) = 0.0
up_{p,g}_(30,_150) = 0.0
up_{p,g}_(30,_40) = 0.0
up_{p,g}_(31,_103) = 0.0
up_{p,g}_(31,_40) = 0.0
up_{p,g}_(32,_40) = 0.0
up_{p,g}_(35,_40) = 0.0
up_{p,g}_(36,_40) = 0.0
up_{p,g}_(37,_150) = 0.0
up_{p,g}_(37,_40) = 0.0
up_{p,g}_(38,_150) = 0.0
up_{p,g}_(38,_40) = 0.0
up_{p,g}_(4,_103) = 0.0
up_{p,g}_(4,_119) = 1.0
up_{p,g}_(4,_123) = 0.0
up_{p,g}_(4,_128) = 1.0
up_{p,g}_(4,_143) = 0.0
up_{p,g}_(4,_164) = 0.0
up_{p,g}_(4,_170) = 0.0
up_{p,g}_(4,_171) = 1.0
up_{p,g}_(4,_173) = 0.0
up_{p,g}_(4,_174) = 0.0
up_{p,g}_(4,_175) = 1.0
up_{p,g}_(4,_194) = 0.0
up_{p,g}_(4,_203) = 0.0
up_{p,g}_(4,_204) = 0.0
up_{p,g}_(4,_206) = 0.0
up_{p,g}_(4,_209) = 0.0
up_{p,g}_(4,_211) = 0.0
up_{p,g}_(4,_217) = 0.0
up_{p,g}_(4,_233) = 0.0
up_{p,g}_(4,_234) = 0.0
up_{p,g}_(4,_246) = 0.0
up_{p,g}_(4,_255) = 0.0
up_{p,g}_(4,_26) = 0.0
up_{p,g}_(4,_29) = 0.0
up_{p,g}_(4,_32) = 1.0
up_{p,g}_(4,_40) = 0.0
up_{p,g}_(4,_41) = 1.0
up_{p,g}_(4,_45) = 0.0
up_{p,g}_(4,_64) = 0.0
up_{p,g}_(4,_79) = 1.0
up_{p,g}_(4,_8) = 0.0
up_{p,g}_(4,_96) = 1.0
up_{p,g}_(5,_103) = 1.0
up_{p,g}_(5,_119) = 0.0
up_{p,g}_(5,_123) = 1.0
up_{p,g}_(5,_128) = 1.0
up_{p,g}_(5,_143) = 0.0
up_{p,g}_(5,_164) = 0.0
up_{p,g}_(5,_170) = 0.0
up_{p,g}_(5,_171) = 0.0
up_{p,g}_(5,_173) = 0.0
up_{p,g}_(5,_174) = 0.0
up_{p,g}_(5,_175) = 1.0
up_{p,g}_(5,_193) = 1.0
up_{p,g}_(5,_194) = 0.0
up_{p,g}_(5,_206) = 1.0
up_{p,g}_(5,_217) = 1.0
up_{p,g}_(5,_233) = 0.0
up_{p,g}_(5,_255) = 0.0
up_{p,g}_(5,_26) = 0.0
up_{p,g}_(5,_29) = 0.0
up_{p,g}_(5,_32) = 0.0
up_{p,g}_(5,_40) = 0.0
up_{p,g}_(5,_41) = 1.0
up_{p,g}_(5,_64) = 0.0
up_{p,g}_(5,_79) = 1.0
up_{p,g}_(5,_8) = 0.0
up_{p,g}_(5,_96) = 0.0
up_{p,g}_(6,_103) = 1.0
up_{p,g}_(6,_119) = 0.0
up_{p,g}_(6,_123) = 1.0
up_{p,g}_(6,_128) = 1.0
up_{p,g}_(6,_143) = 0.0
up_{p,g}_(6,_164) = 0.0
up_{p,g}_(6,_170) = 0.0
up_{p,g}_(6,_171) = 1.0
up_{p,g}_(6,_193) = 0.0
up_{p,g}_(6,_194) = 0.0
up_{p,g}_(6,_206) = 1.0
up_{p,g}_(6,_217) = 1.0
up_{p,g}_(6,_233) = 1.0
up_{p,g}_(6,_255) = 0.0
up_{p,g}_(6,_26) = 0.0
up_{p,g}_(6,_29) = 1.0
up_{p,g}_(6,_32) = 0.0
up_{p,g}_(6,_40) = 0.0
up_{p,g}_(6,_51) = 0.0
up_{p,g}_(6,_64) = 0.0
up_{p,g}_(6,_79) = 0.0
up_{p,g}_(6,_8) = 0.0
up_{p,g}_(6,_96) = 0.0
up_{p,g}_(7,_103) = 1.0
up_{p,g}_(7,_119) = 0.0
up_{p,g}_(7,_123) = 0.0
up_{p,g}_(7,_128) = 1.0
up_{p,g}_(7,_143) = 0.0
up_{p,g}_(7,_150) = 0.0
up_{p,g}_(7,_170) = 0.0
up_{p,g}_(7,_193) = 0.0
up_{p,g}_(7,_194) = 0.0
up_{p,g}_(7,_206) = 0.0
up_{p,g}_(7,_217) = 0.0
up_{p,g}_(7,_233) = 0.0
up_{p,g}_(7,_26) = 0.0
up_{p,g}_(7,_29) = 0.0
up_{p,g}_(7,_32) = 1.0
up_{p,g}_(7,_40) = 0.0
up_{p,g}_(7,_64) = 0.0
up_{p,g}_(7,_79) = 0.0
up_{p,g}_(7,_96) = 0.0
up_{p,g}_(8,_119) = 0.0
up_{p,g}_(8,_123) = 0.0
up_{p,g}_(8,_128) = 0.0
up_{p,g}_(8,_143) = 0.0
up_{p,g}_(8,_150) = 0.0
up_{p,g}_(8,_170) = 0.0
up_{p,g}_(8,_193) = 0.0
up_{p,g}_(8,_206) = 0.0
up_{p,g}_(8,_233) = 1.0
up_{p,g}_(8,_26) = 0.0
up_{p,g}_(8,_29) = 1.0
up_{p,g}_(8,_32) = 0.0
up_{p,g}_(8,_40) = 0.0
up_{p,g}_(8,_51) = 0.0
up_{p,g}_(8,_64) = 0.0
up_{p,g}_(8,_79) = 0.0
up_{p,g}_(8,_96) = 0.0
up_{p,g}_(9,_103) = 1.0
up_{p,g}_(9,_119) = 0.0
up_{p,g}_(9,_128) = 0.0
up_{p,g}_(9,_143) = 0.0
up_{p,g}_(9,_150) = 0.0
up_{p,g}_(9,_193) = 0.0
up_{p,g}_(9,_206) = 0.0
up_{p,g}_(9,_26) = 0.0
up_{p,g}_(9,_29) = 0.0
up_{p,g}_(9,_30) = 0.0
up_{p,g}_(9,_32) = 0.0
up_{p,g}_(9,_64) = 0.0
up_{p,g}_(9,_79) = 0.0
up_{p,g}_(9,_96) = 0.0
ventaC_bc1 = 340157.16
ventaC_bc10 = 340157.16
ventaC_bc11 = 340157.16
ventaC_bc12 = 340157.16
ventaC_bc13 = 340157.16
ventaC_bc14 = 340157.16
ventaC_bc15 = 340157.16
ventaC_bc16 = 340157.16
ventaC_bc17 = 340157.16
ventaC_bc18 = 340157.16
ventaC_bc19 = 340157.16
ventaC_bc2 = 340157.16
ventaC_bc20 = 340157.16
ventaC_bc21 = 340157.16
ventaC_bc22 = 340157.16
ventaC_bc23 = 340157.16
ventaC_bc24 = 340157.16
ventaC_bc25 = 340157.16
ventaC_bc26 = 425196.45
ventaC_bc27 = 29299.55
ventaC_bc28 = 0.0
ventaC_bc29 = 0.0
ventaC_bc3 = 340157.16
ventaC_bc30 = 0.0
ventaC_bc4 = 340157.16
ventaC_bc5 = 340157.16
ventaC_bc6 = 340157.16
ventaC_bc7 = 340157.16
ventaC_bc8 = 340157.16
ventaC_bc9 = 340157.16
ventaE_be1 = 340157.16
ventaE_be10 = 340157.16
ventaE_be11 = 340157.16
ventaE_be12 = 340157.16
ventaE_be13 = 340157.16
ventaE_be14 = 340157.16
ventaE_be15 = 340157.16
ventaE_be16 = 340157.16
ventaE_be17 = 340157.16
ventaE_be18 = 340157.16
ventaE_be19 = 340157.16
ventaE_be2 = 340157.16
ventaE_be20 = 340157.16
ventaE_be21 = 340157.16
ventaE_be22 = 340157.16
ventaE_be23 = 340157.16
ventaE_be24 = 340157.16
ventaE_be25 = 340157.16
ventaE_be26 = 425196.45
ventaE_be27 = 425196.45
ventaE_be28 = 425196.45
ventaE_be29 = 24979.01
ventaE_be3 = 340157.16
ventaE_be30 = 0.0
ventaE_be4 = 340157.16
ventaE_be5 = 340157.16
ventaE_be6 = 340157.16
ventaE_be7 = 340157.16
ventaE_be8 = 340157.16
ventaE_be9 = 340157.16
ventaP_bp1 = 47.46
ventaP_bp10 = 47.46
ventaP_bp11 = 47.46
ventaP_bp12 = 47.46
ventaP_bp13 = 47.46
ventaP_bp14 = 47.46
ventaP_bp15 = 47.46
ventaP_bp16 = 47.46
ventaP_bp17 = 47.46
ventaP_bp18 = 47.46
ventaP_bp19 = 47.46
ventaP_bp2 = 47.46
ventaP_bp20 = 47.46
ventaP_bp21 = 47.46
ventaP_bp22 = 47.46
ventaP_bp23 = 47.46
ventaP_bp24 = 47.46
ventaP_bp25 = 47.46
ventaP_bp26 = 15.83
ventaP_bp27 = 0.0
ventaP_bp28 = 0.0
ventaP_bp29 = 0.0
ventaP_bp3 = 47.46
ventaP_bp30 = 0.0
ventaP_bp4 = 47.46
ventaP_bp5 = 47.46
ventaP_bp6 = 47.46
ventaP_bp7 = 47.46
ventaP_bp8 = 47.46
ventaP_bp9 = 47.46
5671838324.54
Objective Function Value:
5671838324.54
代码
Any suggestions? Thank you.
Any help is well appreciated
Arturo
Datos = pd.ExcelFile('Datos_Zumma_SLP2016.xlsx')
demE = Datos.parse('DemE', index_col=0)
demC = Datos.parse('DemC', index_col=0)
demP = Datos.parse('DemP', index_col=0)
paquetes = Datos.parse('Paquetes', index_col=[0,1])
paqinc = Datos.parse('PaqIn', index_col=0)
paqexc = Datos.parse('PaqExc', index_col=[0,1,2])
indpaqexc = Datos.parse('IndPaqExc', index_col=0)
centrales = Datos.parse('Centrales', index_col=[7,1])
centralOV = Datos.parse('Central_OV', index_col=[0,1,2])
sistemaInter = Datos.parse('SINT', index_col=0)
nodoOf = Datos.parse('LimInterconexionNodos', index_col=0)
# Creación de variables necesarias.
variables_demE = pulp.LpVariable.dicts("ventaE",
(BE for BE in demE.index),
lowBound=0,
cat='Continuous')
variables_demC = pulp.LpVariable.dicts("ventaC",
(BC for BC in demC.index),
lowBound=0,
cat='Continuous')
variables_demP = pulp.LpVariable.dicts("ventaP",
(BP for BP in demP.index),
lowBound=0,
cat='Continuous')
variables_up = pulp.LpVariable.dicts("up_{p,g}",
((P,G) for (P,G) in paquetes.index),
lowBound=0,
cat='Binary')
variables_uc = pulp.LpVariable.dicts("uc_{gen,cen}",
((gen,cen) for gen,cen in centrales.index),
lowBound=0,
cat='Binary')
#Creación del modelo de Programa de Enteros Mixtos
model = pulp.LpProblem("problema de maximización del excedente total", pulp.LpMaximize)
# función objetivo
model += pulp.lpSum(
[variables_demP[BP] * demP.loc[(BP), 'PrecioDemPot'] for BP in demP.index]
) + pulp.lpSum(
[variables_demE[BE] * demE.loc[(BE), 'PrecioDemEea'] for BE in demE.index]
) + pulp.lpSum(
[variables_demC[BC] * demC.loc[(BC), 'PrecioDemCel'] for BC in demC.index]
) - pulp.lpSum(
[variables_up[PAQ] * paquetes.loc[(PAQ), 'PaqPrecio'] for PAQ in paquetes.index]
)
#restricción 1
'''
Las siguientes tres restricciones asegurarán que la cantidad de cada Producto asignada a cada banda (Oferta de
Compra) sea menor o igual a la cantidad incluida en dicha Oferta de Compra:
'''
for be in demE.index:
demEeaMax = demE.loc[(be), 'DemEeaMax']
model += variables_demE[(be)] <= demEeaMax
for bp in demP.index:
demPotMax = demP.loc[(bp), 'DemPotMax']
model += variables_demP[(bp)] <= demPotMax
for bc in demC.index:
demCelMax = demC.loc[(bc), 'DemCelMax']
model += variables_demC[(bc)] <= demCelMax
'''
La siguiente restricción asegura que los paquetes (Ofertas de Venta) seleccionados contengan una cantidad de
Energía Eléctrica Acumulable suficiente para proporcionar la cantidad asignada a las Ofertas de Compra:
'''
model+= pulp.lpSum([variables_demE[BE] for BE in demE.index]) <= \
pulp.lpSum([(variables_up[PAQ]*paquetes.loc[(PAQ), 'PaqEea']) for PAQ in paquetes.index])
'''
La siguiente restricción asegura que los paquetes (Ofertas de Venta) seleccionados contengan una cantidad de CELs
suficiente para proporcionar la cantidad asignada a las Ofertas de Compra:
'''
model += pulp.lpSum([variables_demC[BC] for BC in demC.index]) <= \
pulp.lpSum([(variables_up[PAQ] * paquetes.loc[(PAQ), 'PaqCel']) for PAQ in paquetes.index])
'''
La siguiente restriccion asegura que los paquetes (Ofertas de Venta) seleccionados contengan una cantidad de
Potencia suficiente para proporcionar la cantidad asignada a las Ofertas de Compra:
'''
for SINT in sistemaInter.index:
model += pulp.lpSum(variables_demP[A] for A in demP.index if demP.loc[A, 'SINT'] == SINT) <= \
pulp.lpSum(variables_up[paq] * paquetes.loc[paq, 'PaqPot'] for paq in paquetes.index
if paquetes.loc[paq, 'PaqZonaP'] == SINT)
'''
Las siguientes restricciones aseguran que la cantidad de potencia en los paquetes seleccionados con fechas
irregulares no rebase el porcentaje definido en las Ofertas de Compra:
'''
for SINT in sistemaInter.index:
model += pulp.lpSum(variables_up[paq] * paquetes.loc[paq, 'PaqPot'] * paquetes.loc[paq, 'PaqFechIrrAnt']
for paq in paquetes.index if paquetes.loc[paq, 'PaqZonaP'] == SINT) <= \
pulp.lpSum(
demP.loc[(A), 'KFechaIrrAntP'] * variables_demP[A] for A in demP.index if demP.loc[A, 'SINT'] == SINT)
for SINT in sistemaInter.index:
model += pulp.lpSum(variables_up[paq] * paquetes.loc[paq, 'PaqPot'] * paquetes.loc[paq, 'PaqFechIrrDesp']
for paq in paquetes.index if paquetes.loc[paq, 'PaqZonaP'] == SINT) <= \
pulp.lpSum(
demP.loc[(A), 'KFechaIrrDespP'] * variables_demP[A] for A in demP.index if demP.loc[A, 'SINT'] == SINT)