this repo has no description
1% RUNS ON mzn20_fd 2% RUNS ON mzn-fzn_fd 3% RUNS ON mzn20_fd_linear 4% RUNS ON mzn20_mip 5% 6% Constraint Programming: Mortgage 7% 8% 9% This Minizinc program is written by Hakan Kjellerstrand, hakank@bonetmail.com, 10% and is commented in the (swedish) blog post 11% Constraint Programming: Minizinc, Gecode/flatzinc och ECLiPSe/minizinc 12% http://www.hakank.org/webblogg/archives/001209.html 13% 14% See also my MiniZinc page: http://www.hakank.org/minizinc 15% 16% Marriot & Stuckey: Programming with Constraints, page 175f 17% (famous early example) 18% 19% Since Minizinc don't allow recursion, it is implemented as an array. 20% 21% This example shows the flexibility of Minizinc: 22% the same code can calculate P, R _or_ I with just a simple change of the declarations. 23% 24% 25% Calculates P, given I and R: 26% P: 373.02779864763335 27% 28% Calculates R, given P and I: 29% R: 149.944102252456 (which is close to 150) 30% 31% Calculates I, given R and P: 32% I: 0.099995922287248337__0.10000424331679297 (close to 0.1) 33 34% Note: As of 2008-06-23 this don't work in version >= 0.8. 35% It may work with later version, though. 36 37int: T = 3; % time period 38 39% comment one of the initiations to calculate it: 40var 0.0..10000.0: I = 10.0/100.0; 41var 0.0..10000.0: R = 150.0; 42var 0.0..10000.0: P; % = 373.02779864763318; 43 44array[1..T] of var float: mortgage; 45 46solve satisfy; 47% solve minimize P; 48 49constraint 50 % start value: 51 mortgage[1] = P + (P * I) - R /\ 52 forall(i in 2..T) ( 53 % calculate the next value using a local variable 54 let { 55 var float: NP = mortgage[i-1] + (mortgage[i-1] * I) - R 56 } 57 in 58 mortgage[i] = NP /\ NP >= 0.0 59 ) 60; 61 62output [ 63 "P: ", show(P), "\n", 64 "I: ", show(I), "\n", 65 "R: ", show(R), "\n", 66 "mortgage: ", show(mortgage),"\n" % is not especially interesting 67];