I'm currently using pulp-1.4.7 on python 2.6.4 in Windows Seven and
having a problem with the output value of LpInteger variables
(d,dc,dr,ar,at) (actually, it's a binary) which it should return 0 or
1. However, when I've added some constraints (constraint 3.39-3.40) to
the problem, the returned output values is between [0,1].
So my question is "Is Pulp automatically relax the LpInteger to
LpContinuous variable?"
Thank you
Ukyo
The code below presents some parts of my code.
# create an instance to LP problem
prob = LpProblem("sub and power assignment in coding
aware",LpMaximize)
# create variables
z = LpVariable ("z", 0.001, None,
LpContinuous)
r = LpVariable.dicts ("r", (SD_r,T), 0, None,
LpContinuous)
rc= LpVariable.dicts ("r_C", (SDC,T), 0, None,
LpContinuous)
rr= LpVariable.dicts ("r_R", (SDR,T), 0, None,
LpContinuous)
p = LpVariable.dicts ("p", (SD_pd,K,T), 0, None,
LpContinuous)
pc= LpVariable.dicts ("p_C", (SDC,K,T), 0, None, LpContinuous)
pr= LpVariable.dicts ("p_R", (SDR,K,T), 0, None,
LpContinuous)
d = LpVariable.dicts ("d", (SD_pd,K,T), 0, 1,
LpInteger)
dc= LpVariable.dicts ("d_C", (SDC,K,T), 0, 1, LpInteger)
dr= LpVariable.dicts ("d_R", (SDR,K,T), 0, 1,
LpInteger)
ar= LpVariable.dicts ("ar", (V,T), 0, 1,
LpInteger)
at= LpVariable.dicts ("at", (V,T), 0, 1,
LpInteger)
...
#--------------------------------------------------------------
# 7. Transmission and receive constraints
#--------------------------------------------------------------
for t in T:
# --- ar ---
# constraint 3.39 (BS)
prob += C*ar["BS"][t] >= sum([dc["RS,MS1"][k][t]+dr["RS,BS"][k][t]
for k in K]),"Constraint 3.39 (n="+"BS"+",T="+t+")"
# constraint 3.39 (RS)
prob += C*ar["RS"][t] >= sum([d["BS,RS"][k][t]+d["MS1,RS"][k][t]
for k in K]),"Constraint 3.39 (n="+"RS"+",T="+t+")"
# constraint 3.39 (MS1)
prob += C*ar["MS1"][t] >= sum([dc["RS,MS1"][k][t] for k in
K]),"Constraint 3.39 (n="+"MS1"+",T="+t+")"
# --- at ---
# constraint 3.40 (BS)
prob += C*at["BS"][t] >= sum([d["BS,RS"][k][t] for k in
K]),"Constraint 3.40 (n="+"BS"+",T="+t+")"
# constraint 3.40 (RS)
prob += C*at["RS"][t] >= sum([dc["RS,MS1"][k][t]+dr["RS,BS"][k][t]
for k in K]),"Constraint 3.40 (n="+"RS"+",T="+t+")"
# constraint 3.40 (MS1)
prob += C*at["MS1"][t] >= sum([d["MS1,RS"][k][t] for k in
K]),"Constraint 3.40 (n="+"MS1"+",T="+t+")"
for n in V:
# constraint 3.41
prob += ar[n][t]+at[n][t] == 1,"Constraint 3.41 (n="+n+",T="+t
+")"
prob.writeLP("lp_ca_w_time.lp")
# solve the problem using coin
prob.solve()
I suspect that perhaps the problem is infeasible in some way and pulp
does not return the optimal integer solution.
Please check the status returned by LpProblem.solve()
like this
>>> status = prob.solve()
>>> print LpStatus[status]
and see what is returned.
Please see my next Email for a possible solution.
Vinaka
Stu
Note that Integer Infeasible problems are reported as optimal because
the lpsolver in CoinMP will report optimality.
This issue will hopefully be fixed soon on CoinMP but in the mean time
use COIN_CMD or GUROBI as your solver which will report Undefined and
Infeasible status respectively.
Vinaka
Stu