function gurobi_solution_read_test ( )

%*****************************************************************************80
%
%% gurobi_solution_read_test() tests gurobi_solution_read().
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    14 June 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'GUROBI_SOLUTION_READ_TEST:\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  GUROBI_SOLUTION_READ tries to extract a solution vector\n' );
  fprintf ( 1, '  X returned by GUROBI for a particular polyomino tiling problem.\n' );

  filename = 'reid_gurobi.sol';
  gurobi_solution_read_demo ( filename );

  filename = 'pent5x6_gurobi.sol';
  gurobi_solution_read_demo ( filename );

  filename = 'pent18x30_gurobi.sol';
  gurobi_solution_read_demo ( filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'GUROBI_SOLUTION_READ_TEST:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
function gurobi_solution_read_demo ( filename )

%*****************************************************************************80
%
%% gurobi_solution_read_demo() analyzes a GUROBI solution read from a file.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    14 June 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'gurobi_solution_read_demo():\n' );
  fprintf ( 1, '  MATLAB version.\n' );
  fprintf ( 1, '  GUROBI solution file to be read is "%s"\n', filename );

  x = gurobi_solution_read ( filename );
%
%  Report the solutions.
%
  [ x_dim, x_num ] = size ( x );

  if ( x_dim <= 100 )
    i4mat_print ( x_dim, x_num, x, ' Unscrambled solution data:' );
  else
    fprintf ( 1, '\n' );
    fprintf ( 1, '  Data is rather large, so will not be printed out.\n' );
  end
%
%  Save X as a text file.
%
  [ filepath, name, extension ] = fileparts ( filename );
  filename2 = strcat ( name, '.txt' );

  output = fopen ( filename2, 'wt' );

  for i = 1 : x_dim
    for j = 1 : x_num
      fprintf ( output, '  %g', x(i,j) );
    end
    fprintf ( output, '\n' );
  end
  fclose ( output );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Wrote the ASCII file "%s"\n', filename2 );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'gurobi_solution_read_demo():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
