(!****************************************************** Mosel Example Problems ====================== file b1stadium.mos `````````````````` Construction of a stadium A town is planning to build a new stadium and need to determine the earliest it can be completed. Additionally, the town would like to project to finish earlier than the initial estimate. The town is prepared to pay the builder a bonus for every week the project completes early. Each task has a max week reduction with added costs. The second problem determines when the project will finish if the builder maximizes their profit. The first problem is a classical project scheduling problem. To define the relationship between tasks, we create an array 'ARC' and define constraints for related tasks. The second problem is called 'scheduling with project crashing' and it requires the result of the first problem. The new variable 'advance' is introduced to represent how many weeks early each task can be finished. (c) 2008 Fair Isaac Corporation author: S. Heipcke, Mar. 2002, rev. Oct 2009 *******************************************************!) model "B-1 Stadium construction" uses "mmxprs" forward procedure printsol declarations N = 19 ! Number of tasks in the project ! (last = fictitious end task) TASKS=1..N ARC: dynamic array(TASKS,TASKS) of real ! Matrix of the adjacency graph DUR: array(TASKS) of real ! Duration of tasks start: array(TASKS) of mpvar ! Start times of tasks obj1: real ! Solution of first problem end-declarations initializations from 'b1stadium.dat' ARC DUR end-initializations ! Precedence relations between tasks forall(i,j in TASKS | exists(ARC(i,j))) Prec(i,j):= start(j) - start(i) >= DUR(i) ! Solve the first problem: minimize the total duration minimize(start(N)) obj1:=getobjval ! Solution printing printsol ! **** Extend the problem **** declarations BONUS: integer ! Bonus per week finished earlier MAXW: array(TASKS) of real ! Max. reduction of tasks (in weeks) COST: array(TASKS) of real ! Cost of reducing tasks by a week advance: array(TASKS) of mpvar ! Number of weeks finished early end-declarations initializations from 'b1stadium.dat' MAXW BONUS COST end-initializations ! Second objective function Profit:= BONUS*advance(N) - sum(i in 1..N-1) COST(i)*advance(i) ! Redefine precedence relations between tasks forall(i,j in TASKS | exists(ARC(i,j))) Prec(i,j):= start(j) - start(i) + advance(i) >= DUR(i) ! Total duration start(N) + advance(N) = obj1 ! Limit on number of weeks that may be saved forall(i in 1..N-1) advance(i) <= MAXW(i) ! Solve the second problem: maximize the total profit maximize(Profit) ! Solution printing writeln("Total profit: ", getsol(Profit)) printsol !----------------------------------------------------------------- procedure printsol writeln("Total duration: ", getsol(start(N)), " weeks") forall(i in 1..N-1) write(strfmt(i,2), ": ", strfmt(getsol(start(i)),-3), if(i mod 9 = 0,"\n","")) writeln end-procedure end-model