Пример #1
0
def testsolve(Q,
              W,
              K,
              R,
              mR,
              M,
              P,
              teams,
              resource2team,
              T,
              maxT,
              E,
              C,
              U_plus,
              U_minus,
              N_wk,
              shift,
              mr,
              ar,
              phi,
              TeamConstr=False):

    start_time = time.time()

    print "============================ FULL LP relaxation =============================="
    obj_relax, n_value0, overflow_value0, y_value0, s_value0, p, attset, f, tl = LPsolver(
        W,
        K,
        R,
        mR,
        M,
        P,
        teams,
        resource2team,
        T,
        E,
        C,
        U_plus,
        U_minus,
        N_wk,
        shift,
        mr,
        ar,
        phi,
        integer=1,
        OverConstr=True,
        TeamConstr=TeamConstr,
        MaxT=maxT,
        Q=Q)

    minr = np.zeros((W, R))

    for w in range(W):
        for r in range(R):
            minr[w][r] = math.floor(y_value0[w][r])
            print y_value0[w][r]

    print "============================ Binary Y / single relaxed n_wtk (allocated arrivals) MIP ======================"
    [x] = KStrategiesY(Q,
                       W,
                       K,
                       R,
                       mR,
                       M,
                       P,
                       teams,
                       resource2team,
                       T,
                       maxT,
                       E,
                       C,
                       U_plus,
                       U_minus,
                       N_wk,
                       shift,
                       mr,
                       minr,
                       ar,
                       phi,
                       integer=0,
                       OverConstr=False,
                       TeamConstr=TeamConstr),
    #objy, n_value, overflow_value, y_value, ys,  s_value, p_value, q, t1

    [objy, y_value, ys, s_value, p_value, q,
     t1] = [x[0], x[3], x[4], x[5], x[6], x[7], x[8]]

    [x1] = KStrategiesY(Q + 1,
                        W,
                        K,
                        R,
                        mR,
                        M,
                        P,
                        teams,
                        resource2team,
                        T,
                        maxT,
                        E,
                        C,
                        U_plus,
                        U_minus,
                        N_wk,
                        shift,
                        mr,
                        minr,
                        ar,
                        phi,
                        integer=0,
                        OverConstr=False,
                        TeamConstr=TeamConstr),
    #objy, n_value, overflow_value, y_value, ys,  s_value, p_value, q, t1

    [objy2, y_value2, ys2, s_value2, p_value2, q2,
     t12] = [x1[0], x1[3], x1[4], x1[5], x1[6], x1[7], x1[8]]
    print objy, objy2
    print q
    print q2

    print y_value
    print y_value2
    #return [obj_relax, objy, objy2 ],  q, [tl, t1, t12]

    objyn, n_val, n, t2 = KStrategiesYN(Q,
                                        W,
                                        K,
                                        R,
                                        M,
                                        P,
                                        resource2team,
                                        T,
                                        maxT,
                                        E,
                                        C,
                                        U_plus,
                                        U_minus,
                                        N_wk,
                                        shift,
                                        mr,
                                        y_value,
                                        ys,
                                        q,
                                        p_value,
                                        s_value,
                                        ar,
                                        phi,
                                        integer=0,
                                        OverConstr=False,
                                        OverConstr2=False)
    objyn3, n_val, n, t2 = KStrategiesYN(Q + 1,
                                         W,
                                         K,
                                         R,
                                         M,
                                         P,
                                         resource2team,
                                         T,
                                         maxT,
                                         E,
                                         C,
                                         U_plus,
                                         U_minus,
                                         N_wk,
                                         shift,
                                         mr,
                                         y_value2,
                                         ys2,
                                         q2,
                                         p_value2,
                                         s_value2,
                                         ar,
                                         phi,
                                         integer=0,
                                         OverConstr=False,
                                         OverConstr2=False)

    print objyn, objyn3
Пример #2
0
def solve(Q,
          W,
          K,
          R,
          mR,
          M,
          P,
          teams,
          resource2team,
          T,
          maxT,
          E,
          C,
          U_plus,
          U_minus,
          N_wk,
          shift,
          mr,
          ar,
          phi,
          TeamConstr=False,
          YConstr=True):

    start_time = time.time()

    print "============================ FULL LP relaxation =============================="
    obj_relax, n_value0, overflow_value0, y_value0, s_value0, p, attset, f, tl = LPsolver(
        W,
        K,
        R,
        mR,
        M,
        P,
        teams,
        resource2team,
        T,
        E,
        C,
        U_plus,
        U_minus,
        N_wk,
        shift,
        mr,
        ar,
        phi,
        integer=1,
        OverConstr=False,
        TeamConstr=TeamConstr,
        MaxT=maxT,
        Q=Q)

    minr = np.zeros((W, R))

    for w in range(W):
        for r in range(R):
            minr[w][r] = math.floor(y_value0[w][r])
            print y_value0[w][r]

    print "============================ Binary Y / single relaxed n_wtk (allocated arrivals) MIP ======================"
    [x] = KStrategiesY(Q,
                       W,
                       K,
                       R,
                       mR,
                       M,
                       P,
                       teams,
                       resource2team,
                       T,
                       maxT,
                       E,
                       C,
                       U_plus,
                       U_minus,
                       N_wk,
                       shift,
                       mr,
                       minr,
                       ar,
                       phi,
                       integer=0,
                       OverConstr=False,
                       TeamConstr=TeamConstr,
                       YConstr=YConstr),
    #objy, n_value, overflow_value, y_value, ys,  s_value, p_value, q, t1

    [objy, y_value, ys, s_value, p_value, q,
     t1] = [x[0], x[3], x[4], x[5], x[6], x[7], x[8]]
    print "============================ multiple relaxed n_wtk (allocated arrivals) MIP ==============================="

    objyn, n_val, n, t2 = KStrategiesYN(Q,
                                        W,
                                        K,
                                        R,
                                        M,
                                        P,
                                        resource2team,
                                        T,
                                        maxT,
                                        E,
                                        C,
                                        U_plus,
                                        U_minus,
                                        N_wk,
                                        shift,
                                        mr,
                                        y_value,
                                        ys,
                                        q,
                                        p_value,
                                        s_value,
                                        ar,
                                        phi,
                                        integer=0,
                                        OverConstr=False,
                                        OverConstr2=False)

    minn = np.zeros((Q, W, T, K))

    for i in range(Q):
        for w in range(W):
            for k in range(K):
                sum = 0
                for t in range(T):
                    minn[i][w][t][k] = math.floor(n[i][w][t][k])
                    sum += math.floor(n[i][w][t][k])

    print "============================ Integer n_wtk  MIP ==============================="

    obj, rt, q, t3 = KStrategiesYNB(Q,
                                    W,
                                    K,
                                    R,
                                    M,
                                    resource2team,
                                    T,
                                    maxT,
                                    E,
                                    C,
                                    U_plus,
                                    U_minus,
                                    N_wk,
                                    y_value,
                                    ys,
                                    minn,
                                    p,
                                    s_value,
                                    phi,
                                    integer=0,
                                    OverConstr=False,
                                    OverConstr2=False)
    walltime = time.time() - start_time

    print "Runtime/walltime ", rt, " ", walltime

    print obj_relax, objy, objyn, obj

    return [obj_relax, objy, objyn, obj], walltime, q, [tl, t1, t2, t3]
Пример #3
0
def solve(Q,
          W,
          K,
          R,
          mR,
          M,
          P,
          teams,
          resource2team,
          T,
          maxT,
          E,
          C,
          U_plus,
          U_minus,
          N_wk,
          shift,
          mr,
          ar,
          phi,
          verbose=True):

    start_time = time.time()

    minr = np.zeros((W, R))

    obj_relax, n_value0, overflow_value0, y_value0, s_value0, p, attset, f, tl = LPsolver(
        W,
        K,
        R,
        mR,
        M,
        P,
        teams,
        resource2team,
        T,
        E,
        C,
        U_plus,
        U_minus,
        N_wk,
        shift,
        mr,
        ar,
        phi,
        integer=1,
        OverConstr=False,
        TeamConstr=False,
        MaxT=maxT,
        Q=Q,
        verbose=verbose)

    minr = np.zeros((W, R))
    minn = np.zeros((W, T, K))
    for w in range(W):
        for r in range(R):
            minr[w][r] = math.floor(y_value0[w][r])
        for k in range(K):
            for t in range(T):
                minn[w][t][k] = math.floor(n_value0[w][t][k])
    q_val = np.zeros(Q)
    for i in range(Q):
        q_val[i] = float(1) / Q

    obj, n_value, ns_value, team_val = FixedQ(Q,
                                              W,
                                              K,
                                              R,
                                              M,
                                              P,
                                              minr,
                                              minn,
                                              q_val,
                                              resource2team,
                                              T,
                                              maxT,
                                              E,
                                              C,
                                              U_plus,
                                              U_minus,
                                              N_wk,
                                              shift,
                                              mr,
                                              ar,
                                              phi,
                                              False,
                                              False,
                                              verbose=verbose)
    rt = time.time() - start_time

    return obj, rt
Пример #4
0
    seed = 2345
    resource2team, T, E, C, U_plus, U_minus, N_wk, shift, mr, minr, ar, phi = randomSetting(
        seed, W, K, R, mR, M, P, teams, shift)

    print "============================ LP relaxation =============================="
    obj_relax, n_value0, overflow_value0, y_value0, s_value0, p, attset, f = LPsolver(
        W,
        K,
        R,
        mR,
        M,
        P,
        teams,
        resource2team,
        T,
        E,
        C,
        U_plus,
        U_minus,
        N_wk,
        shift,
        mr,
        ar,
        phi,
        integer=1,
        OverConstr=True)
    for w in range(W):
        for r in range(R):
            minr[w][r] = math.floor(y_value0[w][r])
            print y_value0[w][r]
Пример #5
0
    #pickle.dump( lst, open( "data.p", "wb" ) )
    [
        W, K, R, mR, M, P, teams, resource2team, T, E, C, U_plus, U_minus,
        N_wk, shift, mr, ar, phi
    ] = pickle.load(open("data.p", "rb"))
    print "============================ LP relaxation =============================="
    obj_relaxed, n, o, y, s, p, att_set1, f = LPsolver(W,
                                                       K,
                                                       R,
                                                       mR,
                                                       M,
                                                       P,
                                                       teams,
                                                       resource2team,
                                                       T,
                                                       E,
                                                       C,
                                                       U_plus,
                                                       U_minus,
                                                       N_wk,
                                                       shift,
                                                       mr,
                                                       ar,
                                                       phi,
                                                       integer=0,
                                                       OverConstr=False)

    start_time = time.time()
    print "============================ MIP SOLVER =============================="

    obj, rt, q, n2, o, att_set = Ksolver(W,
                                         K,