this repo has no description
1int: w = 4; 2int: h = 4; 3 4% arraydec 5set of int: HEIGHT = 0..h; 6set of int: CHEIGHT = 1..h-1; 7set of int: WIDTH = 0..w; 8set of int: CWIDTH = 1..w-1; 9array[HEIGHT,WIDTH] of var float: t; % temperature at point (i,j) 10var float: left; % left edge temperature 11var float: right; % right edge temperature 12var float: top; % top edge temperature 13var float: bottom; % bottom edge temperature 14 15% equation 16% Laplace equation: each internal temp. is average of its neighbours 17constraint forall(i in CHEIGHT, j in CWIDTH)( 18 4.0*t[i,j] = t[i-1,j] + t[i,j-1] + t[i+1,j] + t[i,j+1]); 19% sides 20% edge constraints 21constraint forall(i in CHEIGHT)(t[i,0] = left); 22constraint forall(i in CHEIGHT)(t[i,w] = right); 23constraint forall(j in CWIDTH)(t[0,j] = top); 24constraint forall(j in CWIDTH)(t[h,j] = bottom); 25% corners 26% corner constraints 27constraint t[0,0]=0.0; 28constraint t[0,w]=0.0; 29constraint t[h,0]=0.0; 30constraint t[h,w]=0.0; 31left = 0.0; 32right = 0.0; 33top = 100.0; 34bottom = 0.0; 35 36solve satisfy; 37 38output [ show_float(6, 2, t[i,j]) ++ 39 if j == w then "\n" else " " endif | 40 i in HEIGHT, j in WIDTH 41];