model "Tanker Scheduling" uses "mmxprs" ! Use Xpress-Optimizer declarations n=4 !# of cargoes T=3 !# of tankers S=5 !# of possible schedules for each tanker CARGOES = 1..n !set of cargoes TANKERS = 1..T !Set of tankers SCHEDULES = 1..S !set of schedules for each tanker a: array(TANKERS, CARGOES, SCHEDULES) of integer COST_OWN: array(TANKERS, SCHEDULES) of real COST_RENT: array(CARGOES) of real PROFIT: array(TANKERS, SCHEDULES) of real x: array(TANKERS, SCHEDULES) of mpvar end-declarations initializations from 'tanker_data.dat' a COST_OWN COST_RENT end-initializations forall(i in TANKERS, l in SCHEDULES) PROFIT(i,l):= (sum(j in CARGOES) a(i,j,l)*COST_RENT(j)) - COST_OWN(i,l) ! Objective: total return Return:= sum(i in TANKERS, l in SCHEDULES) PROFIT(i,l)*x(i,l) forall(j in CARGOES) sum(i in TANKERS, l in SCHEDULES) a(i,j,l)*x(i,l) <= 1 forall(i in TANKERS) sum(l in SCHEDULES) x(i,l) <= 1 forall(i in TANKERS, l in SCHEDULES) x(i,l) is_binary ! Solve the problem maximize(Return) ! Solution printing writeln("profit: ", getobjval) forall(i in TANKERS, l in SCHEDULES) writeln("x(",i,",",l,") = ", getsol(x(i,l))) end-model