Pulp obtains results as problem is infeasible, while problem is not feasible

Viewed 536

I'm trying to solve an assignment problem with pulp. The basic part of the code is as follows:


set_I = range(1, numberOfPoints)
set_J = range(1, numberOfCentroids)

tau = 0.15
Q = 15

# decision variable
x_vars = LpVariable.dicts(name="x_vars", indexs=(set_I, set_J), lowBound=0, upBound=1, cat=LpInteger)

# model name
prob = LpProblem("MIP_Model", LpMinimize)

# constraints
for i in set_I:
   prob += lpSum(x_vars[i][j] for j in set_J) == 1, ""

for j in set_J:
   prob += lpSum(x_vars[i][j] for i in set_I) >= 1, ""

for j in set_J:
   prob += lpSum(x_vars[i][j] for i in set_I) <= Q*(1-tau), ""

for j in set_J:
   prob += lpSum(x_vars[i][j] for i in set_I) >= Q*(1+tau), ""

# objective
prob += lpSum(d[i, j]*x_vars[i][j] for i in set_I for j in set_J)

prob.solve()

The result is like this:

Problem MODEL has 31 rows, 76 columns and 304 elements

Coin0008I MODEL read with 0 errors

Problem is infeasible - 0.01 seconds

Option for printingOptions changed from normal to all

However, the problem is not infeasible and results are obtained with other solvers.

I wonder if there is a syntax error and is the problem caused by this?

I have asked a similar question in the next link:

Infeasible solution by pulp

1 Answers

When I run the problem locally, with d a matrix of ones, 20 points, and 3 centroids. It also becomes infeasible for me. Look at the constraints:

_C22: x_vars_10_1 + x_vars_11_1 + x_vars_12_1 + x_vars_13_1 + x_vars_14_1
 + x_vars_15_1 + x_vars_16_1 + x_vars_17_1 + x_vars_18_1 + x_vars_19_1
 + x_vars_1_1 + x_vars_2_1 + x_vars_3_1 + x_vars_4_1 + x_vars_5_1 + x_vars_6_1
 + x_vars_7_1 + x_vars_8_1 + x_vars_9_1 <= 12.75

_C23: x_vars_10_2 + x_vars_11_2 + x_vars_12_2 + x_vars_13_2 + x_vars_14_2
 + x_vars_15_2 + x_vars_16_2 + x_vars_17_2 + x_vars_18_2 + x_vars_19_2
 + x_vars_1_2 + x_vars_2_2 + x_vars_3_2 + x_vars_4_2 + x_vars_5_2 + x_vars_6_2
 + x_vars_7_2 + x_vars_8_2 + x_vars_9_2 <= 12.75

_C24: x_vars_10_1 + x_vars_11_1 + x_vars_12_1 + x_vars_13_1 + x_vars_14_1
 + x_vars_15_1 + x_vars_16_1 + x_vars_17_1 + x_vars_18_1 + x_vars_19_1
 + x_vars_1_1 + x_vars_2_1 + x_vars_3_1 + x_vars_4_1 + x_vars_5_1 + x_vars_6_1
 + x_vars_7_1 + x_vars_8_1 + x_vars_9_1 >= 17.25

_C25: x_vars_10_2 + x_vars_11_2 + x_vars_12_2 + x_vars_13_2 + x_vars_14_2
 + x_vars_15_2 + x_vars_16_2 + x_vars_17_2 + x_vars_18_2 + x_vars_19_2
 + x_vars_1_2 + x_vars_2_2 + x_vars_3_2 + x_vars_4_2 + x_vars_5_2 + x_vars_6_2
 + x_vars_7_2 + x_vars_8_2 + x_vars_9_2 >= 17.25

You require

x_vars_10_2 + x_vars_11_2 + x_vars_12_2 + x_vars_13_2 + x_vars_14_2
 + x_vars_15_2 + x_vars_16_2 + x_vars_17_2 + x_vars_18_2 + x_vars_19_2
 + x_vars_1_2 + x_vars_2_2 + x_vars_3_2 + x_vars_4_2 + x_vars_5_2 + x_vars_6_2
 + x_vars_7_2 + x_vars_8_2 + x_vars_9_2

to be greater than 17.25 and smaller than 12.75 at the same time. That's not possible, of course.

Related