/* Choose your crew (PuzzlOR problem) in Picat. By John Toczek From http://www.informs.org/ORMS-Today/Public-Articles/April-Volume-38-Number-2/THE-PUZZLOR """ Choose your crew Successfully navigating the waters during sea voyages is a challenging task. A captain’s most important decision is selecting the right crew for the voyage. A mix of different skill sets is required to sail the ship efficiently, navigate to the destination and fish for good along the way. Table 1 shows a list of crew members available for you to hire for the voyage. Each crew member demands a salary for the voyage and has different skill levels of fishing, sailing and navigation. In order for your journey to be successful, you must have a cumulative skill of 15 or more in each of the three skill categories from all of your chosen crew members. You may choose as many crew members as you like. [Table 1 Name Fishing Sailing Navigation Salary (in 1000) ------------------------------------------- Amy 3 5 1 46 Bill 1 2 5 43 Carl 3 4 2 47 Dan 4 3 1 36 Eva 4 2 2 43 Fred 1 3 4 55 Greg 3 1 5 68 Henry 5 4 2 64 Ida 3 3 3 60 What is the minimum achievable cost of the voyage? """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> N = 9, NumSkills = 3, Names = ["Amy" , "Bill", "Carl", "Dan", "Eva", "Fred", "Greg", "Henry", "Ida"], Skills = {{3,5,1}, {1,2,5}, {3,4,2}, {4,3,1}, {4,2,2}, {1,3,4}, {3,1,5}, {5,4,2}, {3,3,3}}, Salary = [46,43,47,36,43,55,68,64,60], MinLimit = 15, % decision variables X = new_list(N), X :: 0..1, TotalCost #= sum([X[I]*Salary[I] : I in 1..N]), SumSkills = new_list(NumSkills), foreach(Skill in 1..NumSkills) SumSkills[Skill] #= sum([Skills[I,Skill]*X[I] : I in 1..N]) end, foreach(Skill in 1..NumSkills) sum([X[I]*Skills[I,Skill] : I in 1..N]) #>= MinLimit end, Vars = X ++ SumSkills, solve($[min(TotalCost)],Vars), println(totalCost=TotalCost), % println(x=X), println("Selected:"), foreach(I in 1..N, X[I] == 1) println([Names[I],salary=Salary[I],skills=Skills[I].to_list]) end, println(sumSkills=SumSkills), nl, nl. go => true.