/* Capital budgeting in Picat. Winston Operations Research, page 478: Capital budgeting and some extra constraint (page 479): either one of: - can only make two investments - if investment 2 then investment 1 - if investment 2 then not investment 4 This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ % import util. import cp. main => go. go => Budget = 14, Npv = [16,22,12,8], % Net Present Value CashFlow = [5,7,4,3], % the cash_flow for each investment N = CashFlow.len, % variables X = new_list(N), % X[I] = 1 if investment i X :: 0..1, Z #= sum([(X[I]*Npv[I]) : I in 1..N]), % the sum of all choosen investments must be less than the budget sum([X[I] * CashFlow[I] : I in 1..N]) #<= Budget, % the extra constraints % only two investments sum([X[I] : I in 1..N]) #= 2, % if investment 2 -> investment 1 X[2] #= 1 #=> X[1] #= 1, % X[1] #>= X[2], % alternative (integer programming) way % if investment 2 then not investment 4 X[2] #= 1 #=> X[4] #= 0, % X[4] + X[2] #<= 1, % IP way solve($[max(Z)], X), println(z=Z), println(x=X), nl.