function x = cplex_solution_single_read ( data )

%*****************************************************************************80
%
%% cplex_solution_single_read() reads a CPLEX single solution file.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 July 2018
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    struct DATA, the solution data structure.
%
%  Output:
%
%    real X(?,1), the single solution vector.
%

%
%  Get the number of solutions.
%
  sol_num = 1;
%
%  Determine how many nonzero values are given in this solution.
%
  nonzero_num = length ( data.CPLEXSolution.variables.variable );
%
%  Make a guess for the size of X.
%  It is not necessarily nonzero_num; it may be greater.
%
  x = zeros ( nonzero_num, 1 );
%
%  Read the name, index, and value for each nonzero entry and save into X.
%
  for nonzero_index = 1 : nonzero_num
    name = data.CPLEXSolution.variables.variable{nonzero_index}.Attributes.name;
    var_index = str2num ( name(2:end) );
    value = data.CPLEXSolution.variables.variable{nonzero_index}.Attributes.value;
    value = str2num ( value );
    x(var_index,1) = value;
  end

  return
end
