function knapsack_brute_test01 ( )

%*****************************************************************************80
%
%% knapsack_brute_test01() tests knapsack_brute().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 November 2024
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'knapsack_brute_test01():\n' );
  fprintf ( 1, '  knapsack_brute() uses a brute force approach.\n' );
  fprintf ( 1, '  Maximize profit without exceeding weight limit.\n' );

  n_data = 0;

  while ( true )

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

    if ( n_data == 0 )
      break;
    end

    d = v ./ w;

    [ vmax, wmax, smax ] = knapsack_brute ( n, v, w, k );

    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  Density\n' );
    fprintf ( 1, '\n' );
    for i = 1 : n
      fprintf ( 1, '  %5d  %2d  %8.0f  %8.0f  %7.2f\n', ...
      i, smax(i), v(i), w(i), d(i) );
    end
    fprintf ( 1, '' );
    fprintf ( 1, '  Taken  %2d  %8.0f  %8.0f  %7.2f\n', ...
      sum ( smax ), ( smax' * v ), ( smax' * w ), ...
      ( smax' * v ) / ( smax' * w ) )

  end

  return
end
