# include # include # include # include # include "polyomino_lp_write.h" int main ( ); void polyomino_monohedral_example_reid_size ( int *m, int *n ); void polyomino_monohedral_example_reid_system ( int m, int n, int a[], int b[] ); void i4mat_copy ( int m, int n, int a1[], int a2[] ); void i4vec_copy ( int n, int a1[], int a2[] ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: MAIN is the main program for POLYOMINO_LP_WRITE_TEST. Discussion: POLYOMINO_LP_WRITE_TEST tests POLYOMINO_LP_WRITE. Licensing: This code is distributed under the GNU LGPL license. Modified: 17 May 2018 Author: John Burkardt */ { int *a; int *b; char filename[] = "reid.lp"; char label[] = "\\ LP file for the Reid example, created by POLYOMINO_LP_WRITE."; int m; int n; timestamp ( ); printf ( "\n" ); printf ( "POLYOMINO_LP_WRITE_TEST:\n" ); printf ( " C version\n" ); printf ( " POLYOMINO_LP_WRITE writes an LP file associated\n" ); printf ( " with a binary programming problem for tiling a region\n" ); printf ( " with copies of a single polyomino.\n" ); /* Get the coefficients and right hand side for the Reid system. */ polyomino_monohedral_example_reid_size ( &m, &n ); a = ( int * ) malloc ( m * n * sizeof ( int ) ); b = ( int * ) malloc ( m * sizeof ( int ) ); polyomino_monohedral_example_reid_system ( m, n, a, b ); /* Create the LP file. */ polyomino_lp_write ( filename, label, m, n, a, b ); printf ( "\n" ); printf ( " Created the LP file '%s'\n", filename ); /* Free memory. */ free ( a ); free ( b ); /* Terminate. */ printf ( "\n" ); printf ( "POLYOMINO_LP_WRITE_TEST:\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void polyomino_monohedral_example_reid_size ( int *m, int *n ) /******************************************************************************/ /* Purpose: POLYOMINO_MONOHEDRAL_EXAMPLE_REID_SIZE returns the size of the Reid system. Licensing: This code is distributed under the GNU LGPL license. Modified: 17 May 2018 Author: John Burkardt Parameters: Output, int *M, *N, the number of equations and variables. */ { *m = 9; *n = 10; return; } /******************************************************************************/ void polyomino_monohedral_example_reid_system ( int m, int n, int a[], int b[] ) /******************************************************************************/ /* Purpose: POLYOMINO_MONOHEDRAL_EXAMPLE_REID_SYSTEM sets up the Reid linear system. Licensing: This code is distributed under the GNU LGPL license. Modified: 17 May 2018 Author: John Burkardt Parameters: Output, double A[9*10], the system matrix. Output, double B[9], the right hand side. */ { /* Note that the matrix is specified in column major form. */ int a_save[9*10] = { 1,1,0,0,0,0,0,0,2, 0,0,1,1,0,0,0,0,2, 0,0,0,1,1,0,0,0,2, 0,0,0,0,0,1,1,0,2, 0,0,0,0,0,0,1,1,2, 1,0,1,0,0,0,0,0,2, 0,1,0,1,0,0,0,0,2, 0,0,1,0,0,1,0,0,2, 0,0,0,1,0,0,1,0,2, 0,0,0,0,1,0,0,1,2}; int b_save[9] = { 1, 1, 1, 1, 1, 1, 1, 1, 8 }; i4mat_copy ( 9, 10, a_save, a ); i4vec_copy ( 9, b_save, b ); return; } /******************************************************************************/ void i4mat_copy ( int m, int n, int a1[], int a2[] ) /******************************************************************************/ /* Purpose: I4MAT_COPY copies one I4MAT to another. Discussion: An I4MAT is an MxN array of I4's, stored by (I,J) -> [I+J*M]. Licensing: This code is distributed under the GNU LGPL license. Modified: 27 August 2008 Author: John Burkardt Parameters: Input, int M, N, the number of rows and columns. Input, int A1[M*N], the matrix to be copied. Output, int A2[M*N], the copy of A1. */ { int i; int j; for ( j = 0; j < n; j++ ) { for ( i = 0; i < m; i++ ) { a2[i+j*m] = a1[i+j*m]; } } return; } /******************************************************************************/ void i4vec_copy ( int n, int a1[], int a2[] ) /******************************************************************************/ /* Purpose: I4VEC_COPY copies an I4VEC. Discussion: An I4VEC is a vector of I4's. Licensing: This code is distributed under the GNU LGPL license. Modified: 25 April 2007 Author: John Burkardt Parameters: Input, int N, the number of entries in the vectors. Input, int A1[N], the vector to be copied. Input, int A2[N], the copy of A1. */ { int i; for ( i = 0; i < n; i++ ) { a2[i] = a1[i]; } return; }