/* The Birthday problem in Picat. From http://www.mcs.vuw.ac.nz/courses/OPRE251/2006T1/Labs/lab12.pdf """ The Birthday Frank is hurrying home late, after a particularly grueling day, when it pops into his mind that today is Kitty's birthday! Or is it? Everything is closed except the florist. If it is not her birthday and he brings no gift, the situation will be neutral, i.e., payoff 0. If it is not her birthday and he comes in bursting with roses, and obviously confused, she may be very suspicious, a payoff of say -1. If it is her birthday and he has, clearly, remembered it, that is worth say 2. If he has forgotten it, he is down like a stone, say, -10. So Frank mentally forms the payoff matrix: Nature Not Birthday Birthday Nothing 0 -10 Frank Flowers -1 2 """ Result: x[1] (Nothing) yield 0.230769230769231 x[2] (Flowers) yield 0.769230769230769 is - of course - the way to do. This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import mip. main => go. go => M = [ % Nature % Not Birthday Birthday [ 0, -10 ], % Frank: Nothing [ -1, 2 ] % Frank: Flowers ], X = new_list(2), X :: 0.0..1.0, V :: -1.0..1.0, foreach(J in 1..2) V #<= sum([M[I,J]*X[I] : I in 1..2]) end, sum(X) #= 1.0, Vars = X ++ V, solve($[max(V)],Vars), println(x=X), println(v=V), nl.