(!****************************************************** Mosel Example Problems ====================== file d2ship.mos ``````````````` Choice of wheat load for a ship (c) 2008 Fair Isaac Corporation author: S. Heipcke, Mar. 2002 *******************************************************!) model "D-2 Ship loading" uses "mmxprs" forward procedure print_sol(num:integer) declarations CLIENTS = 1..7 ! Set of clients AVAIL: array(CLIENTS) of integer ! Number of lots per client SIZE: array(CLIENTS) of integer ! Lot sizes PRICE: array(CLIENTS) of integer ! Prices charged to clients COST: array(CLIENTS) of integer ! Cost per client PROF: array(CLIENTS) of integer ! Profit per client CAP: integer ! Capacity of the ship load: array(CLIENTS) of mpvar ! Lots taken from clients end-declarations initializations from 'd2ship.dat' AVAIL SIZE PRICE COST CAP end-initializations forall(c in CLIENTS) PROF(c):= PRICE(c) - COST(c)*SIZE(c) Profit:= sum(c in CLIENTS) PROF(c)*load(c) ! Limit on the capacity of the ship sum(c in CLIENTS) SIZE(c)*load(c) <= CAP ! Problem 1: unlimited availability of lots at clients maximize(Profit) print_sol(1) ! Problem 2: limits on availability of lots at clients forall(c in CLIENTS) load(c) <= AVAIL(c) maximize(Profit) print_sol(2) ! Problem 3: lots must be integer forall(c in CLIENTS) load(c) is_integer maximize(Profit) print_sol(3) !----------------------------------------------------------------- ! Solution printing procedure print_sol(num:integer) writeln("Problem ", num, ": profit: ", getobjval) forall(c in CLIENTS) write( if(getsol(load(c))>0 , " " + c + ":" + getsol(load(c)), "")) writeln end-procedure end-model