function x = scip_solution_read ( filename )

%*****************************************************************************80
%
%% SCIP_SOLUTION_READ reads solution vectors from an SCIP file.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license. 
%
%  Modified:
%
%    21 June 2018
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, string FILENAME, the name of the input file.
%
%    Output, integer X(X_DIM,X_NUM), an array of X_NUM solutions, each
%    of length X_DIM.
%
  debug = false;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'SCIP_SOLUTION_READ:\n' );
  fprintf ( 1, '  Extract solution information from an SCIP solution file.\n' );
%
%  Get variable permutation from first line of file.
%
  index = scip_index_read ( filename );
%
%  Compute the inverse permutation.
%
  index_num = length ( index );
  index_inverse(index) = 1:index_num;

  if ( debug )
    i4vec2_print ( index_num, index, index_inverse, ...
      '  Index vector and inverse index vector:' );
  end
%
%  Read data as a CSV file (thanks, James Cheung!).
%  Skip row 1 (a comment line).
%  Skip column 1 (some kind of solution index).
%
  x = csvread ( filename, 1, 1 );
%
%  Drop the last column, which indexes objval.
%
  x = x(:,1:end-1);
%
%  Transpose X.
%
  x = x';
%
%  Force all solutions to be nonnegative and integral.
%
  x = abs ( x );

  x = round ( x );
%
%  Optionally print scrambled X.
%
  if ( debug )
    [ x_dim, x_num ] = size ( x );
    i4mat_print ( x_dim, x_num, x, '  Scrambled solution data X:' );
  end
%
%  Use inverse permutation to unscramble data.
%
  x = x(index_inverse,:);

  return
end
