function pentomino_approximate_test ( )

%*****************************************************************************80
%
%% pentomino_approximate_test() tests polyomino_multihedral_matrix2().
%
%  Discussion:
%
%    The problem seeks to tile the 8x8 rectangle with 12 distinct pentominoes.
%
%    This function sets up the corresponding linear system.  But because
%    the system is large, we expect the solution to be carried out by a
%    standard integer programming package such as CPLEX.
%
%    The resulting solution vectors X can then be examined.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 June 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pentomino_approximate_test():\n' );
  fprintf ( 1, '  polyomino_multihedral_matrix2() sets up the matrix\n' );
  fprintf ( 1, '  for a tiling problem involving pentominoes.\n' );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'polyomino_multihedral_example_pentomino_matrix():\n' );
  fprintf ( 1, '  Set up the linear system for the 8x8 pentomino example.\n' );
%
%  Define R, an 8x8 square with a 2x2 hole.
%
  r_shape = ones(8,8);
  r_shape(4:5,4:5) = 0;
  [ r_m, r_n ] = size ( r_shape );
  polyomino_print ( r_shape, '  Region R:' );
%
%  Define pentominoes.
%
  pentomino = [ 'F', 'I', 'L', 'N', 'P', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ];

  p_num = 12;
  p_shape = zeros ( r_m, r_n, p_num );

  for k = 1 : p_num
    name = pentomino(k);
    pent = pentomino_matrix ( name );
    [ pent_m, pent_n ] = size ( pent );
    p_shape(1:pent_m,1:pent_n,k) = pent(1:pent_m,1:pent_n);
  end
%
%  Print the polyominoes.
%
  polyominoes_print ( r_m, r_n, p_num, p_shape, '  The 12 Pentominoes:' );
%
%  Set the vector D, which indicates how many copies of each polyomino
%  we can use: one of each, in this case.
%
  d = ones ( p_num, 1 );
%
%  Compute the system matrix.
%
  [ A1, b1, A2, b2 ] = polyomino_multihedral_matrix2 ( r_shape, p_num, p_shape, d );
  [ m1, n ] = size ( A1 );
  [ m2, n ] = size ( A2 );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Linear system A1 has size %d x %d\n', m1, n );
  fprintf ( 1, '  Linear system A2 has size %d x %d\n', m2, n );
%
%  Write the linear system to an LP file.
%
  filename = 'pentomino_approximate.lp';
  comment = 'The 8x8 multihedral pentomino approximate example.';
  polyomino_lpa_write ( filename, comment, A1, b1, A2, b2 );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'polyomino_multihedral_example_pentomino_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end

