There are currently 0 solution(s) in the model

Hy everyone,

I’m trying to solve an allocation problem. I have two objectives: (i) maximize the shift resiliences on a planning horizon and (ii) minimize the resilience variance across the shifts.

So I coded the model presented below:

using JuMP, Gurobi
function solve(problem, name)
    #Parametros
    members = 30        #Team Members
    hours = 24          #Hours of the day
    days = 7            #Days of the week
    weeks = 4           #Weeks of the month
    shifts = 13         #Shifts and Shifts Names
    shifts_name = ["RRTWD_1", "RRTWD_2", "RRTWD_3", "RRTWE_1", "RRTWE_2", 
              "MOCWD_1", "MOCWD_2", "MOCWD_3", "MOCWE_1", "MOCWE_2",
              "NSWD_1", "NSWE_1", "NSWE_2"]
    shift_time = [6, 6, 12, 12, 12, 4, 4, 11, 13, 11, 11, 12, 12]
    resilienceScore = [ 2334.94, 4071.01, 2187.28, 465.52, 1294.25, 1804.09, 6783.05, 
                        2656.37, 2142.94, 433.23, 1403.59, 93.33, 148.42, 174.89, 431.78,
                        212.36, 107.98, 433.23, 87.26, 240.4, 5785.67, 702.58, 589.05, 
                        364.28, 825.32, 1078.85, 647.19, 1064.08, 1048.19, 483.3] 

    #Setup Model
    print("Setting solver parameters...\n")
    model = Model(Gurobi.Optimizer)
    set_optimizer_attribute(model, "TimeLimit", 21600) # 6 Horas
    set_optimizer_attribute(model, "Presolve", 1)
    set_optimizer_attribute(model, "IntFeasTol", 1e-6)    
	set_optimizer_attribute(model, "LogFile", "3-1_logGUROBI-$name.txt")
    set_optimizer_attribute(model, "DualReductions", 0)

    
    #Decision variables
    print("Defining decisions variables...\n")
    @variable(model, x[m = 1:members, s = 1:shifts, w = 1:weeks, d = 1:days], Bin)
    @variable(model, avg_1[w = 1:weeks, d = 1:days, h = 1:hours] >= 0)
    @variable(model, avg_2[w = 1:weeks, d = 1:days, h = 1:hours] >= 0)
    @variable(model, avg_3[w = 1:weeks, d = 1:days, h = 1:hours] >= 0)
    @variable(model, grand_avg[w = 1:weeks, d = 1:days, h = 1:hours] >= 0)

    # =================================================== WORKERS CONSTRAINTS =================================================================
    print("Defining workers constraints...\n")
    for w = 1:weeks, d = 1:days
        if (d == 1)
            @constraint(model, sum((x[m,4,w,d] + sum(x[m,s,w,d] for s = 6:13)) for m = 1:9) == 0)                                       #Workers 1-9
            @constraint(model, sum((sum(x[m,s,w,d] for s = 1:5) + x[m,9,w,d] + sum(x[m,s,w,d] for s = 11:13)) for m = 10:21) == 0)      #Workers 10-21
            @constraint(model, sum(sum(x[m,s,w,d] for s = 6:7) for m = 12:13) == 0)                                                     #Workers 10-21
            @constraint(model, x[14,6,w,d] + x[15,6,w,d] + x[15,7,w,d] + x[10,8,w,d] + x[18,8,w,d] + x[20,8,w,d] == 0)                  #Workers 10-21
            @constraint(model, sum((sum(x[m,s,w,d] for s = 1:10) + x[m,12,w,d]) for m = 22:30) == 0)                                    #Workers 22-30
        elseif ((d > 1 && d < 4) || d == 5)
            @constraint(model, sum(sum(x[m,s,w,d] for s = 4:13) for m = 1:9) == 0)                                      #Workers 1-9
            @constraint(model, sum((sum(x[m,s,w,d] for s = 1:5) + sum(x[m,s,w,d] for s = 9:13)) for m = 10:21) == 0)    #Workers 10-21
            @constraint(model, sum(sum(x[m,s,w,d] for s = 6:7) for m = 12:13) == 0)                                     #Workers 10-21
            @constraint(model, x[14,6,w,d] + x[15,6,w,d] + x[15,7,w,d] + x[10,8,w,d] + x[18,8,w,d] + x[20,8,w,d] == 0)  #Workers 10-21
            @constraint(model, sum((sum(x[m,s,w,d] for s = 1:10) + sum(x[m,s,w,d] for s = 12:13)) for m = 22:30) == 0)  #Workers 22-30 
        elseif (d == 4)
            @constraint(model, sum(sum(x[m,s,w,d] for s = 4:13) for m = 1:9) == 0)                                      #Workers 1-9
            @constraint(model, sum((sum(x[m,s,w,d] for s = 1:5) + sum(x[m,s,w,d] for s = 9:13)) for m = 10:21) == 0)    #Workers 10-21
            @constraint(model, sum(sum(x[m,s,w,d] for s = 6:7) for m = 12:13) == 0)                                     #Workers 10-21
            @constraint(model, x[14,6,w,d] + x[15,6,w,d] + x[15,7,w,d] + x[10,8,w,d] == 0)                              #Workers 10-21
            @constraint(model, x[13,8,w,d] + x[18,8,w,d] + x[20,8,w,d] + x[21,8,w,d]  == 0)                             #Workers 10-21
            @constraint(model, sum((sum(x[m,s,w,d] for s = 1:10) + sum(x[m,s,w,d] for s = 12:13)) for m = 22:30) == 0)  #Workers 22-30 
        elseif (d == 6)
            @constraint(model, sum((sum(x[m,s,w,d] for s = 1:3) + sum(x[m,s,w,d] for s = 6:13)) for m = 1:9) == 0)     #Workers 1-9
            @constraint(model, sum((sum(x[m,s,w,d] for s = 1:7) + sum(x[m,s,w,d] for s = 11:13)) for m = 10:21) == 0)   #Workers 10-21
            @constraint(model, x[10,8,w,d] + x[18,8,w,d] + x[20,8,w,d] + x[12,9,w,d] + x[15,9,w,d] == 0)                #Workers 10-21
            @constraint(model, sum(sum(x[m,s,w,d] for s = 1:11) for m = 22:30) == 0)                                   #Workers 22-30
        elseif (d == 7) 
            @constraint(model, sum((sum(x[m,s,w,d] for s = 1:3) + sum(x[m,s,w,d] for s = 6:13)) for m = 1:9) == 0)       #Workers 1-9
            @constraint(model, sum((sum(x[m,s,w,d] for s = 1:8) + sum(x[m,s,w,d] for s = 11:13)) for m = 10:21) == 0)   #Workers 10-21
            @constraint(model, x[12,9,w,d] + x[15,9,w,d] == 0)                                                          #Workers 10-21
            @constraint(model, sum(sum(x[m,s,w,d] for s = 1:11) for m = 22:30) == 0)                                    #Workers 22-30 
        end
    end

    print("Time limit working constraints...\n")
    for m = 1:9, w = 1:4
        # Shifts that start on one day and end on another - I'll consider that 
        if w < 4
            @constraint(model, x[m,5,w,7] <= x[m,5,w+1,1]) # s5 - s1 (OK)
            @constraint(model, x[m,5,w,7] >= x[m,5,w+1,1]) # s5 - s1 (OK)
        end

        # Shifts allocated
        @constraint(model, x[m, 3, w, 5] + x[m, 4, w, 6] <= 1)      # s3 - s4 (OK)
        @constraint(model, x[m, 4, w, 6] + x[m, 5, w, 6] <= 1)      # s4 - s5 (OK) 
        @constraint(model, x[m, 4, w, 7] + x[m, 5, w, 7] <= 1)      # s4 - s5 (OK)
        @constraint(model, x[m, 5 ,w ,6] + x[m, 4, w, 7] <= 1)      # s4 - s5 (OK)
        @constraint(model, x[m, 5, w, 1] + x[m, 1, w, 1] <= 1)      # s5 - s1 (OK)
        @constraint(model, x[m, 5, w, 1] + x[m, 2, w, 1] <= 1)      # s5 - s2 (OK)      #Adicionei
        for d = 1:5
            @constraint(model, x[m, 1, w, d] + x[m, 3, w, d] <= 1)          # s1 - s3 (OK)
            @constraint(model, x[m, 2, w, d] + x[m, 3, w, d] <= 1)          # s2 - s3 (OK)  #Adicionei
            if d < 5
                @constraint(model, x[m, 3, w, d] + x[m, 1, w, d+1] <= 1)    # s3 - s1 (OK)
                @constraint(model, x[m, 3, w, d] + x[m, 2, w, d+1] <= 1)    # s2 - s1 (OK)  #Adicionei
            end
        end
    end

    for m = 10:21, w = 1:4
        # Shifts that start on one day and end on another 
        if w < 4
            @constraint(model, x[m,10,w,7] >= x[m,10,w+1,1])         # s10 (OK)
            @constraint(model, x[m,10,w,7] <= x[m,10,w+1,1])         # s10 (OK)
        end
        # Shifts allocated
        @constraint(model, x[m, 8, w, 5] + x[m, 9, w, 6] <= 1)       # s8 - s9   (OK)
        @constraint(model, x[m, 9, w, 6] + x[m, 10, w, 6] <= 1)      # s9 - s10 (OK) 
        @constraint(model, x[m, 9, w, 7] + x[m, 10, w, 7] <= 1)      # s9 - s10 (OK)
        @constraint(model, x[m, 10 ,w ,6] + x[m, 9, w, 7] <= 1)      # s9 - s10 (OK)
        @constraint(model, x[m, 10, w, 1] + x[m, 6, w, 1] <= 1)      # s10 - s6  (OK)
        @constraint(model, x[m, 10, w, 1] + x[m, 7, w, 1] <= 1)      # s10 - s7  (OK)
        
        for d = 1:5
            @constraint(model, x[m, 7, w, d] + x[m, 8, w, d] <= 1)          # s7 - s8 (OK)
            @constraint(model, x[m, 6, w, d] + x[m, 8, w, d] <= 1)          # s6 - s8 (OK)
            if d < 5
                @constraint(model, x[m, 8, w, d] + x[m, 6, w, d+1] <= 1)    # s8 - s6 (OK)
                @constraint(model, x[m, 8, w, d] + x[m, 7, w, d+1] <= 1)    # s8 - s7 (OK) 
            end
        end
    end

    for m = 22:30, w = 1:4
        # Shifts that start on one day and end on another - I'll consider that 
        if w < 4
            @constraint(model, x[m, 13, w, 7] <= x[m, 13, w+1, 1])  # s13 (OK)
            @constraint(model, x[m, 13, w, 7] >= x[m, 13, w+1, 1])  # s13 (OK)
        end
        ###@constraint(model, x[m, 11, w, 5] == x[m, 11, w, 6])        # s11 (OK)
        @constraint(model, x[m, 11, w, 5] + x[m, 12, w, 6] <= 1)    # s11 - s12 (OK)
        @constraint(model, x[m, 12, w, 6] + x[m, 13, w, 6] <= 1)    # s12 - s13 (OK) 
        @constraint(model, x[m, 12, w, 7] + x[m, 13, w, 7] <= 1)    # s12 - s13 (OK)
        @constraint(model, x[m, 13, w ,6] + x[m, 12, w, 7] <= 1)    # s12 - s13 (OK)
        ###@constraint(model, x[m, 13, w, 1] + x[m, 11, w, 1] <= 1)    # s11 - s13
    end
    # =========================================================================================================================================
    
    # ================================================== RESILIENCE CONSTRAINTS ===============================================================
    print("Resilience scores constraints...\n")
    #RRT Team - Check
    for w = 1:weeks, d = 1:days, h = 1:hours
        #Day 1
        if (d == 1 && h <= 6)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,5,w,d] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,5,w,d] for m = 1:9) / 9))
        elseif (d == 1 && h > 6 && h <= 12)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,1,w,d] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,1,w,d] for m = 1:9) / 9))
        elseif (d == 1 && h > 12 && h <= 18)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,2,w,d] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,2,w,d] for m = 1:9) / 9))
        elseif (d == 1 && h > 18)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,3,w,d] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,3,w,d] for m = 1:9) / 9))
        end
        #Day 2 to 5
        if (d > 1 && d < 6 && h <= 6)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,3,w,d-1] for m = 1:9)/9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,3,w,d-1] for m = 1:9)/9))
        elseif (d >1 && d < 6 && h > 6 && h <= 12)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,1,w,d] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,1,w,d] for m = 1:9) / 9))
        elseif (d >1 && d < 6 && h > 12 && h <= 18)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,2,w,d] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,2,w,d] for m = 1:9) / 9))
        elseif (d >1 && d < 6 && h > 18)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,3,w,d] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,3,w,d] for m = 1:9) / 9))
        end
        
        #Day 6
        if (d == 6 && h <= 6)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,3,w,d-1] for m = 1:9)/9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,3,w,d-1] for m = 1:9)/9))
        elseif (d == 6 && h > 6 && h <= 18)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,4,w,d] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,4,w,d] for m = 1:9) / 9))
        elseif (d == 6 && h > 18)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,5,w,d] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,5,w,d] for m = 1:9) / 9))
        end

        #Day 7
        if (d == 7 && h <= 6)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,5,w,d-1] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,5,w,d-1] for m = 1:9) / 9))
        elseif (d == 7 && h > 6 && h <= 18)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,4,w,d] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,4,w,d] for m = 1:9) / 9))
        elseif (d == 7 && h > 18)
            @constraint(model, avg_1[w,d,h] <= (sum(resilienceScore[m]*x[m,5,w,d] for m = 1:9) / 9))
            @constraint(model, avg_1[w,d,h] >= (sum(resilienceScore[m]*x[m,5,w,d] for m = 1:9) / 9))
        end
    end

    #MOC Team - Verificar amanhã
    for w = 1:weeks, d = 1:days, h = 1:hours
        #Day 1
        if (d == 1 && h < 8)
            @constraint(model, avg_2[w,d,h] >= (sum(resilienceScore[m]*x[m,10,w,d] for m = 10:21) / 12))
            @constraint(model, avg_2[w,d,h] <= (sum(resilienceScore[m]*x[m,10,w,d] for m = 10:21) / 12))
        elseif (d == 1 && h > 7 && h < 12)
            @constraint(model, avg_2[w,d,h] <= 0)
        elseif (d == 1 && h > 11 && h < 16)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,6,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,6,w,d] for m = 16:21))/8))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,6,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,6,w,d] for m = 16:21))/8))
        elseif (d == 1 && h > 15 && h < 20)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,7,w,d] for m = 10:11) + resilienceScore[14]*x[14,7,w,d] + sum(resilienceScore[m]*x[m,7,w,d] for m = 16:21))/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,7,w,d] for m = 10:11) + resilienceScore[14]*x[14,7,w,d] + sum(resilienceScore[m]*x[m,7,w,d] for m = 16:21))/9))
        elseif (d == 1 && h > 19)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,8,w,d] for m = 11:17) + resilienceScore[19]*x[19,8,w,d] + resilienceScore[21]*x[21,8,w,d])/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,8,w,d] for m = 11:17) + resilienceScore[19]*x[19,8,w,d] + resilienceScore[21]*x[21,8,w,d])/9))
        end

        #Day 2
        if (d == 2 && h < 7)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,8,w,d-1] for m = 11:17) + resilienceScore[19]*x[19,8,w,d-1] + resilienceScore[21]*x[21,8,w,d-1])/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,8,w,d-1] for m = 11:17) + resilienceScore[19]*x[19,8,w,d-1] + resilienceScore[21]*x[21,8,w,d-1])/9))
        elseif (d == 2 && h > 6 && h < 12)
            @constraint(model, avg_2[w,d,h] <= 0)
        elseif (d == 2 && h > 11 && h < 16)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,6,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,6,w,d] for m = 16:21))/8))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,6,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,6,w,d] for m = 16:21))/8))
        elseif (d == 2 && h > 15 && h < 20)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,7,w,d] for m = 10:11) + resilienceScore[14]*x[14,7,w,d] + sum(resilienceScore[m]*x[m,7,w,d] for m = 16:21))/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,7,w,d] for m = 10:11) + resilienceScore[14]*x[14,7,w,d] + sum(resilienceScore[m]*x[m,7,w,d] for m = 16:21))/9))
        elseif (d == 2 && h > 19)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,8,w,d] for m = 11:17) + resilienceScore[19]*x[19,8,w,d] + resilienceScore[21]*x[21,8,w,d])/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,8,w,d] for m = 11:17) + resilienceScore[19]*x[19,8,w,d] + resilienceScore[21]*x[21,8,w,d])/9))
        end

        #Day 3
        if (d == 3 && h < 7)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,8,w,d-1] for m = 11:17) + resilienceScore[19]*x[19,8,w,d-1] + resilienceScore[21]*x[21,8,w,d-1])/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,8,w,d-1] for m = 11:17) + resilienceScore[19]*x[19,8,w,d-1] + resilienceScore[21]*x[21,8,w,d-1])/9))
        elseif (d == 3 && h > 6 && h < 12)
            @constraint(model, avg_2[w,d,h] <= 0)
        elseif (d == 3 && h > 11 && h < 16)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,6,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,6,w,d] for m = 16:21))/8))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,6,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,6,w,d] for m = 16:21))/8))
        elseif (d == 3 && h > 15 && h < 20)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,7,w,d] for m = 10:11) + resilienceScore[14]*x[14,7,w,d] + sum(resilienceScore[m]*x[m,7,w,d] for m = 16:21))/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,7,w,d] for m = 10:11) + resilienceScore[14]*x[14,7,w,d] + sum(resilienceScore[m]*x[m,7,w,d] for m = 16:21))/9))
        elseif (d == 3 && h > 19)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,8,w,d] for m = 11:17) + resilienceScore[19]*x[19,8,w,d] + resilienceScore[21]*x[21,8,w,d])/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,8,w,d] for m = 11:17) + resilienceScore[19]*x[19,8,w,d] + resilienceScore[21]*x[21,8,w,d])/9))
        end

        #Day 4
        if (d == 4 && h < 7)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,8,w,d-1] for m = 11:17) + resilienceScore[19]*x[19,8,w,d-1] + resilienceScore[21]*x[21,8,w,d-1])/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,8,w,d-1] for m = 11:17) + resilienceScore[19]*x[19,8,w,d-1] + resilienceScore[21]*x[21,8,w,d-1])/9))
        elseif (d == 4 && h > 6 && h < 12)
            @constraint(model, avg_2[w,d,h] <= 0)
        elseif (d == 4 && h > 11 && h < 16)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,6,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,6,w,d] for m = 16:21))/8))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,6,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,6,w,d] for m = 16:21))/8))
        elseif (d == 4 && h > 15 && h < 20)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,7,w,d] for m = 10:11) + resilienceScore[14]*x[14,7,w,d] + sum(resilienceScore[m]*x[m,7,w,d] for m = 16:21))/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,7,w,d] for m = 10:11) + resilienceScore[14]*x[14,7,w,d] + sum(resilienceScore[m]*x[m,7,w,d] for m = 16:21))/9))
        elseif (d == 4 && h > 19)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,8,w,d] for m = 11:12) + sum(resilienceScore[m]*x[m,8,w,d] for m = 14:17) + resilienceScore[19]*x[19,8,w,d])/7))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,8,w,d] for m = 11:12) + sum(resilienceScore[m]*x[m,8,w,d] for m = 14:17) + resilienceScore[19]*x[19,8,w,d])/7))
        end

        #Day 5
        if (d == 5 && h < 7)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,8,w,d-1] for m = 11:12) + sum(resilienceScore[m]*x[m,8,w,d-1] for m = 14:17) + resilienceScore[19]*x[19,8,w,d-1])/7))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,8,w,d-1] for m = 11:12) + sum(resilienceScore[m]*x[m,8,w,d-1] for m = 14:17) + resilienceScore[19]*x[19,8,w,d-1])/7))
        elseif (d == 5 && h > 6 && h < 12)
            @constraint(model, avg_2[w,d,h] <= 0)
        elseif (d == 5 && h > 11 && h < 16)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,6,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,6,w,d] for m = 16:21))/8))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,6,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,6,w,d] for m = 16:21))/8))
        elseif (d == 5 && h > 15 && h < 20)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,7,w,d] for m = 10:11) + resilienceScore[14]*x[14,7,w,d] + sum(resilienceScore[m]*x[m,7,w,d] for m = 16:21))/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,7,w,d] for m = 10:11) + resilienceScore[14]*x[14,7,w,d] + sum(resilienceScore[m]*x[m,7,w,d] for m = 16:21))/9))
        elseif (d == 5 && h > 19)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,8,w,d] for m = 11:17) + resilienceScore[19]*x[19,8,w,d] + resilienceScore[21]*x[21,8,w,d])/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,8,w,d] for m = 11:17) + resilienceScore[19]*x[19,8,w,d] + resilienceScore[21]*x[21,8,w,d])/9))
        end

        #Day 6
        if (d == 6 && h < 7)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,8,w,d-1] for m = 11:17) + resilienceScore[19]*x[19,8,w,d-1] + resilienceScore[21]*x[21,8,w,d-1])/9))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,8,w,d-1] for m = 11:17) + resilienceScore[19]*x[19,8,w,d-1] + resilienceScore[21]*x[21,8,w,d-1])/9))
        elseif (d == 6 && h > 7 && h < 21)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,9,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,9,w,d] for m = 13:14) + sum(resilienceScore[m]*x[m,9,w,d] for m = 16:21))/10))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,9,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,9,w,d] for m = 13:14) + sum(resilienceScore[m]*x[m,9,w,d] for m = 16:21))/10))
        elseif (d == 6 && h > 20)
            @constraint(model, avg_2[w,d,h] >= (sum(resilienceScore[m]*x[m,10,w,d] for m = 10:21)/12))
            @constraint(model, avg_2[w,d,h] <= (sum(resilienceScore[m]*x[m,10,w,d] for m = 10:21)/12))
        end

        #Day 7
        if (d == 7 && h < 8)
            @constraint(model, avg_2[w,d,h] >= (sum(resilienceScore[m]*x[m,10,w,d-1] for m = 10:21)/12))
            @constraint(model, avg_2[w,d,h] <= (sum(resilienceScore[m]*x[m,10,w,d-1] for m = 10:21)/12))
        elseif (d == 7 && h > 7 && h < 21)
            @constraint(model, avg_2[w,d,h] >= ((sum(resilienceScore[m]*x[m,9,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,9,w,d] for m = 13:14) + sum(resilienceScore[m]*x[m,9,w,d] for m = 16:21))/10))
            @constraint(model, avg_2[w,d,h] <= ((sum(resilienceScore[m]*x[m,9,w,d] for m = 10:11) + sum(resilienceScore[m]*x[m,9,w,d] for m = 13:14) + sum(resilienceScore[m]*x[m,9,w,d] for m = 16:21))/10))
        elseif (d == 7 && h > 20)
            @constraint(model, avg_2[w,d,h] >= (sum(resilienceScore[m]*x[m,10,w,d] for m = 10:21)/12))
            @constraint(model, avg_2[w,d,h] <= (sum(resilienceScore[m]*x[m,10,w,d] for m = 10:21)/12))
        end
    end

    #NS Team
    for w = 1:weeks, d = 1:days, h = 1:hours
        # Day 1
        if (d == 1 && h < 7)
            @constraint(model, avg_3[w,d,h] <= (sum(resilienceScore[m]*x[m,13,1,d] for m = 22:30) / 9))
            @constraint(model, avg_3[w,d,h] >= (sum(resilienceScore[m]*x[m,13,1,d] for m = 22:30) / 9))
        elseif (d == 1 && h > 6 && h < 20)
            @constraint(model, avg_3[w,d,h] <= 0)
        elseif (d == 1 && h > 19)
            @constraint(model, avg_3[w,d,h] >= (sum(resilienceScore[m]*x[m,11,1,d] for m = 22:30) / 9))
            @constraint(model, avg_3[w,d,h] <= (sum(resilienceScore[m]*x[m,11,1,d] for m = 22:30) / 9))
        end

        #Day 2 to 5
        if (d > 1 && d < 6 && h < 7)
            @constraint(model, avg_3[w,d,h] >= (sum(resilienceScore[m]*x[m,11,1,d-1] for m = 22:30) / 9))
            @constraint(model, avg_3[w,d,h] <= (sum(resilienceScore[m]*x[m,11,1,d-1] for m = 22:30) / 9))
        elseif (d > 1 && d < 6 && h > 6 && h < 20)
            @constraint(model, avg_3[w,d,h] <= 0)
        elseif (d > 1 && d < 6 && h > 19)
            @constraint(model, avg_3[w,d,h] >= (sum(resilienceScore[m]*x[m,11,1,d] for m = 22:30) / 9))
            @constraint(model, avg_3[w,d,h] <= (sum(resilienceScore[m]*x[m,11,1,d] for m = 22:30) / 9))
        end

        #Day 6
        if (d == 6 && h < 7)
            @constraint(model, avg_3[w,d,h] >= (sum(resilienceScore[m]*x[m,11,1,d-1] for m = 22:30) / 9))
            @constraint(model, avg_3[w,d,h] <= (sum(resilienceScore[m]*x[m,11,1,d-1] for m = 22:30) / 9))
        elseif (d == 6 && h > 6 && h < 19)
            @constraint(model, avg_3[w,d,h] >= (sum(resilienceScore[m]*x[m,12,1,d] for m = 22:30) / 9))
            @constraint(model, avg_3[w,d,h] <= (sum(resilienceScore[m]*x[m,12,1,d] for m = 22:30) / 9))
        elseif (d == 6 && h > 18)
            @constraint(model, avg_3[w,d,h] >= (sum(resilienceScore[m]*x[m,13,1,d] for m = 22:30) / 9))
            @constraint(model, avg_3[w,d,h] <= (sum(resilienceScore[m]*x[m,13,1,d] for m = 22:30) / 9))
        end

        #Day 7
        if (d == 7 && h < 7)
            @constraint(model, avg_3[w,d,h] >= (sum(resilienceScore[m]*x[m,13,1,d-1] for m = 22:30) / 9))
            @constraint(model, avg_3[w,d,h] <= (sum(resilienceScore[m]*x[m,13,1,d-1] for m = 22:30) / 9))
        elseif (d == 7 && h > 6 && h < 19)
            @constraint(model, avg_3[w,d,h] >= (sum(resilienceScore[m]*x[m,12,1,d] for m = 22:30) / 9))
            @constraint(model, avg_3[w,d,h] <= (sum(resilienceScore[m]*x[m,12,1,d] for m = 22:30) / 9))
        elseif (d == 7 && h > 18)
            @constraint(model, avg_3[w,d,h] >= (sum(resilienceScore[m]*x[m,13,1,d] for m = 22:30) / 9))
            @constraint(model, avg_3[w,d,h] <= (sum(resilienceScore[m]*x[m,13,1,d] for m = 22:30) / 9))
        end
    end

    #Grand_Avg
    for w = 1:weeks, d = 1:days, h = 1:hours
        @constraint(model, grand_avg[w,d,h] >= ((avg_1[w,d,h] + avg_2[w,d,h] + avg_3[w,d,h]) / 3))
        @constraint(model, grand_avg[w,d,h] <= ((avg_1[w,d,h] + avg_2[w,d,h] + avg_3[w,d,h]) / 3))
    end

   print("Number of workers per shift constraints...\n")
    for w = 1:4, s = 1:13, d = 1:7
        # Workers 1 to 9
        if ((s < 4 && d < 6) || (s == 5 && d == 1) || (s > 3 && s < 6 && d > 5))
            @constraint(model,sum(x[m,s,w,d] for m = 1:9) >= 2)
            @constraint(model,sum(x[m,s,w,d] for m = 1:9) <= 2)
        # Workers 10 to 21
        elseif ((s >= 6 && s <= 8 && d <= 5) || (s == 10 && d == 1) || (s > 8 && s <= 10 && d == 6) || (s >= 9 && s <= 10 && d == 7))
            @constraint(model,sum(x[m,s,w,d] for m = 10:21) >= 1)
            @constraint(model,sum(x[m,s,w,d] for m = 10:21) <= 1)
        # Workers 22 to 30
        elseif ((s == 11 && d < 6) || (s == 12 && d > 5) || (s == 13 && (d == 1 || d > 5)))
            @constraint(model,sum(x[m,s,w,d] for m = 22:30) >= 2)
            @constraint(model,sum(x[m,s,w,d] for m = 22:30) <= 2)
        end
    end

    print("Maximum of hours worked per week constraints...\n")
    # MOC TEAM
    for w = 1:4, m = 10:21
        if (m <= 13 || (m >= 15 && m <= 20)) #10:13 && 15:20
            @constraint(model, (sum(x[m,s,w,d]*shift_time[s] for s = 6:8, d = 1:5) + x[m,10,w,1]*7 + x[m,10,w,6]*11 + x[m,10,w,7]*4 + x[m,9,w,6]*13 + x[m,9,w,7]*13) <= 25)
            @constraint(model, (sum(x[m,s,w,d]*shift_time[s] for s = 6:8, d = 1:5) + x[m,10,w,1]*7 + x[m,10,w,6]*11 + x[m,10,w,7]*4 + x[m,9,w,6]*13 + x[m,9,w,7]*13) >= 12)
        else #14 e 21
            @constraint(model, (sum(x[m,s,w,d]*shift_time[s] for s = 6:8, d = 1:5) + x[m,10,w,1]*7 + x[m,10,w,6]*11 + x[m,10,w,7]*4 + x[m,9,w,6]*13 + x[m,9,w,7]*13) <= 10)
            #@constraint(model, (sum(x[m,s,w,d]*shift_time[s] for s = 6:8, d = 1:5) + x[m,10,w,1]*7 + x[m,10,w,6]*11 + x[m,10,w,7]*4 + x[m,9,w,6]*13) >= 6)
        end
    end
    # RRT TEAM
    for w = 1:4, m = 1:9
        @constraint(model, (sum(x[m,s,w,d]*shift_time[s] for s = 1:3, d = 1:5) + sum(x[m,4,w,d]*shift_time[4] for d = 6:7) + x[m,5,w,6]*12 + 6*(x[m,5,w,1] + x[m,5,w,7])) <= 42)
        @constraint(model, (sum(x[m,s,w,d]*shift_time[s] for s = 1:3, d = 1:5) + sum(x[m,4,w,d]*shift_time[4] for d = 6:7) + x[m,5,w,6]*12 + 6*(x[m,5,w,1] + x[m,5,w,7])) >= 32)
    end
    # NS TEAM
    for w = 1:4, m = 22:30
        @constraint(model, (sum(x[m,11,w,d]*shift_time[11] for d = 1:5) + 12*(x[m,12,w,6] + x[m,13,w,6] + x[m,12,w,7]) + 6*(x[m,13,w,7] + x[m,13,w,1])) <= 40)
        @constraint(model, (sum(x[m,11,w,d]*shift_time[11] for d = 1:5) + 12*(x[m,12,w,6] + x[m,13,w,6] + x[m,12,w,7]) + 6*(x[m,13,w,7] + x[m,13,w,1])) >= 22)
    end
    
   @expression(model, mean_grand_avg, sum(grand_avg[w,d,h] for w = 1:weeks, d = 1:days, h = 1:hours)/(weeks*days*hours))
    @expression(model, variance_grand_avg, sum((grand_avg[w,d,h] - mean_grand_avg)^2 for w = 1:weeks, d = 1:days, h = 1:hours)/((weeks*days*hours)))

    #Objectives - Teams
    if problem == 1
        @objective(model, Max, mean_grand_avg)
    else
        @objective(model, Min, variance_grand_avg)
    end

  println("\n\nSolving mathematical model...")
  optimize!(model)
  status = termination_status(model)

My doubt is related to the first objective. When I tried to run the model, the gurobi solver returned the status of 0 solutions found. But, when I tried to run the model with the second objective, the model returned a feasible solution. Am I letting anything pass? I really don’t understand why the model returned infeasible.

You may want to read the “Solutions” section of the JuMP documentation Solutions · JuMP

A good overview is calling solution_summary(model).

If the solver found a feasible solution for @objective(model, Min, variance_grand_avg) and not for @objective(model, Max, mean_grand_avg), then the most likely answer is that your mean_grand_avg objective is unbounded.

The documentation has a section on how to debug unbounded problems: