%arg -solver glpk %display nonZeros parameters: # Number of pilots pilots:=8; no_pil:= 1..pilots; # Number of languages no_lan:= 1..4; # Number of plane type no_pl_type:= 1..5; # Matrix of language ratings of pilots R_lan[no_pil,no_lan]:= ((20,12,0,0),(14,0,20,0),(0,0,12,0),(13,10,0,0),(0,15,8,17), (0,20,11,0),(8,8,14,0),(8,9,12,16)); # Matrix of ratings of pilot experience of two seater aircraft R_planetype[no_pil,no_pl_type]:= (( 18,10,0,0,0),(12,0,17,0,0),(15,9,0,14,0),(0,14,11,0,0),(0,15,13,0,12),(0,8,10,12,18),(8,12,0,16,0),(0,13,0,0,18)); # test of a valid crew combination due to the language skills {i in no_pil, j in no_pil, i= 10 && R_lan[j,k] >= 10 : valid_lan_combination[i,j,k] := 1; lan_score[i,j,k] := R_lan[i,k] + R_lan[j,k]; | default: valid_lan_combination[i,j,k] := 0; lan_score[i,j,k] := 0; } } max_lan_score[i,j] := max(lan_score[i,j,]); } # test of a valid crew combination due to the plane skills {i in no_pil, j in no_pil,i= 10 && R_planetype[j,m] >= 10 : valid_plane_combination[i,j,m] := 1; plane_score[i,j,m] := R_planetype[i,m]+ R_planetype[j,m]; | default: valid_plane_combination[i,j,m] := 0; plane_score[i,j,m] := 0; } } max_plan_score[i,j] := max(plane_score[i,j,]); } variables: {i in no_pil, j in no_pil, j>i: x[i,j]: binary ;} objectives: sum {i in no_pil, j in no_pil, j>i : (max_lan_score[i,j]+max_plan_score[i,j] )* x[i,j] } -> max ; constraints: con1 {i in no_pil, j in no_pil,i= x[i,j]; #a pilot combination equals one if it fits at least one plane constraints or equals zero sum { m in no_pl_type : valid_plane_combination[i,j,m] } >= x[i,j]; } #a pilot can only be a member of one crew con2 {i in no_pil: sum{ j in no_pil, i