function domino_approximate_test ( )

%*****************************************************************************80
%
%% domino_approximate_test() tests polyomino_monohedral_matrix2().
%
%  Discussion:
%
%    The region R is the "mutilated checkerboard":
%
%    01111111
%    11111111
%    11111111
%    11111111
%    11111111
%    11111111
%    11111111
%    11111110
%
%    To be covered by 31 dominos:
%
%      11
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 May 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'domino_approximate_test():\n' );
  fprintf ( 1, '  We set up an LP file for an approximate tiling problem\n' );
  fprintf ( 1, '  of the mutilated chessboard with dominoes.\n' );
%
%  Define R.
%
  shape_r = [ ...
    0, 1, 1, 1, 1, 1, 1, 1;
    1, 1, 1, 1, 1, 1, 1, 1;
    1, 1, 1, 1, 1, 1, 1, 1;
    1, 1, 1, 1, 1, 1, 1, 1;
    1, 1, 1, 1, 1, 1, 1, 1;
    1, 1, 1, 1, 1, 1, 1, 1;
    1, 1, 1, 1, 1, 1, 1, 1;
    1, 1, 1, 1, 1, 1, 1, 0 ];

  [ m_r, n_r ] = size ( shape_r );
  polyomino_print ( shape_r, '  Region R:' );
%
%  Define P.
%
  shape_p = [ ...
    1, 1 ];

  [ m_p, n_p ] = size ( shape_p );
  polyomino_print ( shape_p, '  Polyomino P:' );
%
%  Get the system matrix and right hand side.
%
%  Construct the linear system implicitly, from R and P.
%
  [ A1, b1, A2, b2 ] = polyomino_monohedral_matrix2 ( shape_r, shape_p )
  [ m1, n ] = size ( A1 );
  [ m2, n ] = size ( A2 );
%
%  Print the linear system.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  System matrix A1 and right hand side b1:\n' );
  fprintf ( 1, '\n' );
  for i = 1 : m1
    fprintf ( 1, '  ' );
    for j = 1 : n
      fprintf ( 1, '%2d', A1(i,j) );
    end
    fprintf ( 1, '  %2d\n', b1(i) );
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  System matrix A2 and right hand side b2:\n' );
  fprintf ( 1, '\n' );

  for i = 1 : m2
    fprintf ( 1, '  ' );
    for j = 1 : n
      fprintf ( 1, '%2d', A2(i,j) );
    end
    fprintf ( 1, '  %2d\n', b2(i) );
  end
%
%  Write the linear system to an LP file.
%
  filename = 'domino_approximate.lp';
  label = '\ LP file, approximate domino example, polyomino_lpa_write().';

  polyomino_lpa_write ( filename, label, A1, b1, A2, b2 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Wrote the approximate LP file "%s"\n', filename );

  return
end
