Dears,
I´m experimenting on CVXPY and have generated a simple Integer Program. For the sake of comparisson I´ve also generated a linear relaxation of it. But, when solving, I get a value for the relaxed problem (1.429). For the integer problem, however, I get -inf. What am I missing?
Thank you!
Follows the code:
import cvxpy as cp
import numpy as np
def make_problem(m, n, integer, name = 'Not named', solve = True, seed = 0):
np.random.seed(seed)
# Generating problem parameters
A = np.random.randn(m, n)
b = np.dot(A, np.ones(n))/2
c = -np.random.randn(n)
# Generation problem variables
x = cp.Variable(n, integer = integer)
# Generating problem objective
obj = cp.Minimize(c.T @ x)
# Generating problem constraints
cstr = [
A @ x <= b,
x >= 0,
x <= 1,
]
# Generating problem
prob = cp.Problem(obj, cstr)
if solve:
prob.solve()
print(f'PROBLEM {name}: STATUS: {prob.status} | VALUE: {prob.value}')
return x
else:
return prob
m = 300
n = 100
x_rlx = make_problem(m, n, integer = False, name = 'Relaxed')
x = make_problem(m, n, integer = True, name = 'Integer')
Output:
PROBLEM Relaxed: STATUS: optimal | VALUE: 1.4295841445033348
PROBLEM Integer: STATUS: unbounded | VALUE: -inf