this repo has no description
at develop 1.2 kB view raw
1int: w = 4; 2int: h = 4; 3 4% Array declaration. 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; 9 10% Temperatura en el punto (i, j). 11array[HEIGHT,WIDTH] of var float: t; 12 13% Temperatura del borde izquierdo. 14var float: left; 15 16% Temperatura del borde derecho. 17var float: right; 18 19% Temperatura del borde superior. 20var float: top; 21 22% Temperatura del borde inferior. 23var float: bottom; 24 25% Ecuación. 26% Ecuación de Laplace: Cada temperatura interna. es la media de sus vecinos. 27constraint forall(i in CHEIGHT, j in CWIDTH)( 28 4.0*t[i,j] = t[i-1,j] + t[i,j-1] + t[i+1,j] + t[i,j+1]); 29% Lados. 30% Restricciones de los bordes. 31constraint forall(i in CHEIGHT)(t[i,0] = left); 32constraint forall(i in CHEIGHT)(t[i,w] = right); 33constraint forall(j in CWIDTH)(t[0,j] = top); 34constraint forall(j in CWIDTH)(t[h,j] = bottom); 35 36% Esquinas. 37% Restricciones de esquinas. 38constraint t[0,0]=0.0; 39constraint t[0,w]=0.0; 40constraint t[h,0]=0.0; 41constraint t[h,w]=0.0; 42left = 0.0; 43right = 0.0; 44top = 100.0; 45bottom = 0.0; 46 47solve satisfy; 48 49output [ show_float(6, 2, t[i,j]) ++ 50 if j == h then "\n" else " " endif | 51 i in HEIGHT, j in WIDTH 52];