Skip to main content

Infeasible model

Awaiting user input

Comments

4 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • Riley Clement
    • Gurobi Staff

    Hi Ensieh,

    Can you extend your code so that it is a reproducible example?  This will make it easier for someone from the community to lend help.

    - Riley

    0
  • ENSIEH GHAEDYHEIDARY
    • Gurobi-versary
    • First Question
    • First Comment

    Sure! Please see below.

            n = 20
            m = 20
            p = 1
            betha1 = 0.567 / 1000  
            a = np.full(n, 55)
            scale = 4
            v = np.ceil(np.array([1046., 1046., 627.6, 1046., 627.6, 1046., 1046., 627.6,
                            627.6, 627.6, 1046., 627.6, 627.6, 1046., 627.6, 627.6,
                            1046., 627.6, 1046., 1046.]))
            df = pd.read_excel('distances.xlsx')
            d_ij = df.values
            d_ij = np.tile(d_ij, (scale, 1))
            d_jk_l = [40, 440, 20, 0, 60, 170, 50, 30, 80, 340, 50, 390, 90, 90, 110, 70, 300, 50, 1390, 80]
            d_jk = np.array(d_jk_l).reshape(-1, 1)
            D = np.array([626, 241, 178, 151, 151, 78, 87, 62, 60, 48, 53, 39, 32, 35, 40, 20, 27, 30, 28, 37])
            D = np.tile(D, scale)
            D = D.astype('int64')

            c = np.round(np.multiply(betha1, d_jk), 5)  
            t = np.round(np.multiply(betha1, d_ij), 5)  

            Main = Model(name='main') 
            Main.Params.LogToConsole = 0
            Main.Params.MIPGap = 1e-6
            Main.Params.OptimalityTol = 1e-6
            Main.Params.IntFeasTol = 1e-6
            Main.Params.Presolve = 2 
            Main.Params.ImproveStartGap = 1e-6
            Main.Params.NumericFocus = 3 
            
            x = Main.addMVar((m, n), vtype = GRB.BINARY)
            y = Main.addMVar((n, p), vtype = GRB.CONTINUOUS)
            y2 = Main.addMVar((n, p), vtype = GRB.CONTINUOUS)
            z = Main.addMVar((n), vtype = GRB.BINARY)
            D2 = np.power(D, 4)
            Main.setParam("NonConvex", 2)
            
            obj = (quicksum(a[j]*z[j] for j in range (n)) 
                   + quicksum(c[j,k]*(y2[j,k]) for j in range (n) for k in range (p)) 
                   + quicksum(t[i,j]*x[i,j]* (D2[i]) for i in range (m)  for j in range (n)))

            
            Main.setObjective(obj, GRB.MINIMIZE)
            for j in range(n):  
                for k in range(p):  
                    Main.addGenConstrPow(y[j, k], y2[j, k], 4)
                    
            Main.addConstrs(quicksum(x[i, j] for j in range (n)) == 1 for i in range (m))
            Main.addConstrs(quicksum(D[i]*x[i, j] for i in range (m)) == 
                            quicksum(y[j,k] for k in range (p)) for j in range (n))
            Main.addConstrs(y[j,k] >= 0 for j in range (n) for k in range (p))
            Main.addConstrs(y2[j,k] >= 0 for j in range (n) for k in range (p))
            Main.addConstrs(quicksum(y[j,k] for k in range (p)) <= v[j]*z[j] for j in range (n))
            Main.addConstrs(quicksum(D[i]*x[i,j] for i in range (m)) <= v[j]*z[j] for j in range (n))
            Main.optimize() 
            print(Main.objval)

    0
  • Riley Clement
    • Gurobi Staff

    Hi Ensieh,

    df = pd.read_excel('distances.xlsx')

    Your code is not reproducible.

    - Riley

    0

Post is closed for comments.