function pariomino_tiling_solver_test ( )

%*****************************************************************************80
%
%% pariomino_tiling_solver_test tests pariomino_tiling_solver.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 May 2020
%
%  Author:
%
%    John Burkardt
%
  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pariomino_tiling_solver_test:\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  pariomino_tiling_solver() sets up and solves the linear system\n' );
  fprintf ( 1, '  associated with a pariomino tiling problem.\n' );

  pariomino_tiling_solver_test01 ( )
  pariomino_tiling_solver_test02 ( )
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pariomino_tiling_solver_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  return
end
function pariomino_tiling_solver_test01 ( )

%*****************************************************************************80
%
%% pariomino_tiling_solver_test01 tests pariomino_tiling_solver.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 May 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pariomino_tiling_solver_test01:\n' );
  fprintf ( 1, '  pariomino_tiling_solver solves a pariomino\n' );
  fprintf ( 1, '  tiling problem for a 2x4 rectangle.\n' );
%
%  Define R.
%
  shape_r = [ ...
    -1, +1, -1, +1; ...
    +1, -1, +1, -1 ];

  [ m_r, n_r ] = size ( shape_r );
  pariomino_print ( shape_r, '  Region R:' );
%
%  Define N, O, P
%
  shape_n = [ ...
    -1 ];
  [ m_n, n_n ] = size ( shape_n );
  pariomino_print ( shape_n, '  pariomino N:' );

  shape_o = [ ...
    +1, -1, +1 ];
  [ m_o, n_o ] = size ( shape_o );
  pariomino_print ( shape_o, '  pariomino O:' );

  shape_p = [ ...
     0,  0, -1;
    +1, -1, +1 ];
  [ m_p, n_p ] = size ( shape_p );
  pariomino_print ( shape_p, '  pariomino P:' );
%
%  Pack the arrays into P.
%
  p_num = 3;
  p = zeros ( m_r, n_r, p_num );
  p(1:m_n,1:n_n,1) = shape_n(1:m_n,1:n_n);
  p(1:m_o,1:n_o,2) = shape_o(1:m_o,1:n_o);
  p(1:m_p,1:n_p,3) = shape_p(1:m_p,1:n_p);
%
%  Set the vector D, which indicates how many copies of each pariomino
%  we can use: one of each, in this case.
%
  d = ones ( p_num, 1 );
%
%  Set up and solve the system.
%
  filename = '2x4_case1.lp';
  comment = 'The 2x4 example, case 1.';
  [ m, n, k, a, b, x ] = pariomino_tiling_solver ( shape_r, p_num, p, d, ...
     filename, comment );
%
%  Reverse parity of the pieces.
%
  shape_n = pariomino_reverse ( shape_n );
  pariomino_print ( shape_n, '  pariomino -N:' );

  shape_o = pariomino_reverse ( shape_o );
  pariomino_print ( shape_o, '  pariomino -O:' );

  shape_p = pariomino_reverse ( shape_p );
  pariomino_print ( shape_p, '  pariomino -P:' );
%
%  Pack the arrays into P.
%
  p_num = 3;
  p = zeros ( m_r, n_r, p_num );
  p(1:m_n,1:n_n,1) = shape_n(1:m_n,1:n_n);
  p(1:m_o,1:n_o,2) = shape_o(1:m_o,1:n_o);
  p(1:m_p,1:n_p,3) = shape_p(1:m_p,1:n_p);
%
%  Set the vector D, which indicates how many copies of each pariomino
%  we can use: one of each, in this case.
%
  d = ones ( p_num, 1 );
%
%  Set up and solve the system.
%
  filename = '2x4_case2.lp';
  comment = 'The 2x4 example, case 2.';
  [ m, n, k, a, b, x ] = pariomino_tiling_solver ( shape_r, p_num, p, d, ...
     filename, comment );

  return
end
function pariomino_tiling_solver_test02 ( )

%*****************************************************************************80
%
%% pariomino_tiling_solver_test02 tests pariomino_tiling_solver.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 May 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pariomino_tiling_solver_test02:\n' );
  fprintf ( 1, '  pariomino_tiling_solver solves a pariomino\n' );
  fprintf ( 1, '  tiling problem for a subset of a 4x4 rectangle.\n' );
%
%  Define R.
%
  shape_r = [ ...
    +1,  0,  0,  0; ...
    -1,  0,  0,  0; ...
    +1, -1, +1, -1; ...
    -1, +1, -1, +1 ];

  [ m_r, n_r ] = size ( shape_r );
  pariomino_print ( shape_r, '  Region R:' );
%
%  Define N, O, P
%
  shape_n = [ ...
    0,  0, -1; ...
   +1, -1, +1 ];
  [ m_n, n_n ] = size ( shape_n );
  pariomino_print ( shape_n, '  pariomino N:' );

  shape_o = [ ...
    -1, +1, -1 ];
  [ m_o, n_o ] = size ( shape_o );
  pariomino_print ( shape_o, '  pariomino O:' );

  shape_p = [ ...
     0, +1;
    +1, -1 ];
  [ m_p, n_p ] = size ( shape_p );
  pariomino_print ( shape_p, '  pariomino P:' );
%
%  Pack the arrays into P.
%
  p_num = 3;
  p = zeros ( m_r, n_r, p_num );
  p(1:m_n,1:n_n,1) = shape_n(1:m_n,1:n_n);
  p(1:m_o,1:n_o,2) = shape_o(1:m_o,1:n_o);
  p(1:m_p,1:n_p,3) = shape_p(1:m_p,1:n_p);
%
%  Set the vector D, which indicates how many copies of each pariomino
%  we can use: one of each, in this case.
%
  d = ones ( p_num, 1 );
%
%  Set up and solve the system.
%
  filename = '4x4.lp';
  comment = 'The 4x4 example.';
  [ m, n, k, a, b, x ] = pariomino_tiling_solver ( shape_r, p_num, p, d, ...
     filename, comment );

  return
end
