# include # include # include using namespace std; # include "polyomino_lp_write.hpp" 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[] ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // 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; string filename = "reid.lp"; string label = "\\ LP file for the Reid example, created by POLYOMINO_LP_WRITE."; int m; int n; timestamp ( ); cout << "\n"; cout << "POLYOMINO_LP_WRITE_TEST:\n"; cout << " C++ version\n"; cout << " POLYOMINO_LP_WRITE writes an LP file associated\n"; cout << " with a binary programming problem for tiling a region\n"; cout << " 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 = new int[m*n]; b = new int[m]; polyomino_monohedral_example_reid_system ( m, n, a, b ); // // Create the LP file. // polyomino_lp_write ( filename, label, m, n, a, b ); cout << "\n"; cout << " Created the LP file '" << filename << "'\n"; // // Free memory. // delete [] a; delete [] b; // // Terminate. // cout << "\n"; cout << "POLYOMINO_LP_WRITE_TEST:\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void polyomino_monohedral_example_reid_size ( int &m, int &n ) //****************************************************************************80 // // 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; } //****************************************************************************80 void polyomino_monohedral_example_reid_system ( int m, int n, int a[], int b[] ) //****************************************************************************80 /* 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; } //****************************************************************************80 void i4mat_copy ( int m, int n, int a1[], int a2[] ) //****************************************************************************80 // // 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; } //****************************************************************************80 void i4vec_copy ( int n, int a1[], int a2[] ) //****************************************************************************80 // // 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. // // Output, int A2[N], the copy of A1. // { int i; for ( i = 0; i < n; i++ ) { a2[i] = a1[i]; } return; }