3

I am currently trying to estimate a model in some academic work I am doing but having some issues getting it to actually estimate in Gurobi, which is currently returning an infeasibility result.

For starters, I am trying to optimize the following model: Image of the optimization problem

Where Yi are integers.

With the following constraints: Constraint 1 Constraint 2

Where Xi variables are positive valued integers, b is a vector of coefficient estimates that can be positive or negative valued, and cj are any real number subject to the above constraints.

I've tried running the following code multiple times including dropping some/all of the constraints and it continues to return an infeasible result. I'll admit, I am just getting started with linear programming and Gurobi and could really use a second pair of eyes on this to see if maybe I am just formatting something wrong. I am also happy to provide more info for whatever is relevant! The academic source for this model can be found here: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3349935

#Generate model
opt_model = grb.Model(name = "Median Regression Estimation")

#Generate decision variables
d_vars = {(i,j): opt_model.addVar(vtype=grb.GRB.BINARY,
                                 name = "x_{0}_{1}".format(i,j))
         for i in set_I for j in set_J}

c_vars = {j: opt_model.addVar(vtype=grb.GRB.CONTINUOUS,
                                 lb = grb.GRB.INFINITY,
                                 ub = grb.GRB.INFINITY,
                                 name = "x_{0}".format(j))
          for j in set_J}

b1 = opt_model.addVar(vtype=grb.GRB.CONTINUOUS, lb= grb.GRB.INFINITY, ub = grb.GRB.INFINITY, name="beta_1")

b2 = opt_model.addVar(vtype=grb.GRB.CONTINUOUS, lb= grb.GRB.INFINITY, ub = grb.GRB.INFINITY, name="beta_2")

b3 = opt_model.addVar(vtype=grb.GRB.CONTINUOUS, lb= grb.GRB.INFINITY, ub = grb.GRB.INFINITY, name="beta_3")

b4 = opt_model.addVar(vtype=grb.GRB.CONTINUOUS, lb= grb.GRB.INFINITY, ub = grb.GRB.INFINITY, name="beta_4")

#Set objective
objective = grb.quicksum(((np.abs(y[i,j]-j)-np.abs(y[i,j]-j-1))*d_vars[i,j])
                              for i in set_I 
                              for j in set_J)

#Define Constraints
constraints_1 = {(i,j) :
              opt_model.addLConstr(
              lhs=d_vars[i,j],
              sense = grb.GRB.LESS_EQUAL,
              rhs = d_vars[i,j+1],
              name="d_constraint_{0}_{1}".format(i,j))
              for i in set_I for j in set_J_alt}


constraints_2 = {j :
              opt_model.addLConstr(
              lhs=c_vars[j],
              sense = grb.GRB.LESS_EQUAL,
              rhs = c_vars[j+1],
              name="c_constraint_{0}".format(j))
              for j in set_J_alt}


constraints_3 = {(i,j) : opt_model.addGenConstrIndicator(d_vars[i,j], 
                                                         True,
                                                         g[i,j] + treat2[i,j]*b1 + treat3[i,j]*b2 + l[i,j]*b3 + t[i,j]*b4 - c_vars[j],
                                                         grb.GRB.LESS_EQUAL,
                                                         0) for i in set_I for j in set_J}

opt_model.ModelSense = grb.GRB.MINIMIZE

opt_model.setObjective(objective)

opt_model.optimize()

Currently running this returns the following output

Gurobi Optimizer version 9.1.1 build v9.1.1rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 0 rows, 1159 columns and 0 nonzeros
Model fingerprint: 0x9033f4d8
Model has 1150 general constraints
Variable types: 9 continuous, 1150 integer (1150 binary)
Coefficient statistics:
  Matrix range     [0e+00, 0e+00]
  Objective range  [1e+00, 1e+00]
  Bounds range     [1e+00, 1e+00]
  RHS range        [0e+00, 0e+00]
Presolve time: 0.00s

Explored 0 nodes (0 simplex iterations) in 0.01 seconds
Thread count was 1 (of 8 available processors)

Solution count 0

Model is infeasible
Best objective -, best bound -, gap -

0 Answers0