/* Home improvement (PuzzlOR problem) in Picat. From INFORMS, PuzzlOR http://www.informs.org/ORMS-Today/Public-Articles/October-Volume-37-Number-5/PUZZLOR """ By John Toczek Preparing a house for sale may include making home improvements in order to attract buyers and increase the sales price. Some home improvements add profit to the sale of the house but most are not worth the cost. Table 1 lists recently sold houses in your neighborhood. The selling price and any improvements the house had at the time of sale are shown. For example, the first house in the table sold for $181,000 and had a new kitchen, wood floors and new paint. Your house, which you are about to put up for sale, has none of the five listed improvements. You wish to identify the one improvement that will add the most profit to the sale of your house. Installation costs for the improvements are as follows: new bathroom – $10,000; new kitchen – $15,000; pool – $30,000; wood floors – $5,000; new paint – $1,000. Assume that, other than the five improvements, your house is very similar to the houses listed in Table 1 (sqft, land area, # bedrooms, #bathrooms, etc.) and assume all improvements are of the same quality. [Table 1 House New New Pool Wood New Selling bathroom kitchen Floors paint Price --------------------------------------------------------- 181000 Y Y Y 213000 Y Y Y Y 176000 Y Y 169000 Y Y 191000 Y Y Y 187000 Y Y Y 199000 Y Y Y 201000 Y Y Y 200000 Y Y ] """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import mip. main => go. go ?=> NumHouses = 9, NumImprovements = 5, HousePrice = [181000,213000,176000,169000,191000,187000,199000,201000,200000], T = [ [0, 1, 0, 1, 1], [1, 1, 1, 1, 0], [0, 1, 0, 0, 1], [0, 1, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [0, 1, 1, 0, 1], [0, 1, 1, 1, 0], [0, 1, 1, 0, 0] ], InstallationCost = [10000,15000,30000, 5000,1000], X = new_list(NumImprovements), X :: 0..200000, Rest = new_array(NumHouses, NumImprovements), Rest :: -11000..11000, SumRest #= sum([Rest[I,J] : I in 1..NumHouses, J in 1..NumImprovements]), SumRest :: -1000..1000, MaxRest #= max([Rest[I,J] : I in 1..NumHouses, J in 1..NumImprovements]), MaxRest :: 0..10000, foreach(I in 1..NumHouses) sum([(T[I,J]*(X[J]-InstallationCost[J]+Rest[I,J])) : J in 1..NumImprovements]) #= HousePrice[I] end, Vars = X ++ Rest.vars ++ [SumRest,MaxRest], solve($[min(SumRest),ff,split],Vars), println(sumRest=SumRest), println(maxRest=MaxRest), println(x=X), println("Rest:"), foreach(Row in Rest) println(Row) end, nl, nl. go => true.