function knapsack_values_test ( )

%*****************************************************************************80
%
%% knapsack_values_test() tests knapsack_values().
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    19 November 2024
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../knapsack_values' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'knapsack_values_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version: %s\n', version ( ) );
  fprintf ( 1, '  Test knapsack_values().\n' );

  n_data = 0;

  while ( true )

    [ n_data, n, v, w, s, k ] = knapsack_values ( n_data );

    if ( n_data == 0 )
      break;
    end

    fprintf ( 1, '\n' );
    fprintf ( 1, '  Problem #%d\n', n_data );
    fprintf ( 1, '  Number of items is %d\n', n );
    fprintf ( 1, '  Knapsack weight limit is %g\n', k );
    fprintf ( 1, '\n' );
    fprintf ( 1, '   Item 0/1  Value  Weight  Value/Weight\n' );
    fprintf ( 1, '\n' );
    for i = 1 : n
      r = v(i) / w(i);
      fprintf ( 1, '  %5d  %2d  %8.0f  %8.0f  %7.2f\n', ...
        i, s(i), v(i), w(i), r );
    end
    fprintf ( 1, '\n' );
    fprintf ( 1, '  Taken  %2d  %8.0f  %8.0f  %7.2f\n', ...
      sum ( s ), ...
      s * v', ...
      s * w', ...
      ( s * v' ) / ( s * w' ) );
  end
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'knapsack_values_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  timestamp ( );

  rmpath ( '../knapsack_values' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 November 2022
%
%  Author:
%
%    John Burkardt
%
  t = now ( );
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

